Skip to content

Commit

Permalink
🔧 (headscale): Don't overwrite config if it already exists
Browse files Browse the repository at this point in the history
Envs are still suggested, but not required anymore
  • Loading branch information
gabe565 committed Mar 27, 2023
1 parent d426b46 commit 5736598
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion charts/headscale/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ sources:
annotations:
artifacthub.io/changes: |-
- kind: changed
description: Replace PNG icon with SVG
description: Don't overwrite config if already exists. Envs are still suggested, but not required anymore.
2 changes: 1 addition & 1 deletion charts/headscale/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Headscale runs in a distroless Docker container, which does not have any of the
expected command line utilities. This keeps the container small and minimizes the possibility of CVEs,
but it makes working with a config file in Kubernetes more difficult.

To keep config simple, this Helm chart opts to use environment variables.
To keep config simple, this Helm chart suggests using environment variables.
All of the Headscale config variables are supported as envs, but official documentation is lacking.

To configure Headscale:
Expand Down
2 changes: 1 addition & 1 deletion charts/headscale/README_CONFIG.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Headscale runs in a distroless Docker container, which does not have any of the
expected command line utilities. This keeps the container small and minimizes the possibility of CVEs,
but it makes working with a config file in Kubernetes more difficult.

To keep config simple, this Helm chart opts to use environment variables.
To keep config simple, this Helm chart suggests using environment variables.
All of the Headscale config variables are supported as envs, but official documentation is lacking.

To configure Headscale:
Expand Down
25 changes: 15 additions & 10 deletions charts/headscale/templates/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@ initContainers:
- sh
- -c
- |
cat <<'EOF' >/etc/headscale/config.yaml
# Please use environment variables to configure Headscale.
# For config reference, see https://github.com/juanfont/headscale/blob/main/config-example.yaml
# To configure any of these as an env:
# 1. Flatten object keys using "_"
# 2. Prefix with "HEADSCALE_"
#
# For example:
# - "listen_addr" becomes "HEADSCALE_LISTEN_ADDR"
# - "log.level" becomes "HEADSCALE_LOG_LEVEL"
if [[ -f '/etc/headscale/config.yaml' ]]; then
echo 'Config already exists' >&2
else
echo 'Writing empty config' >&2
cat <<- 'EOF' >/etc/headscale/config.yaml
# It's suggested to use environment variables to configure Headscale.
# For config reference, see https://github.com/juanfont/headscale/blob/main/config-example.yaml
# To configure any of these as an env:
# 1. Flatten object keys using "_"
# 2. Prefix with "HEADSCALE_"
#
# For example:
# - "listen_addr" becomes "HEADSCALE_LISTEN_ADDR"
# - "log.level" becomes "HEADSCALE_LOG_LEVEL"
EOF
fi
env:
{{- with .Values.ingress.main }}
Expand Down

0 comments on commit 5736598

Please sign in to comment.