kubernetes.core.helm (3.0.1) — module

Manages Kubernetes packages with the Helm package manager

| "added in version" 0.11.0 of kubernetes.core"

Authors: Lucas Boisserie (@LucasBoisserie), Matthieu Diehr (@d-matt)

This plugin has a corresponding action plugin.

Install collection

Install with ansible-galaxy collection install kubernetes.core:==3.0.1


Add to requirements.yml

  collections:
    - name: kubernetes.core
      version: 3.0.1

Description

Install, upgrade, delete packages with the Helm package manager.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deploy latest version of Prometheus chart inside monitoring namespace (and create it)
  kubernetes.core.helm:
    name: test
    chart_ref: stable/prometheus
    release_namespace: monitoring
    create_namespace: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# From repository
- name: Add stable chart repo
  kubernetes.core.helm_repository:
    name: stable
    repo_url: "https://kubernetes.github.io/ingress-nginx"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deploy latest version of Grafana chart inside monitoring namespace with values
  kubernetes.core.helm:
    name: test
    chart_ref: stable/grafana
    release_namespace: monitoring
    values:
      replicas: 2
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deploy Grafana chart on 5.0.12 with values loaded from template
  kubernetes.core.helm:
    name: test
    chart_ref: stable/grafana
    chart_version: 5.0.12
    values: "{{ lookup('template', 'somefile.yaml') | from_yaml }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deploy Grafana chart using values files on target
  kubernetes.core.helm:
    name: test
    chart_ref: stable/grafana
    release_namespace: monitoring
    values_files:
      - /path/to/values.yaml
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Remove test release and waiting suppression ending
  kubernetes.core.helm:
    name: test
    state: absent
    wait: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Separately update the repository cache
  kubernetes.core.helm:
    name: dummy
    namespace: kube-system
    state: absent
    update_repo_cache: true
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deploy Grafana chart using set values on target
  kubernetes.core.helm:
    name: test
    chart_ref: stable/grafana
    release_namespace: monitoring
    set_values:
      - value: phase=prod
        value_type: string
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# From git
- name: Git clone stable repo on HEAD
  ansible.builtin.git:
    repo: "http://github.com/helm/charts.git"
    dest: /tmp/helm_repo
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Deploy Grafana chart from local path
  kubernetes.core.helm:
    name: test
    chart_ref: /tmp/helm_repo/stable/grafana
    release_namespace: monitoring
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# From url
- name: Deploy Grafana chart on 5.6.0 from url
  kubernetes.core.helm:
    name: test
    chart_ref: "https://github.com/grafana/helm-charts/releases/download/grafana-5.6.0/grafana-5.6.0.tgz"
    release_namespace: monitoring
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Using complex Values
- name: Deploy new-relic client chart
  kubernetes.core.helm:
    name: newrelic-bundle
    chart_ref: newrelic/nri-bundle
    release_namespace: default
    force: True
    wait: True
    replace: True
    update_repo_cache: True
    disable_hook: True
    values:
      global:
        licenseKey: "{{ nr_license_key }}"
        cluster: "{{ site_name }}"
      newrelic-infrastructure:
        privileged: True
      ksm:
        enabled: True
      prometheus:
        enabled: True
      kubeEvents:
        enabled: True
      logging:
        enabled: True
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Deploy latest version
- name: Deploy latest version of Grafana chart using reuse_values
  kubernetes.core.helm:
    name: test
    chart_ref: stable/grafana
    release_namespace: monitoring
    reuse_values: true
    values:
      replicas: 2
      version: 3e8ec0b2dffa40fb97d5342e4af887de95faa8c61a62480dd7f8aa03dffcf533

Inputs

    
host:
    description:
    - Provide a URL for accessing the API. Can also be specified via C(K8S_AUTH_HOST)
      environment variable.
    type: str
    version_added: 1.2.0
    version_added_collection: kubernetes.core

wait:
    default: false
    description:
    - When I(release_state) is set to C(present), wait until all Pods, PVCs, Services,
      and minimum number of Pods of a Deployment are in a ready state before marking the
      release as successful.
    - When I(release_state) is set to C(absent), will wait until all the resources are
      deleted before returning. It will wait for as long as I(wait_timeout). This feature
      requires helm>=3.7.0. Added in version 2.3.0.
    type: bool

force:
    default: false
    description:
    - Helm option to force reinstall, ignore on new install.
    type: bool

purge:
    default: true
    description:
    - Remove the release from the store and make its name free for later use.
    type: bool

atomic:
    default: false
    description:
    - If set, the installation process deletes the installation on failure.
    type: bool

api_key:
    description:
    - Token used to authenticate with the API. Can also be specified via C(K8S_AUTH_API_KEY)
      environment variable.
    type: str
    version_added: 1.2.0
    version_added_collection: kubernetes.core

ca_cert:
    aliases:
    - ssl_ca_cert
    description:
    - Path to a CA certificate used to authenticate with the API. The full certificate
      chain must be provided to avoid certificate validation errors. Can also be specified
      via C(K8S_AUTH_SSL_CA_CERT) environment variable.
    type: path
    version_added: 1.2.0
    version_added_collection: kubernetes.core

context:
    aliases:
    - kube_context
    description:
    - Helm option to specify which kubeconfig context to use.
    - If the value is not specified in the task, the value of environment variable C(K8S_AUTH_CONTEXT)
      will be used instead.
    type: str

replace:
    default: false
    description:
    - Reuse the given name, only if that name is a deleted release which remains in the
      history.
    - This is unsafe in production environment.
    - mutually exclusive with with C(history_max).
    type: bool
    version_added: 1.11.0
    version_added_collection: kubernetes.core

timeout:
    description:
    - A Go duration (described here I(https://pkg.go.dev/time#ParseDuration)) value to
      wait for Kubernetes commands to complete. This defaults to 5m0s.
    - similar to C(wait_timeout) but does not required C(wait) to be activated.
    - Mutually exclusive with C(wait_timeout).
    type: str
    version_added: 2.3.0
    version_added_collection: kubernetes.core

chart_ref:
    description:
    - chart_reference on chart repository.
    - path to a packaged chart.
    - path to an unpacked chart directory.
    - absolute URL.
    - Required when I(release_state) is set to C(present).
    required: false
    type: path

skip_crds:
    default: false
    description:
    - Skip custom resource definitions when installing or upgrading.
    type: bool
    version_added: 1.2.0
    version_added_collection: kubernetes.core

kubeconfig:
    aliases:
    - kubeconfig_path
    description:
    - Helm option to specify kubeconfig path to use.
    - If the value is not specified in the task, the value of environment variable C(K8S_AUTH_KUBECONFIG)
      will be used instead.
    - The configuration can be provided as dictionary. Added in version 2.4.0.
    type: raw

set_values:
    description:
    - Values to pass to chart configuration
    elements: dict
    required: false
    suboptions:
      value:
        description:
        - Value to pass to chart configuration (e.g phase=prod).
        required: true
        type: str
      value_type:
        choices:
        - raw
        - string
        - json
        - file
        default: raw
        description:
        - Use C(raw) set individual value.
        - Use C(string) to force a string for an individual value.
        - Use C(file) to set individual values from a file when the value itself is too
          long for the command line or is dynamically generated.
        - Use C(json) to set json values (scalars/objects/arrays). This feature requires
          helm>=3.10.0.
    type: list
    version_added: 2.4.0
    version_added_collection: kubernetes.core

binary_path:
    description:
    - The path of a helm binary to use.
    required: false
    type: path

history_max:
    description:
    - Limit the maximum number of revisions saved per release.
    - mutually exclusive with with C(replace).
    type: int
    version_added: 2.2.0
    version_added_collection: kubernetes.core

disable_hook:
    default: false
    description:
    - Helm option to disable hook on install/upgrade/delete.
    type: bool

release_name:
    aliases:
    - name
    description:
    - Release name to manage.
    required: true
    type: str

reset_values:
    default: true
    description:
    - When upgrading package, reset the values to the ones built into the chart.
    required: false
    type: bool
    version_added: 2.5.0
    version_added_collection: kubernetes.core

reuse_values:
    description:
    - When upgrading package, specifies wether to reuse the last release's values and
      merge in any overrides from parameters I(release_values), I(values_files) or I(set_values).
    - If I(reset_values) is set to C(True), this is ignored.
    required: false
    type: bool
    version_added: 2.5.0
    version_added_collection: kubernetes.core

values_files:
    default: []
    description:
    - Value files to pass to chart.
    - Paths will be read from the target host's filesystem, not the host running ansible.
    - values_files option is evaluated before values option if both are used.
    - Paths are evaluated in the order the paths are specified.
    elements: str
    required: false
    type: list
    version_added: 1.1.0
    version_added_collection: kubernetes.core

wait_timeout:
    description:
    - Timeout when wait option is enabled (helm2 is a number of seconds, helm3 is a duration).
    - The use of I(wait_timeout) to wait for kubernetes commands to complete has been
      deprecated and will be removed after 2022-12-01.
    type: str

chart_version:
    description:
    - Chart version to install. If this is not specified, the latest version is installed.
    required: false
    type: str

post_renderer:
    description:
    - Path to an executable to be used for post rendering.
    type: str
    version_added: 2.4.0
    version_added_collection: kubernetes.core

release_state:
    aliases:
    - state
    choices:
    - present
    - absent
    default: present
    description:
    - Desirated state of release.
    required: false
    type: str

chart_repo_url:
    description:
    - Chart repository URL where to locate the requested chart.
    required: false
    type: str

release_values:
    aliases:
    - values
    default: {}
    description:
    - Value to pass to chart.
    required: false
    type: dict

validate_certs:
    aliases:
    - verify_ssl
    default: true
    description:
    - Whether or not to verify the API server's SSL certificates. Can also be specified
      via C(K8S_AUTH_VERIFY_SSL) environment variable.
    type: bool
    version_added: 1.2.0
    version_added_collection: kubernetes.core

create_namespace:
    default: false
    description:
    - Create the release namespace if not present.
    type: bool
    version_added: 0.11.1
    version_added_collection: kubernetes.core

dependency_update:
    aliases:
    - dep_up
    default: false
    description:
    - Run standalone C(helm dependency update CHART) before the operation.
    - Run inline C(--dependency-update) with C(helm install) command. This feature is
      not supported yet with the C(helm upgrade) command.
    - So we should consider to use I(dependency_update) options with I(replace) option
      enabled when specifying I(chart_repo_url).
    - The I(dependency_update) option require the add of C(dependencies) block in C(Chart.yaml/requirements.yaml)
      file.
    - For more information please visit U(https://helm.sh/docs/helm/helm_dependency/)
    type: bool
    version_added: 2.4.0
    version_added_collection: kubernetes.core

release_namespace:
    aliases:
    - namespace
    description:
    - Kubernetes namespace where the chart should be installed.
    required: true
    type: str

update_repo_cache:
    default: false
    description:
    - Run C(helm repo update) before the operation. Can be run as part of the package
      installation or as a separate step (see Examples).
    type: bool

Outputs

command:
  description: Full `helm` command built by this module, in case you want to re-run
    the command outside the module or debug a problem.
  returned: always
  sample: helm upgrade ...
  type: str
status:
  contains:
    appversion:
      description: Version of app deployed
      returned: always
      type: str
    chart:
      description: Chart name and chart version
      returned: always
      type: str
    name:
      description: Name of the release
      returned: always
      type: str
    namespace:
      description: Namespace where the release is deployed
      returned: always
      type: str
    revision:
      description: Number of time where the release has been updated
      returned: always
      type: str
    status:
      description: Status of release (can be DEPLOYED, FAILED, ...)
      returned: always
      type: str
    updated:
      description: The Date of last update
      returned: always
      type: str
    values:
      description: Dict of Values used to deploy
      returned: always
      type: str
  description: A dictionary of status output
  returned: on success Creation/Upgrade/Already deploy
  type: complex
stderr:
  description: Full `helm` command stderr, in case you want to display it or examine
    the event log
  returned: always
  sample: ''
  type: str
stdout:
  description: Full `helm` command stdout, in case you want to display it or examine
    the event log
  returned: always
  sample: ''
  type: str