Skip to content

Commit

Permalink
Merge pull request #151 from holaplex/mpw/gateway-certs
Browse files Browse the repository at this point in the history
add deployment of self-signed certs on local dev
  • Loading branch information
mpwsh authored Oct 3, 2023
2 parents bcd22b5 + a862a8a commit 533ca3e
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 2 deletions.
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

0 comments on commit 533ca3e

Please sign in to comment.