Kubernetes helm API 客户端文件生成和远程调用(3)

Iterator<Tiller.ListReleasesResponse> listReleasesIterator = blockingStub.listReleases(Tiller.ListReleasesRequest.newBuilder().build());
        System.out.println("================start=================");
        while (listReleasesIterator.hasNext()) {
            System.out.println(listReleasesIterator.next());
            System.out.println("---------------------------------");
        }
        System.out.println("================end=================");
       
        Tiller.GetReleaseStatusResponse releaseStatus = blockingStub.getReleaseStatus(Tiller.GetReleaseStatusRequest
                .newBuilder()
                .setName("invited-catfish").build());
        System.out.println("status:"+releaseStatus);

System.out.println("-----------------");
       
        Tiller.GetHistoryResponse history = blockingStub.getHistory(Tiller.GetHistoryRequest.newBuilder()
                .setName("invited-catfish").setMax(10).build());
        System.out.println(history);

try {
            channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

5.提出运行结果

releases {
  name: "full-meerkat"
  info {
    status {
      code: DEPLOYED
      notes: "1. Get the application URL by running these commands:\n  export POD_NAME=$(kubectl get pods --namespace default -l \"app=full-meerkat-test\" -o jsonpath=\"{.items[0].metadata.name}\")\n  echo \"Visit :8080 to use your application\"\n  kubectl port-forward $POD_NAME 8080:80\n"
    }
    first_deployed {
      seconds: 1489569670
      nanos: 350911984
    }
    last_deployed {
      seconds: 1489569670
      nanos: 350911984
    }
    Description: "Install complete"
  }
  chart {
    metadata {
      name: "test"
      version: "0.1.0"
      description: "A Helm chart for Kubernetes"
      apiVersion: "v1"
    }
    templates {
      name: "templates/NOTES.txt"
      data: "1. Get the application URL by running these commands:\n{{- if contains \"NodePort\" .Values.service.type }}\n  export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath=\"{.spec.ports[0].nodePort}\" services {{ template \"fullname\" . }})\n  export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath=\"{.items[0].status.addresses[0].address}\")\n  echo $NODE_IP:$NODE_PORT/login\n{{- else if contains \"LoadBalancer\" .Values.service.type }}\n    NOTE: It may take a few minutes for the LoadBalancer IP to be available.\n          You can watch the status of by running \'kubectl get svc -w {{ template \"fullname\" . }}\'\n  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template \"fullname\" . }} -o jsonpath=\'{.status.loadBalancer.ingress[0].ip}\')\n  echo $SERVICE_IP:{{ .Values.service.externalPort }}\n{{- else if contains \"ClusterIP\"  .Values.service.type }}\n  export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l \"app={{ template \"fullname\" . }}\" -o jsonpath=\"{.items[0].metadata.name}\")\n  echo \"Visit :8080 to use your application\"\n  kubectl port-forward $POD_NAME 8080:{{ .Values.service.externalPort }}\n{{- end }}\n"
    }
    templates {
      name: "templates/_helpers.tpl"
      data: "{{/* vim: set filetype=mustache: */}}\n{{/*\nExpand the name of the chart.\n*/}}\n{{- define \"name\" -}}\n{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix \"-\" -}}\n{{- end -}}\n\n{{/*\nCreate a default fully qualified app name.\nWe truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).\n*/}}\n{{- define \"fullname\" -}}\n{{- $name := default .Chart.Name .Values.nameOverride -}}\n{{- printf \"%s-%s\" .Release.Name $name | trunc 63 | trimSuffix \"-\" -}}\n{{- end -}}\n"
    }
    templates {
      name: "templates/configMap.yaml"
      data: "apiVersion: v1\r\nkind: ConfigMap\r\nmetadata:\r\n  name: {{ template \"fullname\" . }}-cfgmap\r\n  # annotations:\r\n  #    # This is what defines this resource as a hook. Without this line, the\r\n  #    # job is considered part of the release.\r\n  #  \"helm.sh/hook\": pre-install\r\ndata:\r\n  dessert: {{ .Values.dessert }}\r\n  test: {{ .Release.Revision }}-{{ .Release.IsUpgrade }}-{{ .Release.IsInstall }}\r\n"
    }
    templates {
      name: "templates/deployment.yaml"
      data: "apiVersion: extensions/v1beta1\nkind: Deployment\nmetadata:\n  name: {{ template \"fullname\" . }}\n  labels:\n    chart: \"{{ .Chart.Name }}-{{ .Chart.Version }}\"\nspec:\n  replicas: {{ .Values.replicaCount }}\n  template:\n    metadata:\n      labels:\n        app: {{ template \"fullname\" . }}\n      annotations:\n        pod.beta.kubernetes.io/init-containers: \'[\n              {\n                  \"name\": \"remove-lost-found\",\n                  \"image\": \"busybox:1.25.0\",\n                  \"command\": [\"rm\", \"-fr\", \"/var/lib/MySQL/lost+found\"],\n                  \"volumeMounts\": [\n                      {\n                          \"name\": \"data\",\n                          \"mountPath\": \"/var/lib/mysql\"\n                      }\n                  ],\n                  \"imagePullPolicy\": {{ .Values.imagePullPolicy | quote }}\n              }\n          ]\'\n    spec:\n      containers:\n      - name: {{ .Chart.Name }}\n        image: \"{{ .Values.image.repository }}:{{ .Values.image.tag }}\"\n        imagePullPolicy: {{ .Values.image.pullPolicy }}\n        ports:\n        - containerPort: {{ .Values.service.internalPort }}\n        livenessProbe:\n          httpGet:\n            path: /\n            port: {{ .Values.service.internalPort }}\n        readinessProbe:\n          httpGet:\n            path: /\n            port: {{ .Values.service.internalPort }}\n        resources:\n{{ toYaml .Values.resources | indent 12 }}\n"
    }
    templates {
      name: "templates/service.yaml"
      data: "apiVersion: v1\nkind: Service\nmetadata:\n  name: {{ template \"fullname\" . }}\n  labels:\n    chart: \"{{ .Chart.Name }}-{{ .Chart.Version | replace \"+\" \"_\" }}\"\nspec:\n  type: {{ .Values.service.type }}\n  ports:\n  - port: {{ .Values.service.externalPort }}\n    targetPort: {{ .Values.service.internalPort }}\n    protocol: TCP\n    name: {{ .Values.service.name }}\n  selector:\n    app: {{ template \"fullname\" . }}\n"
    }
    values {
      raw: "# Default values for test.\n# This is a YAML-formatted file.\n# Declare variables to be passed into your templates.\nreplicaCount: 1\nimage:\n  repository: 172.16.101.192/common/nginx\n  tag: 1.8.1\n  pullPolicy: IfNotPresent\nservice:\n  name: nginx\n  type: ClusterIP\n  externalPort: 80\n  internalPort: 80\nresources:\n  limits:\n    cpu: 200m\n    memory: 128Mi\n  requests:\n    cpu: 200m\n    memory: 128Mi\ndessert: cake\n\n"
    }
    files {
      type_url: ".helmignore"
      value: "# Patterns to ignore when building packages.\n# This supports shell glob matching, relative path matching, and\n# negation (prefixed with !). Only one pattern per line.\n.DS_Store\n# Common VCS dirs\n.git/\n.gitignore\n.bzr/\n.bzrignore\n.hg/\n.hgignore\n.svn/\n# Common backup files\n*.swp\n*.bak\n*.tmp\n*~\n# Various IDEs\n.project\n.idea/\n*.tmproj\n"
    }
  }
  config {
    raw: "{}\n"
  }
  manifest: "\n---\n# Source: test/templates/configMap.yaml\napiVersion: v1\r\nkind: ConfigMap\r\nmetadata:\r\n  name: full-meerkat-test-cfgmap\r\n  # annotations:\r\n  #    # This is what defines this resource as a hook. Without this line, the\r\n  #    # job is considered part of the release.\r\n  #  \"helm.sh/hook\": pre-install\r\ndata:\r\n  dessert: cake\r\n  test: 1-false-true\r\n\n---\n# Source: test/templates/service.yaml\napiVersion: v1\nkind: Service\nmetadata:\n  name: full-meerkat-test\n  labels:\n    chart: \"test-0.1.0\"\nspec:\n  type: ClusterIP\n  ports:\n  - port: 80\n    targetPort: 80\n    protocol: TCP\n    name: nginx\n  selector:\n    app: full-meerkat-test\n\n---\n# Source: test/templates/deployment.yaml\napiVersion: extensions/v1beta1\nkind: Deployment\nmetadata:\n  name: full-meerkat-test\n  labels:\n    chart: \"test-0.1.0\"\nspec:\n  replicas: 1\n  template:\n    metadata:\n      labels:\n        app: full-meerkat-test\n      annotations:\n        pod.beta.kubernetes.io/init-containers: \'[\n              {\n                  \"name\": \"remove-lost-found\",\n                  \"image\": \"busybox:1.25.0\",\n                  \"command\": [\"rm\", \"-fr\", \"/var/lib/mysql/lost+found\"],\n                  \"volumeMounts\": [\n                      {\n                          \"name\": \"data\",\n                          \"mountPath\": \"/var/lib/mysql\"\n                      }\n                  ],\n                  \"imagePullPolicy\": \n              }\n          ]\'\n    spec:\n      containers:\n      - name: test\n        image: \"172.16.101.192/common/nginx:1.8.1\"\n        imagePullPolicy: IfNotPresent\n        ports:\n        - containerPort: 80\n        livenessProbe:\n          httpGet:\n            path: /\n            port: 80\n        readinessProbe:\n          httpGet:\n            path: /\n            port: 80\n        resources:\n            limits:\n              cpu: 200m\n              memory: 128Mi\n            requests:\n              cpu: 200m\n              memory: 128Mi\n            \n"
  version: 1
  namespace: "default"
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b0bcf3daa84f9e7e587839e1f80d0faf.html