1. 程式人生 > 實用技巧 >k8s pod 定義 檔案 yaml

k8s pod 定義 檔案 yaml

# yaml格式的pod定義檔案完整內容:
apiVersion: v1       #必選,版本號,例如v1
kind: Pod       #必選,Pod
metadata:       #必選,元資料
  name: intellect1       #必選,Pod名稱
  namespace: app #必選,Pod所屬的名稱空間
  labels:      #自定義標籤
    - name: intellect1       #自定義標籤名字
  annotations:       #自定義註釋列表
    - name: intellect1  
spec:         #必選,Pod中容器的詳細定義
  containers:      #必選,Pod中容器列表
  - name: intellect1     #必選,容器名稱
    image: 192.168.190.126:5000/app/intellect:latest    #必選,容器的映象名稱
    imagePullPolicy: Always    
    ports:       #需要暴露的埠庫號列表
    - name: P3000     #埠號名稱
      containerPort: 3000   #容器需要監聽的埠號
      hostPort: 31300    #容器所在主機需要監聽的埠號,預設與Container相同
      protocol: TCP     #埠協議,支援TCP和UDP,預設TCP