k8s kubernetes常用deploy模板 并验证

kubernetes常用deploy模板,并验证

k8s kubernetes常用deploy模板 并验证

文章插图
【k8s kubernetes常用deploy模板 并验证】 
编写deploy配置文件root@hello:~# cat deploy.yaml apiVersion: Apps/v1kind: Deploymentmetadata:   name: hostname-test-cby  labels:    name: hostname-test-cbyspec:  # 副本数  replicas: 10  # 标签选择器  selector:    matchLabels:      name: hostname-test-cby  # 更新策略  strategy:    rollingUpdate:      maxSurge: 3    # 更新最大数量      maxUnavailable: 3    #更新时最大不可用数量    type: RollingUpdate  #滚动更新  # 模板  template:    metadata:      labels:        name: hostname-test-cby    spec:      # 配置容器      containers:      - name: hostname-test-cby #容器名        image: Nginx #镜像        imagePullPolicy: IfNotPresent # 拉取策略        resources:          requests:            cpu: "100m" #CPU限制            memory: "300M" #内存限制        # 健康监测        livenessProbe:          httpGet:            path: / # 探测路径            port: 80 # 端口          initialDelaySeconds: 15 # 第一次探测等待          timeoutSeconds: 3 # 探测的超时后等待多少秒        # 就绪探测        readinessProbe:          httpGet:            path: / # 探测路径            port: 80 # 端口          initialDelaySeconds: 10 # 第一次探测等待          timeoutSeconds: 3 # 探测的超时后等待多少秒        #环境变量        env:        - name: cby          value: chenby        # 配置容器端口        ports:        - containerPort: 80        # 配置挂载到目录        volumeMounts:        - mountPath: /usr/share/nginx/html/          name: data      # 配置目录挂载      volumes:      - name: data        hostPath:          path: /html/          type: Directory      # 配置指定解析      hostAliases:      - ip: "192.168.1.1" #IP地址        hostnames:        - "cby" #主机名        - "cby.chenby.cn" #主机名      - ip: "192.168.1.10"#IP地址        hostnames:        - "chenby" #主机名        - "chenby.chenby.cn" #主机名root@hello:~# 


推荐阅读