hetznercloud / hcloud-cloud-controller-manager

Kubernetes cloud-controller-manager for Hetzner Cloud
Apache License 2.0
740 stars 118 forks source link

feat(helm): allow setting extra pod volumes via chart values #744

Closed hegerdes closed 2 months ago

hegerdes commented 2 months ago

What changed

This adds the ability to set extraVolumes and extraVolumeMounts via helm to the pod. It can be used to mount extra files, to persist files inside the container or to allow usage of the CSI Secret Driver.
It does not introduce user facing changes since the default for both is an empty array, so no volumes or volumeMounts are created when not explicitly set.

Fixed #743

Testing

The change can be previewed with the following command: helm template chart -s templates/deployment.yaml --values chart/my-values.yaml --debug

# my-values.yaml 
# Mounts the specified volume to the hcloud-cloud-controller-manager container.
extraVolumeMounts:
  - name: token-volume
    readOnly: true
    mountPath: /var/run/secrets/hcloud

# Adds extra volumes to the pod.
extraVolumes:
  - name: token-volume
    secret:
      secretName: hcloud-token

# Set envs for token
env:
  HCLOUD_TOKEN_FILE:
    value: /var/run/secrets/hcloud/token
  HCLOUD_TOKEN: null

Testing can be done with the same file just with helm install. The hcloud-token must exist before deployment

apricote commented 2 months ago

Awesome! Thanks @hegerdes.

Your values failed for me, the env is not properly defined and causes a YAML parser error. This works:

env:
  HCLOUD_TOKEN_FILE:
    value: /var/run/secrets/hcloud/token
hegerdes commented 2 months ago

Awesome! Thanks @hegerdes.

Your values failed for me, the env is not properly defined and causes a YAML parser error. This works:

env:
  HCLOUD_TOKEN_FILE:
    value: /var/run/secrets/hcloud/token

Thanks, I fixed the error, updated the example and rebased from main.

I tested now with helm upgrade --install ccm chart --values chart/my-values.yaml

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 71.81%. Comparing base (a299730) to head (a6a5af7). Report is 1 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #744 +/- ## ========================================== - Coverage 72.00% 71.81% -0.19% ========================================== Files 31 30 -1 Lines 2650 2473 -177 ========================================== - Hits 1908 1776 -132 + Misses 553 524 -29 + Partials 189 173 -16 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.