Skip to content

Commit

Permalink
feat(infra): implement TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
ClayenKitten committed Nov 5, 2024
1 parent daec6b0 commit e2501be
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 32 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
steps:
- name: Deploy
uses: appleboy/[email protected]
env:
secrets: '{
"s3SecretKey": "${{ secrets.S3_SECRET_KEY }}",
"resendKey": "${{ secrets.RESEND_KEY }}"
}'
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
Expand All @@ -30,7 +35,8 @@ jobs:
--untar \
--destination /tmp
helm upgrade --install capydemia \
/tmp/capydemia/capydemia-helm/ \
/tmp/capydemia-helm/ \
--values /tmp/capydemia-helm/${{ vars.VALUES_FILE }} \
--namespace ${{ vars.NAMESPACE }} \
--create-namespace
--create-namespace \
--set-json 'secrets=${{ env.secrets }}'
26 changes: 26 additions & 0 deletions helm/templates/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: acme
spec:
acme:
email: [email protected]
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: acme
solvers:
- http01:
ingress:
class: traefik
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: capydemia-cert
spec:
secretName: capydemia-cert
dnsNames:
- "{{ .Values.domain }}"
issuerRef:
name: acme
kind: Issuer
12 changes: 6 additions & 6 deletions helm/templates/config-map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ metadata:
data:
NODE_ENV: {{ .Values.nodeEnv }}
DOMAIN: {{ .Values.domain }}
EMAIL_SENDER: {{ .Values.email.sender }}
RESEND_KEY: {{ .Values.email.resendKey }}
EMAIL_SENDER: {{ .Values.emailSender }}
RESEND_KEY: {{ .Values.secrets.resendKey }}
POSTGRES_HOST: capydemia-postgres-rw
S3_ENDPOINT: {{ .Values.s3.endpoint }}
S3_ACCESS_KEY: {{ .Values.s3.accessKey }}
S3_SECRET_KEY: {{ .Values.s3.secretKey }}
S3_BUCKET: {{ .Values.s3.bucket }}
S3_ENDPOINT: {{ .Values.s3Endpoint }}
S3_BUCKET: {{ .Values.s3Bucket }}
S3_ACCESS_KEY: {{ .Values.s3AccessKey }}
S3_SECRET_KEY: {{ .Values.secrets.s3SecretKey }}
49 changes: 34 additions & 15 deletions helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: capydemia-ingress
labels:
app.kubernetes.io/part-of: capydemia
spec:
rules:
- host: {{ .Values.domain }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: capydemia-web
port:
number: 3000
routes:
- kind: Rule
match: Host(`{{ .Values.domain }}`)
services:
- name: capydemia-web
port: 3000
tls:
secretName: capydemia-cert
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: capydemia-ingress-http
spec:
entryPoints: [web]
routes:
- kind: Rule
match: Host(`{{ .Values.domain }}`)
middlewares:
- name: redirect-https
services:
- name: capydemia-web
port: 3000
---
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: redirect-https
spec:
redirectScheme:
scheme: https
permanent: true
20 changes: 11 additions & 9 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ domain: capydemia.clayenkitten.dev
nodeEnv: production
dockerTag: main

email:
sender: "Capydemia <[email protected]>"
resendKey: example

s3:
endpoint: s3.timeweb.cloud
bucket: 4f267831-capydemia
accessKey: EURCS9IDGC9WM9V1TPMH
secretKey: example
emailSender: "Capydemia <[email protected]>"

s3Endpoint: s3.timeweb.cloud
s3Bucket: 4f267831-capydemia
s3AccessKey: EURCS9IDGC9WM9V1TPMH

# Secrets are set from deploy.yaml action and should never have non-example value there.
# When new secret is created, update deploy.yaml file.
secrets:
s3SecretKey: abcdefgh
resendKey: re_abcdefgh

0 comments on commit e2501be

Please sign in to comment.