How Do You Troubleshoot The Message “Error from server (NotFound): the server could not find the requested resource”?

Updated 9/20/19

Problem scenario
You run the kubectl command. You receive “Error from server (NotFound): the server could not find the requested resource.” How do you resolve this?

Solution
1.a. Run this command: kubectl version | grep Version

Look at the GitVersion values for the client and server. They should match or nearly match.

What is a ReplicationController in Kubernetes?

Question
What is a ReplicationController in Kubernetes?

Answer
It is a component that ensures the pods are constantly running (page 90 and 91 of Kubernetes in Action by Luksa). They were designed to create and manage redundant pods (page 91 of Kubernetes in Action by Luksa). They do just that — they do not transfer pods but create new ones on different nodes (page 93 of Kubernetes in Action by Luksa).

How Do You Connect to a Particular Docker Repository or Registry to Run a “docker push” Command?

Problem scenario
You want to use the “docker push” command. But you do not know how your Docker host is configured. You want to know what repository your Docker host is configured to use. How do you determine which repository your “docker push” commands will be destined to?

Solution
Docker push involves a destination Docker registry — not a repository. A registry is a collection of Docker repositories (things that hold versions of Docker images).

How Do You Create Your Own kubeconfig File?

Problem scenario
You want to create a kubeconfig file automatically. But you do not know how. What should you do?

Prerequisites
If kubelet, kubeadm and kubectl are installed, skip the prerequisites to go to step #1 in the procedures. Otherwise, run these commands:

cd /tmp

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

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 && …

How Do You Troubleshoot the Error “kubelet service is not enabled” or How Do You Write Your Own .service File in Linux?

Problem scenario
You try to run a kubeadm command. You get an error about kubelet

” [WARNING Service-Kubelet]: kubelet service is not enabled, please run ‘systemctl enable kubelet.service'”

How do you get “sudo systemctl start kubelet” or “sudo systemctl enable kubelet” to work? How do you create your own kubelet.service file?

Solution

  1. Create this file: /etc/systemd/system/kubelet.service
  2. The content should be as follows (but you may need to double check that the kubelet file is there;

How Do You Install Docker on Debian Linux in GCP?

Problem scneario
In Google Cloud Platform you have a Debian Linux server. You want to install Docker on it. What do you do?

Solution
1. Create a file called dockerinstall.sh in the /tmp/ directory with the following content:

apt-get -y update
apt-get install -y apt-transport-https ca-certificates wget software-properties-common

wget https://download.docker.com/linux/debian/gpg
apt-key add gpg

echo “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee -a /etc/apt/sources.list.d/docker.list
apt-get -y update

apt-get -y install docker-ce

2.

How Do You Create a Dockerfile That Will Use Reserved Words Such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL?

Problem scenario
You want to create your own Dockerfile. You also want to invoke reserved words such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL. You want to then create a Docker image from it. You want to ultimately create a working Docker container from that image. How do you do all of this?

Solution

1. In a given directory,

How Do You Troubleshoot the Google Kubernetes Engine error “Request had insufficient authentication scopes”?

Problem scenario
You run a command like this:
gcloud container clusters get-credentials standard-cluster-1 –region us-central1-a

But you receive one of the following messages:
“Fetching cluster endpoint and auth data.
ERROR: (gcloud.container.clusters.get-credentials) ResponseError: code=403, message=Request had insufficient authentication scopes.”

ERROR: (gcloud.projects.describe) User [123456789-compute@developer.gserviceaccount.com] does not have permission to access projects instance [123456789] (or it may not exist): Request had insufficient
authentication scopes.

How Do You Troubleshoot This Error “error executing access token command /google/google-cloud-sdk/bin/gcloud”?

Problem scenario
You run a command like this to view your Google Kubernetes Engine (GKE) clusters:

kubectl get pods

You see this:
‘Unable to connect to the server: error executing access token command “/google/google-cloud-sdk/bin/gcloud config config-helper –format=json”: err=fork/exec /google/google-cloud-sdk/bin/gcloud: no such file or directory output= stderr=’

What should you do?

Solution
Check your config file in the .kube directory.