diff --git a/charts/helm/checkmate/INSTALLATION.md b/charts/helm/checkmate/INSTALLATION.md index 4a2a120b5..06cf9f7b9 100644 --- a/charts/helm/checkmate/INSTALLATION.md +++ b/charts/helm/checkmate/INSTALLATION.md @@ -26,6 +26,7 @@ Edit `values.yaml` to update: - Old: `persistence.redisSize` → New: `persistence.redis.size` - Add: `persistence.mongo.storageClass` and `persistence.redis.storageClass` (leave empty for default) - Secrets under the `secrets` section (`JWT_SECRET`, email credentials, API keys, etc.) — replace all change_me values +- **For TLS/HTTPS**: Configure ingress TLS settings (see section below) ### 3. Deploy the Helm chart ```bash @@ -41,3 +42,75 @@ kubectl get svc ``` Once all pods are `Running` and `Ready`, you can access Checkmate via the configured ingress hosts. + +## Enabling TLS/HTTPS with cert-manager + +If you have [cert-manager](https://cert-manager.io/) installed in your cluster, you can enable automatic TLS certificate provisioning using Let's Encrypt or other certificate issuers. + +### Prerequisites +- cert-manager installed in your cluster +- A ClusterIssuer or Issuer configured (e.g., `letsencrypt-prod`) + +### Configuration + +Edit `values.yaml` to enable TLS (and update protocols to https): + +```yaml +client: + protocol: https + ingress: + enabled: true + host: checkmate.example.com + className: nginx + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + tls: + enabled: true + secretName: checkmate-client-tls + +server: + protocol: https + ingress: + enabled: true + host: checkmate.example.com + className: nginx + annotations: + cert-manager.io/cluster-issuer: "letsencrypt-prod" + tls: + enabled: true + secretName: checkmate-server-tls +``` + +### Alternative: Using --set flags + +You can also enable TLS during installation using Helm's `--set` flags: + +```bash +helm install checkmate ./charts/helm/checkmate \ + --set client.protocol=https \ + --set server.protocol=https \ + --set client.ingress.annotations."cert-manager\.io/cluster-issuer"="letsencrypt-prod" \ + --set client.ingress.tls.enabled=true \ + --set client.ingress.tls.secretName=checkmate-client-tls \ + --set server.ingress.annotations."cert-manager\.io/cluster-issuer"="letsencrypt-prod" \ + --set server.ingress.tls.enabled=true \ + --set server.ingress.tls.secretName=checkmate-server-tls +``` + +### Verification + +After deployment, cert-manager will automatically create the TLS secrets. You can verify the certificate status: + +```bash +# Check certificates +kubectl get certificates + +# Check certificate details +kubectl describe certificate checkmate-client-tls +kubectl describe certificate checkmate-server-tls + +# Verify the secrets were created +kubectl get secrets | grep checkmate-tls +``` + +The ingress will automatically use these secrets to enable HTTPS access to your Checkmate instance. diff --git a/charts/helm/checkmate/templates/_prechecks.yaml b/charts/helm/checkmate/templates/_prechecks.yaml deleted file mode 100644 index 870ab5c77..000000000 --- a/charts/helm/checkmate/templates/_prechecks.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if eq .Values.client.ingress.host "change_me" }} - {{- fail "client.ingress.host must be overridden and not set to 'change_me'" }} -{{- end }} - -{{- if eq .Values.server.ingress.host "change_me" }} - {{- fail "server.ingress.host must be overridden and not set to 'change_me'" }} -{{- end }} - -{{- $protocol := .Values.server.protocol }} -{{- if not (or (eq $protocol "http") (eq $protocol "https")) }} - {{- fail "server.protocol must be either 'http' or 'https'" }} -{{- end }} diff --git a/charts/helm/checkmate/templates/client-ingress.yaml b/charts/helm/checkmate/templates/client-ingress.yaml index 89e001e15..4fe126ea6 100644 --- a/charts/helm/checkmate/templates/client-ingress.yaml +++ b/charts/helm/checkmate/templates/client-ingress.yaml @@ -11,6 +11,12 @@ metadata: {{- end }} spec: ingressClassName: {{ .Values.client.ingress.className }} + {{- if .Values.client.ingress.tls.enabled }} + tls: + - hosts: + - {{ .Values.client.ingress.host }} + secretName: {{ default (printf "%s-client-tls" .Release.Name) .Values.client.ingress.tls.secretName }} + {{- end }} rules: - host: {{ .Values.client.ingress.host }} http: diff --git a/charts/helm/checkmate/templates/prechecks.yaml b/charts/helm/checkmate/templates/prechecks.yaml new file mode 100644 index 000000000..e2b9ec5c2 --- /dev/null +++ b/charts/helm/checkmate/templates/prechecks.yaml @@ -0,0 +1,48 @@ +{{- if eq .Values.client.ingress.host "change_me" }} + {{- fail "client.ingress.host must be overridden and not set to 'change_me'" }} +{{- end }} + +{{- if eq .Values.server.ingress.host "change_me" }} + {{- fail "server.ingress.host must be overridden and not set to 'change_me'" }} +{{- end }} + +{{- $serverProtocol := .Values.server.protocol }} +{{- if not (or (eq $serverProtocol "http") (eq $serverProtocol "https")) }} + {{- fail "server.protocol must be either 'http' or 'https'" }} +{{- end }} + +{{- $clientProtocol := .Values.client.protocol }} +{{- if not (or (eq $clientProtocol "http") (eq $clientProtocol "https")) }} + {{- fail "client.protocol must be either 'http' or 'https'" }} +{{- end }} + +{{/* Enforce protocol when TLS is enabled to avoid mixed-content */}} +{{- if and .Values.client.ingress.tls.enabled (ne $clientProtocol "https") }} + {{- fail "client.ingress.tls.enabled is true but client.protocol is not 'https'. Set client.protocol: https to avoid mixed content." }} +{{- end }} + +{{- if and .Values.server.ingress.tls.enabled (ne $serverProtocol "https") }} + {{- fail "server.ingress.tls.enabled is true but server.protocol is not 'https'. Set server.protocol: https to ensure correct API base URL." }} +{{- end }} + +{{/* If client runs on https, API must also be https to avoid mixed content */}} +{{- if and (eq $clientProtocol "https") (ne $serverProtocol "https") }} + {{- fail "client.protocol is 'https' but server.protocol is not. Set server.protocol: https to prevent browser mixed-content issues." }} +{{- end }} + +{{/* Fail early if TLS enabled without cert-manager annotations (cluster-issuer or issuer) */}} +{{- $cAnn := .Values.client.ingress.annotations | default dict }} +{{- $sAnn := .Values.server.ingress.annotations | default dict }} + +{{- $clientHasIssuer := or (hasKey $cAnn "cert-manager.io/cluster-issuer") (hasKey $cAnn "cert-manager.io/issuer") }} +{{- $serverHasIssuer := or (hasKey $sAnn "cert-manager.io/cluster-issuer") (hasKey $sAnn "cert-manager.io/issuer") }} + +{{- if and .Values.client.ingress.tls.enabled (not $clientHasIssuer) }} + {{- fail "client.ingress.tls.enabled is true but no cert-manager issuer annotation found. Add 'cert-manager.io/cluster-issuer' or 'cert-manager.io/issuer'." }} +{{- end }} + +{{- if and .Values.server.ingress.tls.enabled (not $serverHasIssuer) }} + {{- fail "server.ingress.tls.enabled is true but no cert-manager issuer annotation found. Add 'cert-manager.io/cluster-issuer' or 'cert-manager.io/issuer'." }} +{{- end }} + +{{/* Secret name can be omitted; we default to -client|server-tls in templates */}} diff --git a/charts/helm/checkmate/templates/server-ingress.yaml b/charts/helm/checkmate/templates/server-ingress.yaml index 6e2d0d4d6..34c9ac0dc 100644 --- a/charts/helm/checkmate/templates/server-ingress.yaml +++ b/charts/helm/checkmate/templates/server-ingress.yaml @@ -18,6 +18,12 @@ metadata: #nginx.ingress.kubernetes.io/cors-allow-credentials: "true"*/}} spec: ingressClassName: {{ .Values.server.ingress.className }} + {{- if .Values.server.ingress.tls.enabled }} + tls: + - hosts: + - {{ .Values.server.ingress.host }} + secretName: {{ default (printf "%s-server-tls" .Release.Name) .Values.server.ingress.tls.secretName }} + {{- end }} rules: - host: {{ .Values.server.ingress.host }} http: diff --git a/charts/helm/checkmate/values.yaml b/charts/helm/checkmate/values.yaml index a1a1527de..9a586dd54 100644 --- a/charts/helm/checkmate/values.yaml +++ b/charts/helm/checkmate/values.yaml @@ -7,6 +7,15 @@ client: host: change_me className: nginx annotations: {} + # Example annotations for cert-manager: + # annotations: + # cert-manager.io/cluster-issuer: "letsencrypt-prod" + tls: + enabled: false + # secretName: {{ .Release.Name }}-client-tls # Optional; defaults to -client-tls if omitted + # Note: when enabling TLS, also set client.protocol: https and add + # a cert-manager issuer annotation (e.g. cert-manager.io/cluster-issuer: "letsencrypt-prod"). + # The secret will be automatically created by cert-manager when using the cert-manager.io/cluster-issuer annotation server: image: ghcr.io/bluewave-labs/checkmate-backend:v3.2.0 @@ -17,6 +26,15 @@ server: host: change_me className: nginx annotations: {} + # Example annotations for cert-manager: + # annotations: + # cert-manager.io/cluster-issuer: "letsencrypt-prod" + tls: + enabled: false + # secretName: {{ .Release.Name }}-server-tls # Optional; defaults to -server-tls if omitted + # Note: when enabling TLS, also set server.protocol: https and add + # a cert-manager issuer annotation (e.g. cert-manager.io/cluster-issuer: "letsencrypt-prod"). + # The secret will be automatically created by cert-manager when using the cert-manager.io/cluster-issuer annotation redis: enabled: false