首页 > 解决方案 > 从图表中查找 repo

问题描述

我正在尝试编写一段代码,该代码将“观察”添加到集群中的任何新掌舵图,并找出有关该图表的一些细节。例如,使用的值、图表的回购等。

我能够获取图表的值,但 repo url 未存储在图表中。

有没有办法在给定图表的情况下获得回购?

看起来 helm 将源存储在图表元数据中,但有没有更好的方法来获取这些信息?

type Metadata struct {
    // The name of the chart
    Name string `json:"name,omitempty"`
    // The URL to a relevant project page, git repo, or contact person
    Home string `json:"home,omitempty"`
    // Source is the URL to the source code of this chart
    Sources []string `json:"sources,omitempty"`
    // A SemVer 2 conformant version string of the chart
    Version string `json:"version,omitempty"`
    // A one-sentence description of the chart
    Description string `json:"description,omitempty"`
    // A list of string keywords
    Keywords []string `json:"keywords,omitempty"`
    // A list of name and URL/email address combinations for the maintainer(s)
    Maintainers []*Maintainer `json:"maintainers,omitempty"`
    // The URL to an icon file.
    Icon string `json:"icon,omitempty"`
    // The API Version of this chart.
    APIVersion string `json:"apiVersion,omitempty"`
    // The condition to check to enable chart
    Condition string `json:"condition,omitempty"`
    // The tags to check to enable chart
    Tags string `json:"tags,omitempty"`
    // The version of the application enclosed inside of this chart.
    AppVersion string `json:"appVersion,omitempty"`
    // Whether or not this chart is deprecated
    Deprecated bool `json:"deprecated,omitempty"`
    // Annotations are additional mappings uninterpreted by Helm,
    // made available for inspection by other applications.
    Annotations map[string]string `json:"annotations,omitempty"`
    // KubeVersion is a SemVer constraint specifying the version of Kubernetes required.
    KubeVersion string `json:"kubeVersion,omitempty"`
    // Dependencies are a list of dependencies for a chart.
    Dependencies []*Dependency `json:"dependencies,omitempty"`
    // Specifies the chart type: application or library
    Type string `json:"type,omitempty"`
}```

标签: kubernetes-helm

解决方案


您列出的结构实际上并不存储存储库 URL。这只是charts.yaml. 例如,在 Hazelcast Helm Chart 中,它是 "http://hazelcast.org/",它不是图表存储库 URL。

当您执行时helm repo update,Helm 只是从存储库中下载图表,而不是稍后存储 repo URL。因此,在您的情况下,如果您想提取给定图表的 repo URL,您需要执行以下命令(并匹配正确的 repo 名称):

helm repo list

推荐阅读