简体   繁体   English

如何从 Python 中的 Kubernetes 集群中获取已部署微服务的 Helm 图表版本

[英]How to fetch the Helm chart version of an already deployed microservice from Kubernetes Cluster in Python

I have deployed a microservice in a K8S Cluster.我在 K8S 集群中部署了一个微服务。 Below are the Helm Chart details -以下是 Helm Chart 详细信息 -

CHART_NAME=eric-bss-sd-dxp-adaptation-staging, CHART_VERSION=1.0.262, NAMESPACE=anindya-ns CHART_NAME=eric-bss-sd-dxp-adaptation-staging,CHART_VERSION=1.0.262,NAMESPACE=anindya-ns

Now I want to write a python script which will fetch this version of the chart (ie 1.0.262)现在我想写一个 python 脚本来获取这个版本的图表(即 1.0.262)

Please help if you have worked on such requirement before or suggest the way forward如果您以前曾处理过此类要求或建议前进的方向,请提供帮助

I can give you some steps, it may helpful.我可以给你一些步骤,它可能会有所帮助。

create a service/pod/deployment..., like below创建一个服务/pod/部署...,如下所示

apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
labels:
    chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" 

You can use.Chart.Version in any where like name, fullname, lable...,您可以在任何地方使用.Chart.Version,例如名称、全名、标签……,

Use kubectl command to fetch the yaml file ex:- https://github.com/kubernetes/kubernetes/issues/24873使用 kubectl 命令获取 yaml 文件,例如:- https://github.com/kubernetes/kubernetes/issues/24873

then write your own python code read it, fetch chat version.然后编写您自己的 python 代码阅读它,获取聊天版本。

Please refer below links https://github.com/kubernetes-client/python https://pypi.org/project/kube/请参考以下链接https://github.com/kubernetes-client/python https://pypi.org/project/kube/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM