How Do You Create a Node.js Application to Be Presentable and Usable via a Docker Container?

Problem scenario
You want to create a basic “Hello World” web page with Node.js running in a Docker container.  How do you do this?

Solution
Prerequisite

Install Docker.  If you need assistance, see this posting.

Procedures
1.  Create three files in the same directory on a Linux server. 

How Do You Install kubeadm on Any Type of Linux?

Problem scenario
You want a quick, generic way to install kubeadm on any type of Linux.  What should you do?

Solution
Run these commands:

cd /tmp

curl -Lo kubeadm https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubeadm && chmod +x kubeadm

sudo mv kubeadm /usr/bin/

Test it by running this command: kubeadm version

(If you would prefer to use apt commands,

How Do You Install kubelet on Any Type of Linux?

Problem scenario
You want a quick, generic way to install kubelet on any type of Linux.  What should you do?

Solution
Run these commands:

cd /tmp

curl -Lo kubelet https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubelet && chmod +x kubelet

sudo mv kubelet /usr/bin/

Test it by running this command: kubelet –version

(If you would prefer to use apt commands,

How Do You Secure a Docker Container, a Docker Host, and Their Network?

Problem Scenario
You have been tasked with finding ways of securing Docker containers, a Docker host, and your network that has Docker containers.  How do you harden a Docker container and its related infrastructure (i.e., the Docker network and Docker host)?

Solution
Overview

From a pragmatic perspective we understand that there are exceptions to the recommended practices.  (Not the least of which is the rapid rate that technology changes.)  The assertions below are recommended practices. 

How Do You Delete VM Instances from GCP That Pertain to GKE?

Problem Scenario
You have some GKE standard clusters that you want deleted.  What should you do?

Possible Solution #1 (from the Cloud Shell or with a gcloud command)
1.  Delete the instance group of the instance for the cluster you want to delete.  To do this in the web UI, go to Compute Engine -Instance Groups.  Check the box on the left-hand side and click on “Delete”.

How Do You Troubleshoot the kubectl Error “Access denied status code: 403”

Problem scenario
You run a kubectl command but you get this error:

“could not get token: AccessDenied: Access denied
        status code: 403, request id:
Unable to connect to the server: getting credentials: exec: exit status 1″

What should you do?

Solution
The root cause is likely that your .kube directory has an incorrect configuration file. 

Possible Solution #1
If you are not using Amazon EKS,

How Do You Troubleshoot the “kops” error “unable to infer CloudProvider from Zones (is there a typo in –zones?)”?

Problem scenario
You run a “kops” command but you receive this error:

“unable to infer CloudProvider from Zones (is there a typo in –zones?)”

How do you get the “kops” command to work?

Solution
There is a value and a format that are necessary for your kops’ “–zones” flag.

Determine what region you want to know the zone name for (e.g.,

How Do You Troubleshoot the Amazon EKS Web Console Error “AccessDeniedException not authorized to perform: iam:PassRole on resource”?

Problem scenario
You are logged into the AWS web console.  You try to perform an operation but you get this error:

“AccessDeniedException
User: arn:aws:iam::12345678910:user/jdoe is not authorized to perform: iam:PassRole on resource: arn:aws:iam::12345678910:role/rolename”

What should you do?

Solution
1.  Create a role with “EKS” (to create Kubernetes clusters).  If you don’t know how, see this posting.
2. 

How Do You Troubleshoot the “kubectl” Error ‘the server doesn’t have a resource type “svc”‘?

Problem scenario
You are trying to use Kubernetes in AWS.  You have installed kubectl and you run this command:

kubectl get svc

You receive this:  ‘error: the server doesn’t have a resource type “svc”‘

You try again with a more verbose output.  You run this command:

kubectl get svc -v=8

In the output you see messages like this: “Response Status: 401 Unauthorized in 73 milliseconds”

What should you do to use kubectl with AWS?

How Do You Troubleshoot “Redirecting to /bin/systemctl start docker.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units”?

Problem Scenario
You try to configure Docker such that you can run “docker” commands without sudo.  You run these three commands:

sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker

You then installed Docker and rebooted the server.  You then run this:

docker run hello-world

But you received this:

/usr/bin/docker-current: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.