|
| 1 | +# Use an existing Secret for the token (SOPS / GitOps) |
| 2 | + |
| 3 | +Instead of putting `clusterToken` / `patToken` in your values, point the chart |
| 4 | +at a Secret you manage. You encrypt only that Secret with |
| 5 | +[SOPS](https://github.com/getsops/sops); your values file stays token-free. |
| 6 | + |
| 7 | +## The one flag that matters |
| 8 | + |
| 9 | +Take the helm command from the dashboard's **Connect cluster** button and add: |
| 10 | + |
| 11 | +``` |
| 12 | +--set zxporter.existingSecret.name=<your-secret-name> |
| 13 | +``` |
| 14 | + |
| 15 | +That's it — the chart then reads the token from your Secret instead of creating |
| 16 | +its own, and no token ever appears in the helm command or values. |
| 17 | + |
| 18 | +## Steps (SOPS + age) |
| 19 | + |
| 20 | +```bash |
| 21 | +export NS=devzero-system |
| 22 | + |
| 23 | +# 1. Create the SOPS-encrypted Secret (encrypt only the data; commit the .enc.yaml). |
| 24 | +age-keygen -o key.txt # prints: Public key: age1xxxx... |
| 25 | +cat > zxporter-token.secret.yaml <<'EOF' |
| 26 | +apiVersion: v1 |
| 27 | +kind: Secret |
| 28 | +metadata: |
| 29 | + name: zxporter-token |
| 30 | +type: Opaque |
| 31 | +stringData: |
| 32 | + PAT_TOKEN: "dzp_your_pat" # or CLUSTER_TOKEN: "..." |
| 33 | +EOF |
| 34 | +sops --encrypt --age age1xxxx... --encrypted-regex '^(data|stringData)$' \ |
| 35 | + zxporter-token.secret.yaml > zxporter-token.secret.enc.yaml |
| 36 | +rm zxporter-token.secret.yaml |
| 37 | + |
| 38 | +# 2. Apply it into the namespace (server-side keeps plaintext out of annotations). |
| 39 | +kubectl create namespace $NS --dry-run=client -o yaml | kubectl apply -f - |
| 40 | +SOPS_AGE_KEY_FILE=$PWD/key.txt sops --decrypt zxporter-token.secret.enc.yaml \ |
| 41 | + | kubectl apply --server-side -n $NS -f - |
| 42 | + |
| 43 | +# 3. Run the dashboard's Connect-cluster helm command with the extra flag: |
| 44 | +# --set zxporter.existingSecret.name=zxporter-token |
| 45 | +``` |
| 46 | + |
| 47 | +**GitOps:** commit `zxporter-token.secret.enc.yaml` and let Argo CD (KSOPS / |
| 48 | +`argocd-vault-plugin`) or Flux (`decryption.provider: sops`) decrypt it at sync |
| 49 | +time; set `zxporter.existingSecret.name` in the HelmRelease/Application values. |
| 50 | + |
| 51 | +## Values |
| 52 | + |
| 53 | +```yaml |
| 54 | +zxporter: |
| 55 | + existingSecret: |
| 56 | + name: "" # your Secret; empty = use clusterToken/patToken |
| 57 | + clusterTokenKey: "CLUSTER_TOKEN" |
| 58 | + patTokenKey: "PAT_TOKEN" |
| 59 | +``` |
| 60 | +
|
| 61 | +Provide one token — `CLUSTER_TOKEN` or `PAT_TOKEN`. Only used when |
| 62 | +`useSecretForToken: true` (the default). |
| 63 | + |
| 64 | +## Gotchas |
| 65 | + |
| 66 | +- **Secret must exist in the release namespace before install** (`secretKeyRef` |
| 67 | + is namespace-local). |
| 68 | +- **Name must differ from `tokenSecretName`** (default `devzero-zxporter-token`) — |
| 69 | + the chart manages that one itself. The chart fails fast if they match. |
| 70 | +- **Wrong/missing key = no auth, no crash** (keys are `optional`). Check pod logs |
| 71 | + for `no URL or token was configured`. |
0 commit comments