标签:size 指定容器名称 replicas 管理 running current select col available
Docker Kubernetes YAML文件创建容器
通过创建Deployment来管理pods从而创建容器。它会同时创建容器、pod、以及Deployment !
环境:
创建yaml文件
vim nginx-deployment.yaml
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.9 ports: - containerPort: 80
# 指定api版本 apiVersion: apps/v1beta2 # 指定需要创建的资源对象 kind: Deployment # 源数据、可以写name,命名空间,对象标签 metadata: # 指定创建对象名称 name: nginx-deployment # spec 描述pod相关信息 spec: # pod 副本数,默认1 replicas: 3 # pod 标签选择器 selector: # pod 匹配标签字段 matchLabels: # pod 匹配app值为nginx app: nginx # 容器 描述pod具体信息 template: # 容器 指定标签 metadata: # 容器 匹配标签字段 labels: # 容器 匹配值aap值为nginx app: nginx # 容器信描述信息 spec: # 指定容器信息 containers: # 指定容器名称 - name: nginx # 指定镜像名称 image: nginx:1.10 # 暴露容器端口 ports: # 指定暴露容器端口 - containerPort: 80
创建deployment资源
kubectl create -f nginx-deployment.yaml
命令:kubectl get deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE nginx-deployment 3 3 3 3 1m
命令:kubectl get replicaset
NAME DESIRED CURRENT READY AGE
nginx-deployment-845cfc7fb9 3 3 3 4m
命令:kubectl get pods NAME READY STATUS RESTARTS AGE nginx-deployment-845cfc7fb9-j2xcv 1/1 Running 0 5m nginx-deployment-845cfc7fb9-jfq5b 1/1 Running 0 5m nginx-deployment-845cfc7fb9-sbrsp 1/1 Running 0 5m
Docker Kubernetes 创建管理 Deployment
标签:size 指定容器名称 replicas 管理 running current select col available
原文地址:https://www.cnblogs.com/xiangsikai/p/10011207.html