• Home
  • Azure
  • OpenShift
  • Kubernetes
  • Docker
  • Security
  • Database
  • Programming
  • Linux
  • Artificial Intelligence
  • Contact
  • More
    • Home
    • Azure
    • OpenShift
    • Kubernetes
    • Docker
    • Security
    • Database
    • Programming
    • Linux
    • Artificial Intelligence
    • Contact
  • Home
  • Azure
  • OpenShift
  • Kubernetes
  • Docker
  • Security
  • Database
  • Programming
  • Linux
  • Artificial Intelligence
  • Contact

Disclaimer

The links provided on this website are for informational purposes only. I do not necessarily agree with, endorse, or take responsibility for the content, views, or accuracy of any external websites linked here. Use them at your own discretion.

CHEAT SHEET

Getting started

List all pods in ps output format with more information (such as node name) 

    kubectl get pods -o wide

Describe all pods

    kubectl describe pods --all-namespaces

List deployments for all namespaces

    kubectl get deployment --all-namespaces

List service for a specific namespace

    kubectl get svc -n <namespace>

List all nodes

    kubectl get nods

Describe a node

    kubectl describe node <node_name>

Implement changed with a yaml file

kubectl apply -f  deployment.yml

Troubleshooting

Getting logs from a specific container

    kubectl logs <container_name> -n <namespace>

Open interactive shell for a running container

    kubectl exec -it <container_name> -n <namespace> -- /bin/sh

Restart deployment

    kubectl rollout restart deployment/<deployment_name> -n <namespace>

Kubernetes Official Documents

More commands can be found here

    https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands

Example of deployment yaml file

apiVersion: apps/v1

kind: Deployment

metadata:

  name: my-container-app

  labels:

    app: my-container-app

spec:

  replicas: 2

  selector:

    matchLabels:

      app: my-container-app

  template:

    metadata:

      labels:

        app: my-container-app

    spec:

      containers:

        - name: myapp

          image: mcr.microsoft.com/azuredocs/containerapps-helloworld:latest

          ports:

            - containerPort: 80

          resources:

            requests:

              cpu: "0.5"

              memory: "1Gi"

            limits:

              cpu: "1"

              memory: "2Gi"

---

apiVersion: v1

kind: Service

metadata:

  name: my-container-app-service

spec:

  selector:

    app: my-container-app

  ports:

    - protocol: TCP

      port: 80

      targetPort: 80

  type: LoadBalancer


Copyright © 2025 zuliangwu.com - All Rights Reserved.

Powered by

This website uses cookies.

We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.

Accept