Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deployment of self-signed certs on local dev #151

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/hub-gateway/Chart.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ dependencies:
repository: https://charts.apiseven.com
version: 1.3.1
digest: sha256:f5e4c06ee49ce8bdf2ee3cf997ece55fb80071c8e122fad43197d9be8ddd32f3
generated: "2023-04-22T00:12:14.986923-03:00"
generated: "2023-10-03T03:02:45.699841-03:00"
2 changes: 1 addition & 1 deletion charts/hub-gateway/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.23.10
version: 0.24.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
42 changes: 42 additions & 0 deletions charts/hub-gateway/templates/certs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- $domain := .Values.domain -}}
{{- $devMode := .Values.certificates.devMode -}}
{{- if .Values.certificates.deploy -}}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: hub-domains
namespace: ingress-apisix
spec:
dnsNames:
{{- with .Values.routes }}
{{- $usedHosts := "" -}}
{{- range . }}
{{- $currentHost := .host | default (printf "%s.%s" .subdomain $domain) | quote -}}
{{- if not (contains $currentHost $usedHosts) }}
- {{ $currentHost }}
{{- $usedHosts = print $usedHosts $currentHost -}}
{{- end }}
{{- end }}
{{- end }}
issuerRef:
kind: ClusterIssuer
group: cert-manager.io
{{- if $devMode }}
name: selfsigned
{{- else }}
name: letsencrypt-prod
{{- end }}
{{- if $devMode }}
isCA: true
commonName: selfsigned-ca
privateKey:
algorithm: ECDSA
size: 256
{{- end }}
secretName: hub-certificates
usages:
- digital signature
- key encipherment
duration: 2160h # 90d
renewBefore: 360h # 15d
{{- end }}
38 changes: 38 additions & 0 deletions charts/hub-gateway/templates/issuers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- $namespace := .Values.hubNamespace -}}
{{- $certEmail := .Values.certificates.email -}}
{{- $devMode := .Values.certificates.devMode -}}
{{- if $devMode }}
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: selfsigned
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: ca-issuer
namespace: {{ $namespace }}
spec:
ca:
secretName: hub-certificates
{{- else }}
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: {{ $certEmail }}
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- http01:
ingress:
class: apisix
- http01:
ingress:
class: nginx
{{- end }}
22 changes: 22 additions & 0 deletions charts/hub-gateway/templates/tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- $domain := .Values.domain -}}
{{- if .Values.certificates.deploy -}}
apiVersion: apisix.apache.org/v2
kind: ApisixTls
metadata:
name: hub-domains-tls
spec:
hosts:
{{- with .Values.routes }}
{{- $usedHosts := "" -}}
{{- range . }}
{{- $currentHost := .host | default (printf "%s.%s" .subdomain $domain) | quote -}}
{{- if not (contains $currentHost $usedHosts) }}
- {{ $currentHost }}
{{- $usedHosts = print $usedHosts $currentHost -}}
{{- end }}
{{- end }}
{{- end }}
secret:
name: hub-certificates
namespace: ingress-apisix
{{- end }}
5 changes: 5 additions & 0 deletions charts/hub-gateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ internalService:
networkPolicies:
enabled: false

certificates:
deploy: false
devMode: true
email: ""

routes:
- name: api
serviceName: federated-router
Expand Down