Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 935 Bytes

use_deployment.md

File metadata and controls

40 lines (34 loc) · 935 Bytes

使用Deployment部署

Depoy在K8S之中包含描述container內容以及replica數量等資訊,下面是一份deployment的範本,描述使用simpleweb這個image建置一個replica為1的服務,並開通container port為80...

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: myweb
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: myweb
        tier: myweb
    spec:
      containers:
      - name: myweb
        image: peihsinsu/simpleweb
        ports:
        - containerPort: 80 
        env:
        - name: PORT 
          value: "80"
        - name: NODE_ENV
          value: production
        - name: GET_HOSTS_FROM
          value: dns

我們將文件儲存為deploy.yaml,則部署上只要透過下面即可部署:

kubectl create -f deploy.yaml

參考