• 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
  • 相关阅读:
    NC学习笔记
    NC开发笔记指导
    进度条Demo
    指点
    NC二次开发常用的方法
    java PDF2JPG
    IO笔记
    java Utils
    Lambda 笔记
    gradle记录
  • 原文地址:https://www.cnblogs.com/peterinblog/p/8289177.html
Copyright © 2020-2023  润新知