Kubernetes Pod 资源
Pod资源,具体概念请阅读官方文档:https://kubernetes.io/zh-cn/docs/concepts/workloads/pods/
使用Pod
1 2 3 4 5 6 7 8 9 10
| apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80
|
1 2 3 4 5 6 7 8 9 10 11
| apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80
|
1 2 3 4 5 6
| kubectl create -f pod.yaml
kubectl apply -f pod.yaml
|
Pod 模板
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| apiVersion: batch/v1 kind: Job metadata: name: hello spec: template: spec: containers: - name: hello image: busybox:1.28 command: ['sh', '-c', 'echo "Hello, Kubernetes!" && sleep 3600'] restartPolicy: OnFailure
|
查看运行的Pod

1 2 3 4 5 6
| Name READY STATUS RESTARTS AGE
|
STATUS 状态具体说明Kubernetes Pod的生命周期
查看指定Pod的详细信息
1 2
| kubectl describe pod nginx
|
describe 详细信息说明Kubectl describe 参数解释
删除指定Pod
1 2
| kubectl delete pod nginx
|
删除指定资源清单的所有Pod
1 2
| kubectl delete -f pod.yaml
|
删除所有资源清单的所有Pod(当前目录)
查看Pod内容器的日志
1 2
| kubectl logs -f nginx -c nginx-2
|
进入容器命令
1 2
| kubectl exec -it nginx -c nginx-2 -- /bin/bash
|