Why is a Kubernetes Pod’s Status “Pending”, and What Can Be Done about It?

Problem scenario
You have a Pod that you want to run on a worker node. Its status is “Pending.” What can you do to get the Pod to proceed (and what are some common root causes for this problem)?

Background
A common root cause is that the nodes have insufficient resources for the Pod (e.g., insufficient CPU or memory).

Possible Solution #1
Wait.

How Do You Pass Two or More Subnets to an “aws eks” Command?

Problem scenario
You want to pass more than one subnet to an “aws eks” command.

You tried to delimit the list with commas (or separate two subnet IDs with commas). You received this error message:

An error occurred (InvalidParameterException) when calling the CreateNodegroup operation: The subnet ID ‘subnet-0abcd1234,subnet-zyxw9876’ does not exist (Service: AmazonEC2; Status Code: 400; Error Code: InvalidSubnetID.NotFound; Request ID: Proxy: null)

What should you do?

How Do You Get Chef to Be Automatically Installed and Configured (e.g., in a Docker Container)?

Problem scenario
You have a Docker container that supports Chef or some automatic way of installing Chef. The automation is failing at the end because you are being prompted to accept a license. What should you do to be able to invoke Chef commands automatically?

Solution
With the first Chef command, e.g., “chef env”, use the “–chef-license accept” option/flag. Here is an example:

chef env –chef-license accept

For more information,

How Do You Troubleshoot a Kubernetes Cluster That is Not Working at the Node Level?

Problem scenario
The nodes in a Kubernetes cluster are not working. What should you do?

Possible Solution #1
Run this command: kubectl get nodes
For the node that is not healthy, assuming its hostname is called “foobar”, run this command: kubectl describe node foobar

Possible Solution #2
If you have pods and no nodes (which could be the case),

How Do You Install Troubleshoot the Kubernetes Error “dial tcp x.x.x.x:10248 connection refused”?

Problem scenario
You are trying to run “kubeadm init”, but you get this error:

“failed with error: Get “http://localhost:10248/healthz”: dial tcp 127.0.0.1:10248: connect: connection refused.”

What should you do?

Solution
Is the kubelet service running? Run this: sudo systemctl status kubelet

To install the kubelet, see this posting for How Do You Install the kubelet on any type of Linux?

How Do You Troubleshoot the Kubernetes Error “[ERROR Port-10250]: Port 10250 is in use”?

Problem scenario
You are trying to run a kubeadm command. But you get this error:

[preflight] Running pre-flight checks
error execution phase preflight: [preflight] Some fatal errors occurred:
[ERROR Port-10250]: Port 10250 is in use
[preflight] If you know what you are doing, you can make a check non-fatal with –ignore-preflight-errors=…

What should you do?

Solution
Remove the kubelet that snap installed;

Using a Debian/Ubuntu Distribution of Linux, How Do You Install kubeadm, kubectl, and/or kubelet?

Problem scenario
Using a Debian/Ubuntu distribution of Linux, how do you install kubeadm, kubectl, and/or kubelet?

You want to install kubeadm, kubectl or kubelet (without retrieving the binary of the file from a website and do a regular installation). What do you do?

Solution
Here is another way to install kubectl, kubelet and kubeadm:

curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-add-repository “deb http://apt.kubernetes.io/ kubernetes-xenial main”
sudo apt-get -y install kubeadm kubelet kubectl

(If you can download a file from the internet and want to avoid using apt commands,

How Do You Solve the Kubernetes Error “networkPlugin cni failed to set up pod network: open /run/flannel/subnet.env: no such file or directory”?

Problem scenario
You run kubectl describe pods. You see a message in the output that says

networkPlugin cni failed to set up pod network: open /run/flannel/subnet.env: no such file or directory.

How do you fix this?

Possible Solution #1
Log into every worker node. Make sure it has /run/flannel/subnet.env with the following four lines:

FLANNEL_NETWORK=10.244.0.0/16
FLANNEL_SUBNET=10.244.0.1/24
FLANNEL_MTU=1450
FLANNEL_IPMASQ=true

(This solution was adapted from https://www.programmersought.com/article/7824768991/)

Possible Solution #2
Run this: kubectl get pods.