网站首页 文章专栏 03service.md
03service.md
创建于:2021-07-04 07:52:40 更新于:2024-05-06 13:28:58 羽瀚尘 318

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

获取单个service

GET /api/v1/namespaces/{namespace}/services/{name}

获取指定命名空间所有service

GET /api/v1/namespaces/{namespace}/services

获取所有命名空间service

GET /api/v1/services

创建一个service

POST /api/v1/namespaces/{namespace}/services

修改一个service

PATCH /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

替换一个service

PUT /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

删除一个service

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies/{name}

删除指定命名空间所有service

DELETE /apis/networking.k8s.io/v1/namespaces/{namespace}/networkpolicies

create service

curl -X POST -H 'Content-Type: application/yaml' --data '
kind: Service
apiVersion: v1
metadata:
  name: service-example
spec:
  ports:
    - name: http
      port: 80
      targetPort: 80
  selector:
      app: nginx
  type: LoadBalancer
' http://127.0.0.1:8001/api/v1/namespaces/default/services

delete service

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

参考:

TODO

  • 增加其他api接口