Files
my-docs/Containerization & Orchestration/Kubernetes/components/2-Pod.md
2025-06-24 20:47:06 +03:30

1.6 KiB

Pod Management

Listing Pods

  • List Pods in the Default Namespace

    kubectl get pods
    
  • List Pods with Detailed Information (Wide Output)

    kubectl get pods -o wide
    
  • List Pods in a Specific Namespace

    kubectl get pods -o wide -n <namespace-name>
    

Running a Pod

Note: The kubectl run command is best suited for running single pods. For more complex deployments, consider using YAML manifests.

kubectl run <pod-name> --image=<image-name>
kubectl run <pod-name> --image=<image-name> -n <namespace>
kubectl delete pod <pod-name> -n <namespace-name>
kubectl delete pod <pod-name> -n <namespace-name> --force
kubectl delete pod <pod-name> -n <namespace-name> --force --grace-period 0
kubectl edit pod -n <namepsace> <podname>

Pod Can not been edit (not editable)

kubectl exec -it -n <namespace> <podname> -- <command or shell>
apiVersion: v1
kind: Pod
metadata:
  namespace: dev
  name: pod-1
  labels:
    label1: test
    label2: test2
    app.kubernetes.io/label3: test3
    app.kubernetes.io/label4: test4
spec:
  containers:
    - name: nginx-server
      image: nginx
    
    - name: nginx-exporter
      image: nginx-exporter

    - name: ubuntu-c0
      image: ubuntu
      command: ["/bin/bash","-c","while true; do echo hello-world; sleep 5; done"]
      resources:
        limits:
          memory: "256Mi"
          cpu: "250m"
        requests:
          memory: "128Mi"
          cpu: "125m"
  nodeSelector:
    hostname: k3s
    app.kubernetes.io/disk: ssd