How Do You Use a YAML File or a YAML Manifest in Kubernetes?

Problem scenario
Kubernetes can use YAML files for configuration. The book Kubernetes in Action by Luksa refers to these files as manifests (pages 148), YAML manifests (page 155) or “pod manifests” (page 451). The Kubernetes website refers to this YAML file as “the PodSpec” here. Pod templates are defined inside these .yaml files (as a subset of the file itself). How do you use these YAML files?

How Do You Determine the IP Address Assignments of Running Docker Containers?

Problem scenario
You created some Docker containers and assigned them IP addresses. How do you find out what their IP addresses are?

Solution

1. Run this command: docker ps -a # find the container ID of the container you want to know about
2. Run this command but substitute “container_id” with the container ID you found above:
docker inspect -f ‘{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}’ container_id

What Are The Kubernetes Concepts “pod label,” “label selector,” and “pod selector”?

Question
What is the difference between these three two-word terms “pod label,” “label selector,” and “pod selector”?

Answer
This answer provides details on what these are and provides some information on how they are different.

pod label: It is an inherent attribute of the pod. It can be changed via a command like this: kubectl label pod new-podlabel version=5.5 These statements were based on Assistanz.com.

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

Problem Scenario
You have some GKE standard clusters that you want deleted. You try to delete them, but they do not go away. What should you do?

Solution
Root cause: Kubernetes clusters are self-healing. They are acting as they were designed. Once the instance group is deleted, you will be able to delete the instances via the web UI or via Google’s Cloud Shell.

Why Would a MongoDB Container Work on an Ubuntu Host but Not a SUSE Host?

Problem scenario
You have two Linux servers in AWS, and each one has the same flavor (i.e., same amount of RAM and same number of processors). One is Ubuntu and another is SUSE. These commands will create working containers in Ubuntu:

docker run –name name1-mongo -d mongo
docker run –name name2-mongo -d mongo:2

This command will not create a working container in SUSE:

docker run –name name2-mongo -d mongo:2

The container that is created will never start.

How Do You Set up Nginx as an HTTP Load Balancer So Client Requests (from Web Browsers) Do Not Go to Certain Nginx Servers unless Others Are Down?

Problem scenario
You have a web server running Nginx that acts as a reverse proxy server.  On occasion your regular web (Nginx) servers go down.  You want to have one or two web (Nginx) servers that are  reserved as backups exclusively.  You do not want traffic going to these servers unless the main Nginx servers are unavailable (either due to network or server failure).  You can allocate RAM and CPU to these reserved servers on demand. 

How Do You Find the URL of Your Kubernetes Cluster?

Problem scenario
You want to view the website that is powered by Kubernetes. But you do not know which URL to go to. What should you do from the back-end server with kubectl?

Solution

1. Run this: kubectl get services
With the resulting output, find a name that you want the URL for. (Services have names.) Let’s assume the name was “foobar”.

How Do You Troubleshoot the Error “Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock”?

Problem scenario
You try to run a Docker command, but you get this error: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.29/containers/json?all=1: dial unix /var/run/docker.sock: connect: permission denied

What should you do?

Solution
Have you added the user who was trying to execute the command to the “docker” group?

This command would add the user jdoe to the “docker” group:
sudo usermod -aG docker jdoe

If you ran the above command as the jdoe user,

What Is a docker-compose.yml File?

Question
What is a docker-compose.yml file?

Answer
It is a file used by the docker-compose utility which orchestrates the creation of multiple containers. For microservices, SOA and various stacks of applications (e.g., the LAMP stack), container orchestration is useful. Here are some quotes which help elucidate what docker-compose does:

“Compose is a tool for defining and running multi-container Docker applications.” (Taken from Docker’s website.)

“In order to do something useful with containers,