kubernetes pods keep crashing with “CrashLoopBackOff” {GKE}

As in my last blog www.openwriteup.com/create-gke-pod-from-local-image/

I have deployed the pod, deployed using local image on GKE. It is failing with CrashLoopBackOff error. It was not giving any logs as well.

kubectl logs <pod name>
//no log message is reporting

After I have added the command block in the pod yaml

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: ubuntu
  name: ubuntu
  namespace: default
spec:
  containers:
  - image: gcr.io/openwriteup/hellokubernetes/ubuntu
    imagePullPolicy: Never
    name: ubuntu
    resources:
      requests:
        cpu: 100m
    command: ["/bin/sh"]
    args: ["-c", "while true; do echo hello; sleep 10;done"]
  dnsPolicy: ClusterFirst
  enableServiceLinks: true

#command and args has added in the yaml file
Now I have executed
kubectl apply -f pod.yaml
[root@target-1 ~]# kubectl get pods
NAME     READY   STATUS    RESTARTS   AGE
ubuntu   1/1     Running   0          9m30s

kubelet.service fail to start up

kubeadm init is failing due to kubelet.service is failed to start.

I performed the below step and it worked for me!!

#yum install -y kubelet kubeadm kubectl docker

Make swap off by #swapoff -a

Now reset kubeadm by #kubeadm reset

Now try #kudeadm init

after that check #systemctl status kubelet

it will be working!!!

x509 cert issues after kubeadm init

While issuing command “kubeadm token list”, reporting the below issu

failed to list bootstrap tokens [Get https://192.168.40.132:6443/api/v1/namespaces/kube-system/secrets?fieldSelector=type%3Dbootstrap.kubernetes.io%2Ftoken: x509: certificate signed by unknown authority (possibly because of “crypto/rsa: verification error” while trying to verify candidate authority certificate “kubernetes”)

Perform following step:

cp /etc/kubernetes/admin.conf ~/.kube/admin.conf

export KUBECONFIG=$HOME/.kube/admin.conf

kubeadm token list
TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS
h94rrx.90dkwkukxgcp3635 23h 2018-10-22T08:29:50-07:00 authentication,signing The default bootstrap token generated by ‘kubeadm init’. system:bootstrappers:kubeadm:default-node-token