直接命令运行

kubectl run testapp --image=ccr.ccs.tencentyun.com/k8s-tutorial/test-k8s:v1

Pod

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: test-pod
  5. spec: # 定义容器,可以多个
  6. containers:
  7. - name: test-k8s # 容器名字
  8. image: ccr.ccs.tencentyun.com/k8s-tutorial/test-k8s:v1 # 镜像

Deployment

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. # 部署名字
  5. name: test-k8s
  6. spec:
  7. replicas: 2
  8. # 用来查找关联的 Pod,所有标签都匹配才行
  9. selector:
  10. matchLabels:
  11. app: test-k8s
  12. # 定义 Pod 相关数据
  13. template:
  14. metadata:
  15. labels:
  16. app: test-k8s
  17. spec:
  18. # 定义容器,可以多个
  19. containers:
  20. - name: test-k8s # 容器名字
  21. image: ccr.ccs.tencentyun.com/k8s-tutorial/test-k8s:v1 # 镜像

image.png