YAML文件經常使用指令html
配置文件說明:node
YAML文件格式注意事項:nginx
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3
kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.9 ports: - containerPort: 80
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.9 ports: - containerPort: 80
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.9 ports: - containerPort: 80
apiVersion: apps/v1beta2 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.9 ports: - containerPort: 80
apiVersion: v1 kind: Pod metadata: name: pod-test labels: os: centos spec: containers: - name: hello image: centos:6 env: # 變量key - name: Test # 變量value value: "123456"
apiVersion: v1 kind: Pod metadata: name: pod-test labels: os: centos spec: containers: - name: hello image: centos:6 command: ["bash","-c","while true;do date;sleep 1;done"]
apiVersion: v1 kind: Pod metadata: name: pod-test labels: os: centos spec: containers: - name: hello image: centos:6 restartPolicy: OnFailure
apiVersion: v1 kind: Pod metadata: name: nginx-pod labels: app: nginx spec: containers: - name: nginx image: nginx:1.10 ports: - containerPort: 80 livenessProbe: # 健康檢查模式 httpGet: # 指定檢查目錄 path: /index.html # 訪問端口 port: 80
apiVersion: v1 kind: Pod metadata: name: pod-test labels: test: centos spec: containers: - name: hello-read image: centos:6 # 容器內管理數據卷 volumeMounts: # 數據卷名稱 - name: data # 容器數據卷路徑 mountPath: /data # 數據卷 volumes: # 數據卷名稱 - name: data # 數據宿主機卷路徑 hostPath: # 指定宿主機數據卷路徑 path: /data
apiVersion: v1 kind: Pod metadata: name: pod-test labels: test: centos spec: containers: - name: hello-read image: centos:6 # 容器內管理數據卷 volumeMounts: # 數據卷名稱 - name: data # 容器數據卷路徑 mountPath: /data # 數據卷 volumes: # 數據卷名稱 - name: data # 數據宿主機卷路徑 hostPath: # 指定宿主機數據卷路徑 path: /data
apiVersion: v1 kind: Pod metadata: name: nginx-pod2 labels: app: nginx spec: containers: - name: nginx image: nginx:1.10 # hostport管理 ports: # 指定http - name: http # 指定端口 containerPort: 80 # hsotip監聽IP,可經過哪些宿主級ip訪問 hostIP: 0.0.0.0 # 宿主級暴露端口,它會映射到containerport的容器端口 hostPort: 89 # 指定協議類型 protocol: TCP
apiVersion: v1 kind: Pod metadata: name: nginx-pod2 labels: app: nginx spec: containers: - name: nginx image: nginx:1.10 # hostport管理 ports: # 指定http - name: http # 指定端口 containerPort: 80 # hsotip監聽IP,可經過哪些宿主級ip訪問 hostIP: 0.0.0.0 # 宿主級暴露端口,它會映射到containerport的容器端口 hostPort: 89 # 指定協議類型 protocol: TCP
apiVersion: v1 kind: Pod metadata: name: nginx-pod2 labels: app: nginx spec: containers: - name: nginx image: nginx:1.10 # hostport管理 ports: # 指定http - name: http # 指定端口 containerPort: 80 # hsotip監聽IP,可經過哪些宿主級ip訪問 hostIP: 0.0.0.0 # 宿主級暴露端口,它會映射到containerport的容器端口 hostPort: 89 # 指定協議類型 protocol: TCP
apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx ports: - name: http protocol: TCP port: 888 targetPort: 80 clusterIP: "10.10.10.11"
apiVersion: v1 kind: Service metadata: name: nginx-service2 labels: app: nginx spec: selector: app: nginx ports: - name: http port: 8080 targetPort: 80 # 服務類型 type: NodePort
apiVersion: v1 kind: Service metadata: name: nginx-service2 labels: app: nginx spec: selector: app: nginx ports: - name: http port: 8080 targetPort: 80 # 服務類型 type: NodePort