|
61 | 61 | }; |
62 | 62 | }; |
63 | 63 | ConfigMap.init-scripts = { |
64 | | - data.init-secrets = # bash |
| 64 | + data.init-secrets = let |
| 65 | + kc = "kubectl -n ${cfg.namespace}"; |
| 66 | + in |
| 67 | + # bash |
65 | 68 | '' |
| 69 | + set -x |
66 | 70 | mkdir -p /tmp/{ssh-key,nix-key,ssh-auth} |
67 | | - if ! kubectl get secret ssh-key &>/dev/null || ! kubectl get configmap ssh-dynauth &>/dev/null; then |
| 71 | + if ! ${kc} get secret ssh-key &>/dev/null || ! ${kc} get configmap ssh-dynauth &>/dev/null; then |
68 | 72 | # Create ssh secret |
69 | 73 | ssh-keygen -t ed25519 -C "" -N "" -f /tmp/ssh-key/id_ed25519 |
70 | | - kubectl delete --ignore-not-found secret ssh-key |
71 | | - kubectl create secret generic ssh-key --from-file=/tmp/ssh-key |
| 74 | + ${kc} delete --ignore-not-found secret ssh-key |
| 75 | + ${kc} create secret generic ssh-key --from-file=/tmp/ssh-key |
72 | 76 |
|
73 | 77 | # Create pubkey configmap |
74 | 78 | cp /tmp/ssh-key/id_ed25519.pub /tmp/ssh-auth/authorized_keys |
75 | 79 | echo "* $(cat /tmp/ssh-key/id_ed25519.pub)" > /tmp/ssh-auth/ssh_known_hosts |
76 | | - kubectl delete --ignore-not-found configmap ssh-dynauth |
77 | | - kubectl create configmap ssh-dynauth --from-file=/tmp/ssh-auth |
| 80 | + ${kc} delete --ignore-not-found configmap ssh-dynauth |
| 81 | + ${kc} create configmap ssh-dynauth --from-file=/tmp/ssh-auth |
78 | 82 | fi |
79 | 83 |
|
80 | | - if ! kubectl get secret nix-key &>/dev/null; then |
| 84 | + if ! ${kc} get secret nix-key &>/dev/null; then |
81 | 85 | # create nix binary cache key |
82 | 86 | nix-store --generate-binary-cache-key \ |
83 | 87 | nix-cache-1 \ |
84 | 88 | /tmp/nix-key/nix_ed25519 \ |
85 | 89 | /tmp/nix-key/nix_ed25519.pub |
86 | | - kubectl delete --ignore-not-found secret nix-key |
87 | | - kubectl create secret generic nix-key --from-file=/tmp/nix-key |
| 90 | + ${kc} delete --ignore-not-found secret nix-key |
| 91 | + ${kc} create secret generic nix-key --from-file=/tmp/nix-key |
88 | 92 | fi |
89 | 93 | ''; |
90 | 94 | }; |
|
0 commit comments