创建pod

curl -X POST -H "Content-Type: application/json"  -d '{
    "apiVersion": "v1",
    "kind": "Pod",
    "metadata": {
        "name": "busybox-3",
        "namespace":"default",
        "labels": {
            "app": "busybox-3"
        }
    },
    "spec": {
        "containers": [{
            "name":"busybox-3",
            "image": "registry.cn-beijing.aliyuncs.com/kevin-public/busybox:1.0.0",
            "command": ["top"],
            "ports": [{
                "containerPort": 80,
                "name": "http",
                "protocol": "TCP"
            }]
        }]
   }
}' "http://localhost:8023/api/v1/namespaces/default/pods"

创建deployment

curl -X POST -H "Content-Type: application/json" -H "Cache-Control: no-cache" -H "Postman-Token: cc3e1fb5-ecd4-e5d9-bdf6-eeaf9d08150b" -d '{
    "apiVersion": "apps/v1",
    "kind": "Deployment",
    "metadata": {
        "name": "busybox-3",
        "labels": {
            "app": "busybox-3"
        }
    },
    "spec": {
        "replicas": 1,
        "selector": {
            "matchLabels": {
                "app": "busybox-3"
            }
        },
        "template": {
            "metadata": {
                "labels":{
                    "app": "busybox-3"
                }
            },
            "spec": {
                "containers": [{
                    "name":"c1",
                    "image": "registry.cn-beijing.aliyuncs.com/kevin-public/busybox:1.0.0",
                    "command": ["top"],
                    "ports": [{
                        "containerPort": 80,
                        "name": "http",
                        "protocol": "TCP"
                    }]
                }]
            }
        }
    }
}' "http://localhost:8023/apis/apps/v1/namespaces/default/deployments"

创建service

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

附:
go通过kubeconfig调用api接口:https://k8smeetup.github.io/docs/tasks/administer-cluster/access-cluster-api/#go-客户端

k8s api文档