Ansible 错误:在 prometheus-community 索引中找不到匹配 50.3.1 的图表“kube-prometheus-stack”

问题描述 投票:0回答:1

我尝试安装

kube-prometheus-stack
版本为
50.3.1
这里是图表的链接

但是 Ansible 正在崩溃并抱怨

Error: chart "kube-prometheus-stack" matching 50.3.1 not found in prometheus-community index. (try 'helm repo update'): no chart version found for kube-prometheus-stack-50.3.1

我确实跑了

helm repo update
,但没有帮助。另外,如果我手动运行该命令,它就可以工作。

helm upgrade -i --reset-values --atomic --create-namespace prometheus prometheus-community/kube-prometheus-stack --namespace monitoring --version 50.3.1 -f roles/shlomo/monitoring/files/values-prometheus-stack.yaml

有人可以帮我解决发生的事情吗?

组件名称

kubernetes.core.helm

ANSIBLE版本
ansible [core 2.15.0]
  config file = /code/infrastructure/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /code/.venv/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /code/.venv/bin/ansible
  python version = 3.9.10 (main, Mar  2 2022, 04:31:58) [GCC 10.2.1 20210110] (/code/.venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True
珍藏版
kubernetes.core 2.4.0
配置
CONFIG_FILE() = /code/infrastructure/ansible/ansible.cfg
DEFAULT_FILTER_PLUGIN_PATH(/code/infrastructure/ansible/ansible.cfg) = ['/code/infrastructure/ansible/plugins/>
DEFAULT_HOST_LIST(/code/infrastructure/ansible/ansible.cfg) = ['/code/infrastructure/ansible/inventories/sorte>
DEFAULT_ROLES_PATH(/code/infrastructure/ansible/ansible.cfg) = ['/root/.ansible/roles', '/code/infrastructure/>
DEFAULT_VAULT_PASSWORD_FILE(/code/infrastructure/ansible/ansible.cfg) = /root/.vault_pass
HOST_KEY_CHECKING(/code/infrastructure/ansible/ansible.cfg) = False
操作系统/环境

在 Docker 上运行

Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
重现步骤
- name: Add kube prometheus stack chart repo
  kubernetes.core.helm_repository:
    repo_name: prometheus-community
    repo_url: https://prometheus-community.github.io/helm-charts

- name: Install kube prometheus stack chart
  kubernetes.core.helm:
    atomic: true
    name: prometheus
    chart_ref: prometheus-community/kube-prometheus-stack
    chart_version: 50.3.1
    create_namespace: true
    release_namespace: monitoring
    # values: "{{ lookup('file', 'files/values-prometheus-stack.yaml') | from_yaml }}" # i includeded this for completnes but you can ignore this

预期结果

helm 应该已经安装了指定版本的 kube-prometheus-stack 图表

实际结果

Ansible 未能安装图表

fatal: [sx_master]: FAILED! => {
    "changed": false,
    "command": "/usr/sbin/helm --version=50.3.1 show chart prometheus-community/kube-prometheus-stack",
    "invocation": {
        "module_args": {
            "api_key": null,
            "atomic": true,
            "binary_path": null,
            "ca_cert": null,
            "chart_ref": "prometheus-community/kube-prometheus-stack",
            "chart_repo_url": null,
            "chart_version": "50.3.1",
            "context": null,
            "create_namespace": true,
            "dependency_update": false,
            "disable_hook": false,
            "force": false,
            "history_max": null,
            "host": null,
            "kubeconfig": null,
            "name": "prometheus",
            "post_renderer": null,
            "purge": true,
            "release_name": "prometheus",
            "release_namespace": "monitoring",
            "release_state": "present",
            "release_values": {},
            "replace": false,
            "set_values": null,
            "skip_crds": false,
            "timeout": null,
            "update_repo_cache": false,
            "validate_certs": true,
            "values_files": [],
            "wait": false,
            "wait_timeout": null
        }
    },
    "msg": "Failure when executing Helm command. Exited 1.\nstdout: \nstderr: Error: chart \"kube-prometheus-stack\" matching 50.3.1 not found in prometheus-community index. (try 'helm repo update'): no chart version found for kube-prometheus-stack-50.3.1\n",
    "stderr": "Error: chart \"kube-prometheus-stack\" matching 50.3.1 not found in prometheus-community index. (try 'helm repo update'): no chart version found for kube-prometheus-stack-50.3.1\n",
    "stderr_lines": [
        "Error: chart \"kube-prometheus-stack\" matching 50.3.1 not found in prometheus-community index. (try 'helm repo update'): no chart version found for kube-prometheus-stack-50.3.1"
    ],
    "stdout": "",
    "stdout_lines": []
}
ansible devops prometheus kubernetes-helm
1个回答
0
投票

添加

update_repo_cache: true
解决问题。

这是它的样子

- name: Install kube prometheus stack chart
  kubernetes.core.helm:
    atomic: true
    name: prometheus
    chart_ref: prometheus-community/kube-prometheus-stack
    chart_version: 50.3.1
    update_repo_cache: true # <--------------------------This is the solution
    create_namespace: true
    release_namespace: monitoring
    values: "{{ lookup('file', 'files/values-prometheus-stack.yaml') | from_yaml }}" # i includeded this for completnes but you can ignore this

© www.soinside.com 2019 - 2024. All rights reserved.