zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    [转载]网络流ISAP算法的简单介绍
    [漫画]120430 混血男孩
    [代码]SGU 270 Thimbles
    [代码]UVALive 5882 Racing Car Trail
    [代码]SGU 298 King Berl VI
    [解题报告]Codeforces 105D Entertaining Geodetics
    07年的第一个小时
    简单工厂模式
    讨厌什么
    休息像神的味道
  • 原文地址:https://www.cnblogs.com/fat-girl-spring/p/14132618.html
Copyright © 2011-2022 走看看