Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kuuji/helm-external-val
helm plugin to fetch values from external sources
https://github.com/kuuji/helm-external-val
argocd gitops helm helm-plugin helm-plugins kubernetes
Last synced: 3 months ago
JSON representation
helm plugin to fetch values from external sources
- Host: GitHub
- URL: https://github.com/kuuji/helm-external-val
- Owner: kuuji
- License: apache-2.0
- Created: 2022-01-20T01:06:02.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-25T19:53:57.000Z (over 1 year ago)
- Last Synced: 2024-06-19T06:54:19.809Z (7 months ago)
- Topics: argocd, gitops, helm, helm-plugin, helm-plugins, kubernetes
- Language: Go
- Homepage:
- Size: 8.97 MB
- Stars: 16
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# helm-external-val
## Overview
`helm-external-val` is a helm plugin that fetches helm values from external source.
Currently it supports getting values from kubernetes [ConfigMaps](https://kubernetes.io/docs/concepts/configuration/configmap/) and kubernetes [Secrets](https://kubernetes.io/docs/concepts/configuration/secret/)## Installation
### Local
```
helm plugin install https://github.com/kuuji/helm-external-val
```or by specifying the version (git tag)
```
helm plugin install --version v0.0.4 https://github.com/kuuji/helm-external-val
```### ArgoCD
### Via a custom image
The ArgoCD [recommended option](https://argo-cd.readthedocs.io/en/stable/user-guide/helm/#helm-plugins) is to build a repo-server image that includes the plugin.
See example below```
FROM argoproj/argocd:v1.5.7USER root
RUN apt-get update && \
apt-get install -y \
curl && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*USER argocd
RUN helm plugin install https://github.com/kuuji/helm-external-val
ENV HELM_PLUGINS="/home/argocd/.local/share/helm/plugins/"
```### Via init container
Using the helm chart or by patching repo-server we can use an init-container to install helm-external-val in a shared `custom-tools` volume.
Then we set the helm plugins directory to `/custom-tools/helm-plugins` in the main repo-server container via the env `HELM_PLUGIN`
Credit to @jkroepke for this neat trick```
repoServer:
env:
- name: HELM_PLUGINS
value: /custom-tools/helm-plugins/
volumes:
- name: custom-tools
emptyDir: {}
volumeMounts:
- mountPath: /custom-tools
name: custom-tools
initContainers:
- name: download-tools
args:
- |
mkdir -p /custom-tools/helm-plugins
helm plugin install https://github.com/kuuji/helm-external-val
command:
- sh
- -ec
image: alpine/helm:latest
imagePullPolicy: Always
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /custom-tools
name: custom-tools
env:
- name: HELM_PLUGINS
value: /custom-tools/helm-plugins
```### Caveats
ArgoCD won't re-evaluate the external source unless you do a hard refresh on the application. This is because argocd caches the application manifest and won't evaluate the external values since the application manifest didn't change.
You can do this either in the ui (click the arrow under the refresh button) or via the cli like below.
```
argocd app get --hard-refresh
```## Usage
This plugin has 2 modes of operation.
- Using the plugin cli
- Create a values.yaml locally from various sources- As a downloader plugin
- Feed a specially formatted url to `helm install|upgrade -f`The latter is recommended as it fits well with gitops workflows.
### CLI plugin
```
helm external-val cm -h
Get the content of values from a cm and write it to a fileUsage:
helm-external-val cm [flags]Flags:
--dataKey string The key to get the cm from (default "values.yaml")
-h, --help help for cm
--kube_namespace string The namespace to get the cm from (default "default")
-o, --out string The file to output the values to (default "values-cm.yaml")
``````
helm external-val secret -h
Get the content of values from a secret and write it to a fileUsage:
helm-external-val secret [flags]Flags:
--dataKey string The key to get the data from a secret (default "values.yaml")
-h, --help help for secret
--kube_namespace string The namespace to get the secret from (default "default")
-o, --out string The file to output the values to (default "values-secret.yaml")
```### Downloader plugin
Helm will invoke the downloader plugin with 4 parameters `certFile keyFile caFile full-URL`. In our case we're ignoring the first 3.
The url has to be formatted as follows
```
:////
```- source (required) : the protocol to use (`cm` and `secret` are currently supported)
- namespace (optional) : the namespace in which to look for the resource (defaults to `default`)
- name (required) : the name of the resource to fetch
- key (optional) : the key in which to look for the data in the resource (defaults to `values.yaml`)for example the url below will fetch the data under `my-values` from ConfigMap named `helm-values` in the namespace `kuuji`.
```
cm://kuuji/helm-values/my-values
```