- 脚本
使用yaml,注意requests中的auth
import requests
import yaml
f = open('2048.yaml')
y = yaml.load(f)
yYaml = yaml.dump(y)
url = 'http://192.168.123.170/apis/extensions/v1beta1/namespaces/default/deployments'
head = {'Content-Type' : 'application/yaml'}
r = requests.post(url,data=yYaml,headers=head,auth=('admin','admin'))
print(r.text)
2.yaml文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: abc-2048
labels:
app: abc-2048
spec:
template:
metadata:
name: abc-2048
labels:
app: abc-2048
spec:
containers:
- name: abc-2048
image: daocloud.io/daocloud/dao-2048:latest
ports:
- containerPort: 80
网友评论