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
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/55414.html
標籤:其他
下一篇:Kubernetes 環境搭建
