apiVersion: v1 kind: Pod metadata:   name: init-demo   # 命名空间   namespace: default   labels:     app: nginx spec:   # 调度约束:   # nodeName: 将Pod调度到指定的Node名称上   # nodeSelector: 将Pod调度到匹配Label的Node上   # nodeName: k8s-node1   # nodeSelector:   #   env_role: dev   containers:   - name: nginx     image: nginx     # 镜像拉去策略:IfNotPresent, Never, Always     imagePullPolicy: IfNotPresent     ports:     - containerPort: 80     env:     - name: MYSQL_ROOT_PASSWORD       value: "password"     # pod资源请求和限制     resources:       requests:       memory: "64Mi"       cpu: "250m"       limits:       memory: "128Mi"       cpu: "500m"     # 健康检查策略:     # livenessProbe: 检查失败,将杀死容器,根据Pod的restartPolicy来操作     # readinessProde: 检查失败,Kubernetes会把Pod从service endpoints中剔除     # 健康检查方法:httpGet, exec, tcpSocket     livenessProbe:       # exec:       #   command:       #   - cat        #   - /tmp/health       # tcpSocket:       #   port: 80       httpGet:         # scheme: HTTP         path: /         port: 80       initialDelaySeconds: 10       periodSeconds: 20
    # 挂载目录     volumeMounts:     - name: workdir       mountPath: /usr/share/nginx/html   imagePullSecrets:     name: myregistrykey   # 重启策略:Always, Never, Onfailure   restartPolicy: Always   # These containers are run during pod initialization初始化容器,先于业务容器开始执行   initContainers:   - name: install     image: busybox     command:     - wget     - "-O"     - "/work-dir/index.html"     - http://kubernetes.io     volumeMounts:     - name: workdir       mountPath: "/work-dir"   dnsPolicy: Default # 存储 hostpath, emptydir, nfs, configmap   volumes:   - name: workdir     emptyDir: {}   - name: data     hostPath:     path: /tmp     type: Directory   - name: wwwroot     nfs:     server: 192.168.0.200     path: /data/nfs   - name: filebeat-config     configMap:     name: filebeat-config

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄