运行测试 pod

配置文件

  1. $ cat nginx.yaml
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: nginx-deployment
  6. labels:
  7. app: nginx
  8. spec:
  9. replicas: 3
  10. selector:
  11. matchLabels:
  12. app: nginx
  13. template:
  14. metadata:
  15. labels:
  16. app: nginx
  17. spec:
  18. containers:
  19. - name: nginx
  20. image: nginx:1.14.2
  21. ports:
  22. - containerPort: 80

启动 pod

通过kubectl命令运行nginx。

  1. $ kubectl apply -f nginx.yaml
  2. deployment.apps/nginx-deployment created
  3. $ kubectl get pods
  4. NAME READY STATUS RESTARTS AGE
  5. nginx-deployment-66b6c48dd5-6rnwz 1/1 Running 0 33s
  6. nginx-deployment-66b6c48dd5-9pq49 1/1 Running 0 33s
  7. nginx-deployment-66b6c48dd5-lvmng 1/1 Running 0 34s