• kubernetes如何快速编写yaml文件


    有两种方式

    1、使用kubectl create命令生成yaml

    [root@test yaml]# kubectl create deployment my-dep --image=nginx -o yaml --dry-run >web.yaml
    W1214 12:23:36.642511    6822 helpers.go:553] --dry-run is deprecated and can be replaced with --dry-run=client.
    [root@mvpemen-game--test yaml]# cat web.yaml 
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      creationTimestamp: null
      labels:
        app: my-dep
      name: my-dep
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: my-dep
      strategy: {}
      template:
        metadata:
          creationTimestamp: null
          labels:
            app: my-dep
        spec:
          containers:
          - image: nginx
            name: nginx
            resources: {}
    status: {}

    2、将部署好的医院使用kubectl get命令导出yaml文件

    [root@test yaml]# kubectl get deployment my-dep -o yaml  >my2.yaml
    [root@test yaml]# cat my2.yaml 
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      annotations:
        deployment.kubernetes.io/revision: "1"
        kubectl.kubernetes.io/last-applied-configuration: |
          {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"creationTimestamp":null,"labels":{"app":"my-dep"},"name":"my-dep","namespace":"default"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"my-dep"}},"strategy":{},"template":{"metadata":{"creationTimestamp":null,"labels":{"app":"my-dep"}},"spec":{"containers":[{"image":"nginx","name":"nginx","resources":{}}]}}},"status":{}}
      creationTimestamp: "2020-12-14T04:36:31Z"
      generation: 1
      labels:
        app: my-dep
      managedFields:
      - apiVersion: apps/v1
        fieldsType: FieldsV1
        fieldsV1:
          f:metadata:
            f:annotations:
              .: {}
              f:kubectl.kubernetes.io/last-applied-configuration: {}
            f:labels:
              .: {}
              f:app: {}
          f:spec:
            f:progressDeadlineSeconds: {}
            f:replicas: {}
            f:revisionHistoryLimit: {}
            f:selector:
              f:matchLabels:
                .: {}
                f:app: {}
            f:strategy:
              f:rollingUpdate:
                .: {}
                f:maxSurge: {}
                f:maxUnavailable: {}
              f:type: {}
            f:template:
              f:metadata:
                f:labels:
                  .: {}
                  f:app: {}
              f:spec:
                f:containers:
                  k:{"name":"nginx"}:
                    .: {}
                    f:image: {}
                    f:imagePullPolicy: {}
                    f:name: {}
                    f:resources: {}
                    f:terminationMessagePath: {}
                    f:terminationMessagePolicy: {}
                f:dnsPolicy: {}
                f:restartPolicy: {}
                f:schedulerName: {}
                f:securityContext: {}
                f:terminationGracePeriodSeconds: {}
        manager: kubectl-client-side-apply
        operation: Update
        time: "2020-12-14T04:36:31Z"
      - apiVersion: apps/v1
        fieldsType: FieldsV1
        fieldsV1:
          f:metadata:
            f:annotations:
              f:deployment.kubernetes.io/revision: {}
          f:status:
            f:availableReplicas: {}
            f:conditions:
              .: {}
              k:{"type":"Available"}:
                .: {}
                f:lastTransitionTime: {}
                f:lastUpdateTime: {}
                f:message: {}
                f:reason: {}
                f:status: {}
                f:type: {}
              k:{"type":"Progressing"}:
                .: {}
                f:lastTransitionTime: {}
                f:lastUpdateTime: {}
                f:message: {}
                f:reason: {}
                f:status: {}
                f:type: {}
            f:observedGeneration: {}
            f:readyReplicas: {}
            f:replicas: {}
            f:updatedReplicas: {}
        manager: kube-controller-manager
        operation: Update
        time: "2020-12-14T04:36:37Z"
      name: my-dep
      namespace: default
      resourceVersion: "1046241"
      selfLink: /apis/apps/v1/namespaces/default/deployments/my-dep
      uid: e5b3b504-8963-4e21-9605-3060cc423e45
    spec:
      progressDeadlineSeconds: 600
      replicas: 1
      revisionHistoryLimit: 10
      selector:
        matchLabels:
          app: my-dep
      strategy:
        rollingUpdate:
          maxSurge: 25%
          maxUnavailable: 25%
        type: RollingUpdate
      template:
        metadata:
          creationTimestamp: null
          labels:
            app: my-dep
        spec:
          containers:
          - image: nginx
            imagePullPolicy: Always
            name: nginx
            resources: {}
            terminationMessagePath: /dev/termination-log
            terminationMessagePolicy: File
          dnsPolicy: ClusterFirst
          restartPolicy: Always
          schedulerName: default-scheduler
          securityContext: {}
          terminationGracePeriodSeconds: 30
    status:
      availableReplicas: 1
      conditions:
      - lastTransitionTime: "2020-12-14T04:36:37Z"
        lastUpdateTime: "2020-12-14T04:36:37Z"
        message: Deployment has minimum availability.
        reason: MinimumReplicasAvailable
        status: "True"
        type: Available
      - lastTransitionTime: "2020-12-14T04:36:31Z"
        lastUpdateTime: "2020-12-14T04:36:37Z"
        message: ReplicaSet "my-dep-5b7868d854" has successfully progressed.
        reason: NewReplicaSetAvailable
        status: "True"
        type: Progressing
      observedGeneration: 1
      readyReplicas: 1
      replicas: 1
      updatedReplicas: 1
  • 相关阅读:
    检测对象类型的两种方式,constructor属性和instanceof
    Javascript中的事件
    工厂模式、寄生构造函数模式、稳妥构造函数模式比较
    ECMAScript中的原型继承
    Javascript中new的作用
    js组合继承
    【原型模式】--重写原型对象prototype的影响
    动态原型模式
    js类型检测
    Javascript中的继承与复用
  • 原文地址:https://www.cnblogs.com/fat-girl-spring/p/14132618.html
Copyright © 2020-2023  润新知