Troubleshoot Deployment issues in Kubernetes

Ticker

6/recent/ticker-posts

Troubleshoot Deployment issues in Kubernetes

Question: Last week, the Nautilus DevOps team deployed a redis app on Kubernetes cluster, which was working fine so far. This morning one of the team members was making some changes in this existing setup, but he made some mistakes and the app went down. We need to fix this as soon as possible. Please take a look.

The deployment name is redis-deployment. The pods are not in running state right now, so please look into the issue and fix the same.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.

Please Note :-  Perform the below commands based on your question server,  user name & other details that might differ. So please read the task carefully before executing it. 
All the Best 👍
Solution:  

1. Check existing running deployment, pods 

thor@jump_host ~$ kubectl get deployment

NAME               READY   UP-TO-DATE   AVAILABLE   AGE

redis-deployment   0/1     1            0           2m3s

thor@jump_host ~$

thor@jump_host ~$ kubectl get pods

NAME                               READY   STATUS              RESTARTS   AGE

redis-deployment-76cc9c56f-2ncqs   0/1     ContainerCreating   0          2m13s

thor@jump_host ~$

thor@jump_host ~$ kubectl get configmap

NAME               DATA   AGE

kube-root-ca.crt   1      31m

redis-config       2      2m24s

thor@jump_host ~$

2. Describe the configuration of the deployment

thor@jump_host ~$ kubectl describe deployment

Name:                   redis-deployment

Namespace:              default

CreationTimestamp:      Wed, 08 Sep 2021 05:29:51 +0000

Labels:                 app=redis

Annotations:            deployment.kubernetes.io/revision: 1

Selector:               app=redis

Replicas:               1 desired | 1 updated | 1 total | 0 available | 1 unavailable

StrategyType:           RollingUpdate

MinReadySeconds:        0

RollingUpdateStrategy:  25% max unavailable, 25% max surge

Pod Template:

  Labels:  app=redis

  Containers:

   redis-container:

    Image:      redis:alpin

    Port:       6379/TCP

    Host Port:  0/TCP

    Requests:

      cpu:        300m

    Environment:  <none>

    Mounts:

      /redis-master from config (rw)

      /redis-master-data from data (rw)

  Volumes:

   data:

    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)

    Medium:    

    SizeLimit:  <unset>

   config:

    Type:      ConfigMap (a volume populated by a ConfigMap)

    Name:      redis-cofig

    Optional:  false

Conditions:

  Type           Status  Reason

  ----           ------  ------

  Available      False   MinimumReplicasUnavailable

  Progressing    True    ReplicaSetUpdated

OldReplicaSets:  redis-deployment-76cc9c56f (1/1 replicas created)

NewReplicaSet:   <none>

Events:

  Type    Reason             Age    From                   Message

  ----    ------             ----   ----                   -------

  Normal  ScalingReplicaSet  2m45s  deployment-controller  Scaled up replica set redis-deployment-76cc9c56f to 1

thor@jump_host ~$

thor@jump_host ~$ kubectl describe configmap

Name:         kube-root-ca.crt

Namespace:    default

Labels:       <none>

Annotations:  <none>

 

Data

====

ca.crt:

----

-----BEGIN CERTIFICATE-----

MIIC5zCCAc+gAwIBAgIBADANBgkqhkiG9w0BAQsFADAVMRMwEQYDVQQDEwprdWJl

cm5ldGVzMB4XDTIxMDkwODA0NTg1N1oXDTMxMDkwNjA0NTg1N1owFTETMBEGA1UE

AxMKa3ViZXJuZXRlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALzT

GQui8idNXu6xmhcksVTWhGdsgscKC8aBabcB/eW6PMAq+1h02ugctOUOpUeN3xRY

yzEUN4cz5DUcIw3HMk+BMRGUgCSSA6goUDGikfRWydKFxGx9mg1cMrQBzvYi/KWO

v8wBGyJ74lVR23QN2TTLxkWwwzeLOJrMLGyEqeKcnfbj0kiadzNc9iMy5dqDTOl7

3JyGtndRPuZxSTkODgEHXKhXmOvpgU5vj3PdmlQhTVVnZwR/loHEL06H/vaM42PV

VM17aP5sYO6l4DHvFNPSRb3JB09IV9QR2ylgirtsoZuSpodUo3RawkCs/J2NL/wn

zJMTJABqVkMuP5A9ENcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgKkMA8GA1UdEwEB

/wQFMAMBAf8wHQYDVR0OBBYEFBg1IR8+CF7Z2TrauD7c65p2qCe1MA0GCSqGSIb3

DQEBCwUAA4IBAQANXvJCu1YtVN3JfI/Mlc5Ei2DeDVbZ25gAIFwSH7TvasWaRsmI

1qDp0HXfZZTdrzDP9jdMq2jgP1A1i8I5XRQ/fsrrQKj6XpcTtz2X2ZN1AdGAzEHd

zcnTKcT2UY+v24ns7boWv2OD851rV2bcf5RxaJL11XSPUH/yt0nyYlmhSIZMxW4M

MQfKoOM6e7Balp+RYPqh7wwZbCVNLzonqTIz6FiTwwsKBspC3n9WVtVrhzg6NwLT

Zs5dlEHkG+L0zx3RTxCDL1VM88qCXWwaKYEiRpP74Sn4qboWS+zhY9GvOjX43APS

aKrsLO5HxQ3Lrn8PmHDkHBMdGaBbcTHY34Nn

-----END CERTIFICATE-----

 

Events:  <none>

 

 

Name:         redis-config

Namespace:    default

Labels:       <none>

Annotations:  <none>

 

Data

====

maxmemory:

----

2mb

maxmemory-policy:

----

allkeys-lru

Events:  <none>

thor@jump_host ~$

thor@jump_host ~$ kubectl describe pods

Name:           redis-deployment-76cc9c56f-2ncqs

Namespace:      default

Priority:       0

Node:           kodekloud-control-plane/172.18.0.2

Start Time:     Wed, 08 Sep 2021 05:29:51 +0000

Labels:         app=redis

                pod-template-hash=76cc9c56f

Annotations:    <none>

Status:         Pending

IP:            

IPs:            <none>

Controlled By:  ReplicaSet/redis-deployment-76cc9c56f

Containers:

  redis-container:

    Container ID:  

    Image:          redis:alpin

    Image ID:      

    Port:           6379/TCP

    Host Port:      0/TCP

    State:          Waiting

      Reason:       ContainerCreating

    Ready:          False

    Restart Count:  0

    Requests:

      cpu:        300m

    Environment:  <none>

    Mounts:

      /redis-master from config (rw)

      /redis-master-data from data (rw)

      /var/run/secrets/kubernetes.io/serviceaccount from default-token-zlv6q (ro)

Conditions:

  Type              Status

  Initialized       True

  Ready             False

  ContainersReady   False

  PodScheduled      True

Volumes:

  data:

    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)

    Medium:    

    SizeLimit:  <unset>

  config:

    Type:      ConfigMap (a volume populated by a ConfigMap)

    Name:      redis-cofig

    Optional:  false

  default-token-zlv6q:

    Type:        Secret (a volume populated by a Secret)

    SecretName:  default-token-zlv6q

    Optional:    false

QoS Class:       Burstable

Node-Selectors:  <none>

Tolerations:     node.kubernetes.io/not-ready:NoExecute op=Exists for 300s

                 node.kubernetes.io/unreachable:NoExecute op=Exists for 300s

Events:

  Type     Reason       Age                  From               Message

  ----     ------       ----                 ----               -------

  Normal   Scheduled    3m24s                default-scheduler  Successfully assigned default/redis-deployment-76cc9c56f-2ncqs to kodekloud-control-plane

  Warning  FailedMount  80s                  kubelet            Unable to attach or mount volumes: unmounted volumes=[config], unattached volumes=[config default-token-zlv6q data]: timed out waiting for the condition

  Warning  FailedMount  76s (x9 over 3m24s)  kubelet            MountVolume.SetUp failed for volume "config" : configmap "redis-cofig" not found

thor@jump_host ~$


3. Kindly refer to the below video for fixing  issues ahead 


Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this, please go through and share your comments. Like and share the knowledge


 


Post a Comment

0 Comments

Latest Posts

KodeKloud Kubernetes Security CKS  Lab Challenge 4 |  Audit-policy | Install & configure falco utility | Inspect the API server audit logs and identify the user