Wednesday 18 October 2017

Kubernetes Issues


  1. The pods in kubernetes are in pending state when we execute kubectl get pods
    Execute the following command to see the root cause:
    kubectl get events
    You will see output as follows:
    LAST SEEN FIRST SEEN COUNT NAME KIND SUBOBJECT TYPE REASON SOURCE MESSAG E
    1m 14h 3060 hello-nginx-5d47cdc4b7-8btwf.14ecd67c4676131c Pod Warning FailedScheduling default-scheduler No nod es are available that match all of the predicates: PodToleratesNodeTaints (1).This error usually comes when we try to create pod on the master node:
    Execute the following command:
    kubectl taint nodes <nodeName> node-role.kubernetes.io/master:NoSchedule-
    


  2. helm install stable/mysql: Error: no available release name found
    Execute the helm ls command to get the root cause:
    The error I received is
    Error: configmaps is forbidden: User "system:serviceaccount:kube-system:default" cannot list configmaps in the namespace "kube-system"
    The default serviceaccount does not have API permissions. Helm likely needs to be assigned a service account, and that service account given API permissions.
    The commands used to solve are:
    kubectl create serviceaccount --namespace kube-system tiller
    kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
    kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
    helm init --service-account tiller --upgrade

    After that if you get the following error: Error: forwarding ports: error upgrading connection: unable to upgrade connection: pod not found ("tiller-deploy-cffb976df-m5z6f_kube-system")
    Then execute helm init --upgrade
  3. kubernetes pods keep crashing with “CrashLoopBackOff” but I can't find any logI had the need to keep a pod running for subsequent kubectl exec calls and as the comments above pointed out my pod was getting killed by my k8s cluster because it had completed running all its tasks. I managed to keep my pod running by simply kicking the pod with a command that would not stop automatically as in:
    kubectl run YOUR_POD_NAME -n YOUR_NAMESPACE --image SOME_PUBLIC_IMAGE:latest --command tailf /dev/null
    

     
  4. Create busybox kubernetes pod
    kubectl run -i --tty busybox --image=busybox --restart=Never -- sh
  5. Kubernetes pods cannot connect to internet kubeadm:
    If your pods cannot connect to the internet, you caan check the following:
    Spin up a busybox
    Execute: ping 8.8.8.8
    ping google.com
    route -n You will get an ip for gateway. Check if you can ping the gateway
    In the kubernetes master node check the ip of kube-dns pod with command:
    kubectl get pods -n kube-system -o wide | grep kube-dns this will return an IP in output. In your pod container check if this IP is present as nameserver.
    ifconfig note the IP address range assigned to the container.
    In the kubernetes master node execute ifconfig check that the IP address noted previously belong to which bridge's IP range.
    If it belongs to some other interface than expected you can check it by executing:
    brctl show check if the bridge has an interface attached to it.
    If not this is the reason the pods do not have an internet connection.
    You can attach the interface with this command:
    brctl addif mybridge eth0
    This issue can be in the weave network, try to do a kubeadm reset and add a flannel network

Harry

Author & Editor

A technology enthusiast and addictive blogger who likes to hacking tricks and wish to be the best White Hacket Hacker of the World.

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.