码迷,mamicode.com
首页 > Windows程序 > 详细

k8s-api

时间:2018-01-15 20:19:45      阅读:862      评论:0      收藏:0      [点我收藏+]

标签:nginx   dump   ade   pre   post   request   app   pac   enc   

使用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

标签:nginx   dump   ade   pre   post   request   app   pac   enc   

原文地址:https://www.cnblogs.com/peterinblog/p/8289177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!