kind: Deployment apiVersion: apps/v1 # 元数据 metadata: name: advertisement-medium namespace: advertisement labels: app: advertisement-medium annotations: kubesphere.io/creator: dengbiao kubesphere.io/description: advertisement-medium # deployment主要部分 spec: replicas: 1 selector: matchLabels: # 名称与上面的labels对应 app: advertisement-medium template: metadata: labels: # 名称与上面的matchLabels对应 app: advertisement-medium spec: # 声明挂载卷(将外部已存在的pvc、config等挂载进来) volumes: # 用于时区校正 - name: host-time hostPath: path: /etc/localtime type: '' # 将前面创建的configMap也挂载进来 - name: advertisement-medium-cfg configMap: # 这里的名字就是前面创建的configMap的名字 name: advertisement-medium-cfg defaultMode: 420 containers: # 主容器 - name: advertisement-medium-container # 镜像地址(提前打包好并推送的镜像仓库) image: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/advertisement-medium:0.0.1' ports: - name: advertisement-tcp-1004 # 容器端口号(注意与golang web server启动的端口一致) containerPort: 1004 protocol: TCP # 将前面volume声明的需要用到的pvc、config挂载上来 volumeMounts: - name: host-time readOnly: true mountPath: /etc/localtime - name: advertisement-medium-cfg # 该名字对应前面volumes声明的名字 readOnly: true # 挂载到容器的哪个路径 mountPath: /var/zyos imagePullPolicy: Always # Nginx 容器 - name: 'registry.cn-shenzhen.aliyuncs.com/fnuoos-prd/nginx:latest' image: nginx ports: - name: http-80 containerPort: 80 protocol: TCP volumeMounts: # 时区校正 - name: host-time readOnly: true mountPath: /etc/localtime # 存储卷 用于存放前端代码 - name: advertisement-medium-pvc # 前面volumes声明的名称 mountPath: /usr/share/nginx/html - name: advertisement-medium-nginx # Nginx 配置 readOnly: true mountPath: /etc/nginx/conf.d/default.conf subPath: default.conf restartPolicy: Always terminationGracePeriodSeconds: 30 dnsPolicy: ClusterFirst