Skip to main content

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

Comments

Popular posts from this blog

Terraform

Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied. The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc. The key features of Terraform are: Infrastructure as Code : Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and

Java 8 coding challenge: Roy and Profile Picture

Problem:  Roy wants to change his profile picture on Facebook. Now Facebook has some restriction over the dimension of picture that we can upload. Minimum dimension of the picture can be  L x L , where  L  is the length of the side of square. Now Roy has  N  photos of various dimensions. Dimension of a photo is denoted as  W x H where  W  - width of the photo and  H  - Height of the photo When any photo is uploaded following events may occur: [1] If any of the width or height is less than L, user is prompted to upload another one. Print " UPLOAD ANOTHER " in this case. [2] If width and height, both are large enough and (a) if the photo is already square then it is accepted. Print " ACCEPTED " in this case. (b) else user is prompted to crop it. Print " CROP IT " in this case. (quotes are only for clarification) Given L, N, W and H as input, print appropriate text as output. Input: First line contains  L . Second line contains  N , number of

Salt stack issues

The function “state.apply” is running as PID Restart salt-minion with command:  service salt-minion restart No matching sls found for ‘init’ in env ‘base’ Add top.sls file in the directory where your main sls file is present. Create the file as follows: 1 2 3 base: 'web*' : - apache If the sls is present in a subdirectory elasticsearch/init.sls then write the top.sls as: 1 2 3 base: '*' : - elasticsearch.init How to execute saltstack-formulas create file  /srv/pillar/top.sls  with content: base : ' * ' : - salt create file  /srv/pillar/salt.sls  with content: salt : master : worker_threads : 2 fileserver_backend : - roots - git gitfs_remotes : - git://github.com/saltstack-formulas/epel-formula.git - git://github.com/saltstack-formulas/git-formula.git - git://github.com/saltstack-formulas/nano-formula.git - git://github.com/saltstack-f