![Kubernetes权威指南:从Docker到Kubernetes实践全接触(第4版)](https://wfqqreader-1252317822.image.myqcloud.com/cover/916/26297916/b_26297916.jpg)
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
3.1 Pod定义详解
YAML格式的Pod定义文件的完整内容如下:
apiVersion: v1 kind: Pod metadata: name: string namespace: string labels: - name: string annotations: - name: string spec: containers: - name: string image: string imagePullPolicy: [Always | Never | IfNotPresent] command: [string] args: [string] workingDir: string volumeMounts: - name: string mountPath: string readOnly: boolean ports: - name: string containerPort: int hostPort: int protocol: string env: - name: string value: string resources: limits: cpu: string memory: string requests: cpu: string memory: string livenessProbe: exec: command: [string] httpGet: path: string port: number host: string scheme: string httpHeaders: - name: string value: string tcpSocket: port: number initialDelaySeconds: 0 timeoutSeconds: 0 periodSeconds: 0 successThreshold: 0 failureThreshold: 0 securityContext: privileged: false restartPolicy: [Always | Never | OnFailure] nodeSelector: object imagePullSecrets: - name: string hostNetwork: false volumes: - name: string emptyDir: {} hostPath: path: string secret: secretName: string items: - key: string path: string configMap: name: string items: - key: string path: string
对各属性的详细说明如表3.1所示。
表3.1 对Pod定义文件模板中各属性的详细说明
![](https://epubservercos.yuewen.com/1A2BFC/14737439704468706/epubprivate/OEBPS/Images/Figure-0172-0091.jpg?sign=1739486850-rLfIgDiGvsOVrdiTzLofzGAVmsNZwnPF-0-a148af629e17a18c8381b54e7168a717)
续表
![](https://epubservercos.yuewen.com/1A2BFC/14737439704468706/epubprivate/OEBPS/Images/Figure-0173-0092.jpg?sign=1739486850-WrkFkpRZ0Mt6VCZZXTDBmJCN8kuQPezG-0-6d00c6f55b77ef2e1bf01272c11913fe)
续表
![](https://epubservercos.yuewen.com/1A2BFC/14737439704468706/epubprivate/OEBPS/Images/Figure-0174-0093.jpg?sign=1739486850-MVB5U0a7OPWSE5ufA7XnGAx4XtcL6HzX-0-f8a82cb5e4e4de9caaf2f2cec1784526)
续表
![](https://epubservercos.yuewen.com/1A2BFC/14737439704468706/epubprivate/OEBPS/Images/Figure-0175-0094.jpg?sign=1739486850-oACBIV90cv6tZY5w5kG9JrO6tHRaPKOx-0-b46f050b9ff5808c6ededc7ecca5e342)