-
Notifications
You must be signed in to change notification settings - Fork 3
feat: mtls enable #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -21,3 +21,7 @@ | |||
| .idea/ | ||||
| *.tmproj | ||||
| .vscode/ | ||||
|
|
||||
| # Generated mTLS certificates | ||||
| certs/ | ||||
| gen-mtls-certs.sh | ||||
|
||||
| gen-mtls-certs.sh |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -----BEGIN CERTIFICATE----- | ||
| MIIBjzCCATWgAwIBAgIUSJ2qiDFEvwKXlPAGWOnaD3onTGQwCgYIKoZIzj0EAwIw | ||
| HTEbMBkGA1UEAwwSR3RodWxodS1Qcml2YXRlLUNBMB4XDTI2MDIyMzAzMTM0NFoX | ||
| DTM2MDIyMTAzMTM0NFowHTEbMBkGA1UEAwwSR3RodWxodS1Qcml2YXRlLUNBMFkw | ||
| EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEsrU+DZyBpiuB5pvSuS/fbOGckLlwTC73 | ||
| mkQ7hnWwDnA/q+baN77PVtoVZrGNwxxgD0FAhzdrkRAf2jfEuTiqfqNTMFEwHQYD | ||
| VR0OBBYEFIMViDVVNYHUrpQd8MIRbGMk+zjUMB8GA1UdIwQYMBaAFIMViDVVNYHU | ||
| rpQd8MIRbGMk+zjUMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwIDSAAwRQIg | ||
| Ro9LhiUYzT7F5iXEJ0IM64quGDGlSWrbiRBO2odpTq0CIQDMEBxBhsqlx7h4ok6D | ||
| vfoIMENsvJMMzAwN8uA6Y61lKA== | ||
| -----END CERTIFICATE----- |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||||
| -----BEGIN EC PRIVATE KEY----- | ||||||||||||||||||||||||
| MHcCAQEEIIzkO4hC30h7tkNNeCt/NUej6NYWubQ1N6D7vef8uX9yoAoGCCqGSM49 | ||||||||||||||||||||||||
| AwEHoUQDQgAEsrU+DZyBpiuB5pvSuS/fbOGckLlwTC73mkQ7hnWwDnA/q+baN77P | ||||||||||||||||||||||||
| VtoVZrGNwxxgD0FAhzdrkRAf2jfEuTiqfg== | ||||||||||||||||||||||||
| -----END EC PRIVATE KEY----- | ||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
|
||||||||||||||||||||||||
| -----BEGIN EC PRIVATE KEY----- | |
| MHcCAQEEIIzkO4hC30h7tkNNeCt/NUej6NYWubQ1N6D7vef8uX9yoAoGCCqGSM49 | |
| AwEHoUQDQgAEsrU+DZyBpiuB5pvSuS/fbOGckLlwTC73mkQ7hnWwDnA/q+baN77P | |
| VtoVZrGNwxxgD0FAhzdrkRAf2jfEuTiqfg== | |
| -----END EC PRIVATE KEY----- | |
| # Private key removed. | |
| # | |
| # A CA/private key must NOT be committed to version control. | |
| # Generate and manage this key securely (for example, via a secrets manager | |
| # or deployment-time configuration), and ensure gthulhu/certs/ca.key (or | |
| # matching patterns such as *.key) are listed in .gitignore. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| -----BEGIN CERTIFICATE----- | ||
| MIICdjCCAhygAwIBAgIUCT9p4TDp3lc2Fwp+EfecoNsTVVgwCgYIKoZIzj0EAwIw | ||
| HTEbMBkGA1UEAwwSR3RodWxodS1Qcml2YXRlLUNBMB4XDTI2MDIyMzAzMTM0NVoX | ||
| DTI4MDIyMzAzMTM0NVowIDEeMBwGA1UEAwwVZ3RodWxodS1kZWNpc2lvbm1ha2Vy | ||
| MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEI9rucwma2o8H2eLPg+DLOlMqxEYp | ||
| rOWqFw6xdWrNt6FYcRpbvPeO1R75ef86pmQzdIt8N87kvRpk1UMsXW8McqOCATUw | ||
| ggExMIHPBgNVHREEgccwgcSCCWxvY2FsaG9zdIcEfwAAAYI9Ki5ndGh1bGh1LWd0 | ||
| aHVsaHUtc2NoZWR1bGVyLXNpZGVjYXIuZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2Nh | ||
| bIIvKi5ndGh1bGh1LWd0aHVsaHUtc2NoZWR1bGVyLXNpZGVjYXIuZGVmYXVsdC5z | ||
| dmOCO2d0aHVsaHUtZ3RodWxodS1zY2hlZHVsZXItc2lkZWNhci5kZWZhdWx0LnN2 | ||
| Yy5jbHVzdGVyLmxvY2FshwQKAQAbMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEF | ||
| BQcDAjAdBgNVHQ4EFgQU+5CDmEm5uoIDQ+cMpwVIaLhVk1kwHwYDVR0jBBgwFoAU | ||
| gxWINVU1gdSulB3wwhFsYyT7ONQwCgYIKoZIzj0EAwIDSAAwRQIhALAeHhtuVmV9 | ||
| runXu4ssKoxuH5EbeeGaQPgSFn+rDzTbAiByGECW4rDlc7EtHtj3YoFBjDPIJ5RM | ||
| YLrD4+pcyXXXpA== | ||
| -----END CERTIFICATE----- |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||
| -----BEGIN EC PRIVATE KEY----- | ||||||||||||||||||||||
| MHcCAQEEIMEPRqDJaZ1/86TCIOWL9TxxIbh/y+LJPi7IUj7nZ1BooAoGCCqGSM49 | ||||||||||||||||||||||
| AwEHoUQDQgAEI9rucwma2o8H2eLPg+DLOlMqxEYprOWqFw6xdWrNt6FYcRpbvPeO | ||||||||||||||||||||||
| 1R75ef86pmQzdIt8N87kvRpk1UMsXW8Mcg== | ||||||||||||||||||||||
| -----END EC PRIVATE KEY----- | ||||||||||||||||||||||
|
Comment on lines
+1
to
+5
|
||||||||||||||||||||||
| -----BEGIN EC PRIVATE KEY----- | |
| MHcCAQEEIMEPRqDJaZ1/86TCIOWL9TxxIbh/y+LJPi7IUj7nZ1BooAoGCCqGSM49 | |
| AwEHoUQDQgAEI9rucwma2o8H2eLPg+DLOlMqxEYprOWqFw6xdWrNt6FYcRpbvPeO | |
| 1R75ef86pmQzdIt8N87kvRpk1UMsXW8Mcg== | |
| -----END EC PRIVATE KEY----- | |
| # Private key removed from source control. | |
| # | |
| # A valid EC private key must be provided securely at deploy/runtime, | |
| # for example via a secret manager, environment variable, or mounted | |
| # secret volume. Do NOT commit private keys to this repository. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -----BEGIN CERTIFICATE----- | ||
| MIIBkDCCATagAwIBAgIUCT9p4TDp3lc2Fwp+EfecoNsTVVkwCgYIKoZIzj0EAwIw | ||
| HTEbMBkGA1UEAwwSR3RodWxodS1Qcml2YXRlLUNBMB4XDTI2MDIyMzAzMTM0NVoX | ||
| DTI4MDIyMzAzMTM0NVowGjEYMBYGA1UEAwwPZ3RodWxodS1tYW5hZ2VyMFkwEwYH | ||
| KoZIzj0CAQYIKoZIzj0DAQcDQgAEc6EOY5fjmiO/ffE3yHcQBnDINRAE1GiBk0xc | ||
| eRny/6dELBcWO48TbSXw4uu6YD3zczk2gq5jKKSFM8WUUmSxVaNXMFUwEwYDVR0l | ||
| BAwwCgYIKwYBBQUHAwIwHQYDVR0OBBYEFHtY+SaE/DxkUtwY2AlWdk/PeoD4MB8G | ||
| A1UdIwQYMBaAFIMViDVVNYHUrpQd8MIRbGMk+zjUMAoGCCqGSM49BAMCA0gAMEUC | ||
| IHQugTGHFp986lKCEleY0aRgw5xU46eRgLOVhw20GzxDAiEAlk8BmsmPXQTrsIA9 | ||
| n9cGKdtJjHC91Lb/RTydrSH73w4= | ||
| -----END CERTIFICATE----- |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||||
| -----BEGIN EC PRIVATE KEY----- | ||||||||||||||||||||||||
| MHcCAQEEIMb/LITD2EAFHDfryINaeuh/cVgLDac36J4weDztgkOyoAoGCCqGSM49 | ||||||||||||||||||||||||
| AwEHoUQDQgAEc6EOY5fjmiO/ffE3yHcQBnDINRAE1GiBk0xceRny/6dELBcWO48T | ||||||||||||||||||||||||
| bSXw4uu6YD3zczk2gq5jKKSFM8WUUmSxVQ== | ||||||||||||||||||||||||
| -----END EC PRIVATE KEY----- | ||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
|
||||||||||||||||||||||||
| -----BEGIN EC PRIVATE KEY----- | |
| MHcCAQEEIMb/LITD2EAFHDfryINaeuh/cVgLDac36J4weDztgkOyoAoGCCqGSM49 | |
| AwEHoUQDQgAEc6EOY5fjmiO/ffE3yHcQBnDINRAE1GiBk0xceRny/6dELBcWO48T | |
| bSXw4uu6YD3zczk2gq5jKKSFM8WUUmSxVQ== | |
| -----END EC PRIVATE KEY----- | |
| # Private key removed from repository. | |
| # This file is intentionally left without key material. | |
| # A valid EC private key for the manager component must be generated | |
| # and provided securely at deployment time (for example via a secret | |
| # management system or deployment pipeline), and this path should not | |
| # be committed to version control. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/usr/bin/env bash | ||
| # gen-mtls-certs.sh — Generate a private CA and leaf certificates for Gthulhu mTLS. | ||
| # | ||
| # Usage: | ||
| # ./gen-mtls-certs.sh [OUTPUT_DIR] | ||
| # | ||
| # Environment variables: | ||
| # DM_EXTRA_SANS — Extra SANs for the DM server certificate (comma-separated). | ||
| # Example: DM_EXTRA_SANS="IP:10.0.0.5,DNS:my-dm.example.com" | ||
| # HELM_RELEASE — Helm release name (default: gthulhu). Used to build the | ||
| # headless-service wildcard DNS SAN. | ||
| # NAMESPACE — Kubernetes namespace (default: default). | ||
| # | ||
| # Outputs (all PEM-encoded): | ||
| # ca.crt / ca.key — Private CA | ||
| # dm.crt / dm.key — Decision Maker (DM sidecar) server certificate | ||
| # manager.crt / manager.key — Manager client certificate | ||
| # | ||
| # The DM server cert includes SANs for: | ||
| # - localhost / 127.0.0.1 (scheduler → sidecar, same pod) | ||
| # - *.<release>-gthulhu-scheduler-sidecar.<ns>.svc.cluster.local | ||
| # (manager → sidecar, cross-node via headless svc DNS) | ||
| # - Any extra SANs from DM_EXTRA_SANS | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| OUT="${1:-certs}" | ||
| mkdir -p "$OUT" | ||
|
|
||
| CA_DAYS=3650 # 10 years | ||
| LEAF_DAYS=730 # 2 years | ||
|
|
||
| RELEASE="${HELM_RELEASE:-gthulhu}" | ||
| NS="${NAMESPACE:-default}" | ||
| HEADLESS_SVC="${RELEASE}-gthulhu-scheduler-sidecar" | ||
|
|
||
| # Build DM SAN string | ||
| DM_SANS="DNS:localhost,IP:127.0.0.1" | ||
| DM_SANS="${DM_SANS},DNS:*.${HEADLESS_SVC}.${NS}.svc.cluster.local" | ||
| DM_SANS="${DM_SANS},DNS:*.${HEADLESS_SVC}.${NS}.svc" | ||
| DM_SANS="${DM_SANS},DNS:${HEADLESS_SVC}.${NS}.svc.cluster.local" | ||
| if [[ -n "${DM_EXTRA_SANS:-}" ]]; then | ||
| DM_SANS="${DM_SANS},${DM_EXTRA_SANS}" | ||
| fi | ||
|
|
||
| echo "==> DM certificate SANs: ${DM_SANS}" | ||
| echo "" | ||
|
|
||
| echo "==> Generating private CA …" | ||
| openssl ecparam -name prime256v1 -genkey -noout -out "$OUT/ca.key" | ||
| openssl req -new -x509 -days "$CA_DAYS" \ | ||
| -key "$OUT/ca.key" \ | ||
| -out "$OUT/ca.crt" \ | ||
| -subj "/CN=Gthulhu-Private-CA" | ||
|
|
||
| echo "==> Generating DM sidecar server certificate …" | ||
| openssl ecparam -name prime256v1 -genkey -noout -out "$OUT/dm.key" | ||
| openssl req -new \ | ||
| -key "$OUT/dm.key" \ | ||
| -out "$OUT/dm.csr" \ | ||
| -subj "/CN=gthulhu-decisionmaker" | ||
| openssl x509 -req -days "$LEAF_DAYS" \ | ||
| -in "$OUT/dm.csr" \ | ||
| -CA "$OUT/ca.crt" -CAkey "$OUT/ca.key" -CAcreateserial \ | ||
| -extfile <(printf "subjectAltName=${DM_SANS}\nextendedKeyUsage=serverAuth,clientAuth") \ | ||
| -out "$OUT/dm.crt" | ||
|
|
||
| echo "==> Generating Manager client certificate …" | ||
| openssl ecparam -name prime256v1 -genkey -noout -out "$OUT/manager.key" | ||
| openssl req -new \ | ||
| -key "$OUT/manager.key" \ | ||
| -out "$OUT/manager.csr" \ | ||
| -subj "/CN=gthulhu-manager" | ||
| openssl x509 -req -days "$LEAF_DAYS" \ | ||
| -in "$OUT/manager.csr" \ | ||
| -CA "$OUT/ca.crt" -CAkey "$OUT/ca.key" -CAcreateserial \ | ||
| -extfile <(printf "extendedKeyUsage=clientAuth") \ | ||
| -out "$OUT/manager.crt" | ||
|
|
||
| # Clean up CSRs | ||
| rm -f "$OUT"/*.csr "$OUT"/*.srl | ||
|
|
||
| echo "" | ||
| echo "✅ Certificates generated in $OUT/" | ||
| echo "" | ||
| echo "Files:" | ||
| ls -1 "$OUT" | ||
| echo "" | ||
| echo "To install with mTLS enabled:" | ||
| echo " helm install gthulhu ./gthulhu \\" | ||
| echo " --set mtls.enabled=true \\" | ||
| echo " --set-file mtls.ca.cert=$OUT/ca.crt \\" | ||
| echo " --set-file mtls.dm.cert=$OUT/dm.crt \\" | ||
| echo " --set-file mtls.dm.key=$OUT/dm.key \\" | ||
| echo " --set-file mtls.manager.cert=$OUT/manager.crt \\" | ||
| echo " --set-file mtls.manager.key=$OUT/manager.key" |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,7 @@ metadata: | |||||||||||||
| labels: | ||||||||||||||
| {{- include "gthulhu.labels" . | nindent 4 }} | ||||||||||||||
| app.kubernetes.io/component: scheduler | ||||||||||||||
| immutable: true | ||||||||||||||
|
Comment on lines
8
to
+9
|
||||||||||||||
| app.kubernetes.io/component: scheduler | |
| immutable: true | |
| app.kubernetes.io/component: scheduler | |
| {{- if .Values.scheduler.configMapImmutable }} | |
| immutable: true | |
| {{- end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The top-level install example uses
--set-file mtls.*=certs/*.crt|*.keywithout explicitly instructing users to generate fresh certificates, and the repository currently ships example certs/keys undergthulhu/certs. This makes it easy for operators to accidentally deploy with publicly-known test keys, which completely undermines mTLS authentication and allows impersonation of both clients and servers. Update this example to clearly require running./gen-mtls-certs.sh(or supplying custom certs) and avoid shipping reusable private keys in the repo so that no default, shared credentials exist.