開發與維運

K8S deployment的yml部署

kubernetes1.5版本deployment部署的apiVersion為extensions/v1beta1 ,yml腳本如下:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test-service-deploy
labels:

app: nginx

spec:
replicas: 2
selector:

matchLabels:
  app: nginx

template:

metadata:
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80
    1.6.0版本中的apiVersion寫法為apps/v1beta1

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: test-service-deploy
labels:

app: nginx

spec:
replicas: 2
selector:

matchLabels:
  app: nginx

template:

metadata:
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:latest
    ports:
    - containerPort: 80
  目前官網的apiVersion:為apps/v1,yml腳本如下:

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:

app: nginx

spec:
replicas: 3
selector:

matchLabels:
  app: nginx

template:

metadata:
  labels:
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:1.14.2
    ports:
    - containerPort: 80

apiVersion內容不對會導致創建時報錯,無法正常創建。

Leave a Reply

Your email address will not be published. Required fields are marked *