系統 - K3s - 建立、刪除Pod



參考資訊:
https://docs.k3s.io/installation/uninstall
https://kubernetes.io/zh-cn/docs/tasks/run-application/run-stateless-application-deployment/

main.yaml

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

建立Pod

$ kubectl create -f main.yaml 
    deployment.apps/nginx-deployment created

$ kubectl get pod
    NAME                                READY   STATUS    RESTARTS   AGE
    nginx-deployment-848dd6cfb5-tjr95   1/1     Running   0          19s

執行Pod

$ kubectl exec -it nginx-deployment-848dd6cfb5-tjr95 -- /bin/bash

root@nginx-deployment-848dd6cfb5-tjr95:/#

刪除Pod

$ kubectl get deployment
    NAME               READY   UP-TO-DATE   AVAILABLE   AGE
    nginx-deployment   1/1     1            1           4s

$ kubectl delete deployment nginx-deployment
    deployment.apps "nginx-deployment" deleted

$ kubectl get pod
    No resources found in default namespace.