网站首页 文章专栏 02deployment.md
02deployment.md
创建于:2021-07-04 07:52:34 更新于:2024-11-21 12:46:25 羽瀚尘 430

主要介绍如何使用rest api调度deployment资源。

获取单个deployment信息

GET /apis/apps/v1/namespaces/{namespace}/deployments/{name}

获取某个命名空间的deployment信息

GET /apis/apps/v1/namespaces/{namespace}/deployments

获取所有命名空间的deployment信息

GET /apis/apps/v1/deployments

新建一个deployment

POST /apis/apps/v1/namespaces/{namespace}/deployments

修改一个已有的deployment

PATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}

替换一个已有的deployment

PUT /apis/apps/v1/namespaces/{namespace}/deployments/{name}

删除一个deployment

DELETE /apis/apps/v1/namespaces/{namespace}/deployments/{name}

删除指定命名空间的所有deployment

DELETE /apis/apps/v1/namespaces/{namespace}/deployments

create deployments

curl -X POST -H 'Content-Type: application/yaml' --data '
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tensorflow
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tensorflow
  template:
    metadata:
      name: tensorflow
      labels:
        app: tensorflow
    spec:
      containers:
      - name: tensorflow
        imagePullPolicy: IfNotPresent
        image: tensorflow1_18:v2
        ports:
        - containerPort: 6081
          nodePort: 6081
        resources:
          limits:
            cpu: 10m
            memory: 4096Mi
          requests:
            cpu: 10m
            memory: 4096Mi
' -u admin:admin https://192.168.25.180:6443/apis/apps/v1/namespaces/default/deployments -k

delete deployment

curl -X DELETE -H 'Content-Type: application/yaml' --data '
gracePeriodSeconds: 0
orphanDependents: false
' 'http://127.0.0.1:8001/apis/apps/v1/namespaces/default/deployments/deployment-example'

参考:

TODO

  • 增加其他api接口