Kubernetes Describe Command

KubernetesKubernetesBeginner
Practice Now

Introduction

The Kubernetes describe command is a powerful tool for viewing detailed information about Kubernetes resources. With the describe command, you can view information such as resource status, events, labels, annotations, and more. This can be useful for troubleshooting issues in your Kubernetes cluster.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL kubernetes(("`Kubernetes`")) -.-> kubernetes/TroubleshootingandDebuggingCommandsGroup(["`Troubleshooting and Debugging Commands`"]) kubernetes(("`Kubernetes`")) -.-> kubernetes/AdvancedCommandsGroup(["`Advanced Commands`"]) kubernetes/TroubleshootingandDebuggingCommandsGroup -.-> kubernetes/describe("`Describe`") kubernetes/AdvancedCommandsGroup -.-> kubernetes/apply("`Apply`") subgraph Lab Skills kubernetes/describe -.-> lab-8101{{"`Kubernetes Describe Command`"}} kubernetes/apply -.-> lab-8101{{"`Kubernetes Describe Command`"}} end

Describe a Pod

In this step, you will learn how to use the describe command to view information about a Kubernetes Pod.

  1. Create a simple pod that will be used as the template for the replicas. Create a file called myapp-pod.yaml with the following contents:

    apiVersion: v1
    kind: Pod
    metadata:
      name: myapp-pod
    spec:
      containers:
        - name: myapp-container
          image: nginx
          ports:
            - containerPort: 80

    Create the pod using the following command:

    kubectl apply -f myapp-pod.yaml
  2. Then describe the pod:

    kubectl describe pod myapp-pod

This command will retrieve detailed information about the specified Pod, including status, labels, annotations, events, and more.

Describe a Deployment

In this step, you will learn how to use the describe command to view information about a Kubernetes Deployment.

  1. Create a file called myapp-deployment.yaml with the following content:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: myapp-deployment
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: myapp-deployment
      template:
        metadata:
          labels:
            app: myapp-deployment
        spec:
          containers:
            - name: myapp-container
              image: nginx:latest
              ports:
                - containerPort: 80

    Create the deployment using the following command:

    kubectl apply -f myapp-deployment.yaml
  2. Describe the deployment:

    kubectl describe deployment myapp-deployment

This command will retrieve detailed information about the specified Deployment, including status, labels, annotations, events, and more.

Describe a Service

In this step, you will learn how to use the describe command to view information about a Kubernetes Service.

  1. Create a file called myapp-service.yaml with the following content:

    apiVersion: v1
    kind: Service
    metadata:
      name: myapp-service
    spec:
      selector:
        app: myapp-deployment
      ports:
        - protocol: TCP
          port: 80
          targetPort: 80

    Create the service using the following command:

    kubectl apply -f myapp-service.yaml
  2. Use the following command to describe the service:

    kubectl describe service myapp-service

This command will retrieve detailed information about the specified Service, including status, labels, annotations, events, and more.

Summary

In this lab, you learned how to use the Kubernetes describe command to view detailed information about Kubernetes resources. You learned how to describe a Pod, Deployment, and Service.

Other Kubernetes Tutorials you may like