k8s-api

Posted haha1680737

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了k8s-api相关的知识,希望对你有一定的参考价值。

使用k8s的api添加deployments

python脚本

import requests, json,yaml

f = open("nginx1.yaml")
kk = yaml.load(f)
#print(kk)
ngnixYaml = yaml.dump(kk)
#print(ngnixYaml)
Heads = { ‘Content-Type‘: ‘application/yaml‘}
address = ‘http://192.168.56.110:8080‘
api = ‘apis/extensions/v1beta1/namespaces/default/deployments‘

url = address + ‘/‘ + api
print(url)
heads = {}
req = requests.post(url,data=ngnixYaml,headers=Heads)
#req.encoding = "utf-8"
print(req.text)

  yaml

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: deployment-example
spec:
  replicas: 1
  revisionHistoryLimit: 10
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: daocloud.io/library/nginx
        ports:
        - containerPort: 80

 

以上是关于k8s-api的主要内容,如果未能解决你的问题,请参考以下文章

k8s遇坑:The connection to the server k8s-api.virtual.local:6443 was refused - did you specify the righ

微信小程序代码片段

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板