This commit is contained in:
Santiago Lo Coco 2023-11-17 13:21:10 -03:00
parent d3e7ab1aa1
commit 4004c87e40
6 changed files with 36 additions and 17 deletions

4
helm/secrets.yaml Normal file
View File

@ -0,0 +1,4 @@
secrets:
username: "username"
password: "password1234"
database-url: "postgresql://username:password1234@exam-db/api_prod"

View File

@ -92,3 +92,10 @@ Search already generated TLS secret
{{- printf "%s" $value -}} {{- printf "%s" $value -}}
{{- end -}} {{- end -}}
{{- end -}} {{- end -}}
{{/*
Get host
*/}}
{{- define "exam.host" -}}
{{- default "kube-exam.local" .Values.tls.host -}}
{{- end -}}

View File

@ -5,16 +5,16 @@ metadata:
labels: labels:
{{- include "exam.labels" . | nindent 4 }} {{- include "exam.labels" . | nindent 4 }}
data: data:
password: {{ required "secrets.password is required" .Values.secrets.password {{- range $key, $val := .Values.secrets }}
| b64enc | quote }} {{- $envKey := $key }}
username: {{ required "secrets.username is required" .Values.secrets.username {{ $envKey }}: {{ required "$envKey" $val | b64enc | quote }}
| b64enc | quote }} {{- end }}
type: Opaque type: Opaque
--- ---
{{- if (include "exam.createTlsSecret" . ) }} {{- if (include "exam.createTlsSecret" . ) }}
{{- $secretName := printf "%s-crt" (include "exam.fullname" .) }} {{- $secretName := printf "%s-crt" (include "exam.fullname" .) }}
{{- $ca := genCA "ingress-ca" 365 }} {{- $ca := genCA "ingress-ca" 365 }}
{{- $fullname := "kube-exam.local" }} {{- $fullname := (include "exam.host" . ) }}
{{- $cert := genSignedCert $fullname nil nil 365 $ca }} {{- $cert := genSignedCert $fullname nil nil 365 $ca }}
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret

View File

@ -8,8 +8,12 @@ metadata:
"helm.sh/hook": test "helm.sh/hook": test
spec: spec:
containers: containers:
- name: wget - name: wget-client
image: busybox image: busybox
command: ['wget'] command: ['wget']
args: ['{{ include "exam.fullname" . }}:5000'] args: ['http://{{ include "exam.host" . }}']
- name: wget-api
image: busybox
command: ['wget']
args: ['http://{{ include "exam.host" $ }}/api/ping']
restartPolicy: Never restartPolicy: Never

View File

@ -1,5 +1,6 @@
tls: tls:
enabled: true enabled: true
host: kube.slc.ar
ingress: ingress:
className: "" className: ""
@ -8,7 +9,7 @@ ingress:
nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/use-regex: "true" nginx.ingress.kubernetes.io/use-regex: "true"
hosts: hosts:
- host: kube-exam.local - host: kube.slc.ar
paths: paths:
- path: /()(.*) - path: /()(.*)
pathType: ImplementationSpecific pathType: ImplementationSpecific
@ -21,7 +22,7 @@ ingress:
tls: tls:
- secretName: exam-crt - secretName: exam-crt
hosts: hosts:
- kube-exam.local - kube.slc.ar
services: services:
- api: - api:
@ -44,8 +45,9 @@ services:
type: ClusterIP type: ClusterIP
secrets: secrets:
password: "username" username: "username"
username: "password1234" password: "password1234"
database-url: "postgresql://username:password1234@exam-db/api_prod"
pvc: pvc:
class: local-storage class: local-storage
@ -58,17 +60,14 @@ deployments:
env: env:
nonsecrets: nonsecrets:
app-settings: src.config.ProductionConfig app-settings: src.config.ProductionConfig
database-url: postgresql://$(POSTGRES_USER):$(POSTGRES_PASS)@api-db/$(POSTGRES_DB)
port: "5000" port: "5000"
postgres-db: api-db
secrets: secrets:
postgres-password: password database-url: database-url
postgres-user: username
image: image:
repository: api repository: api
tag: prod tag: prod
port: 5000 port: 5000
replicas: 3 replicas: 1
- client: - client:
tier: "frontend" tier: "frontend"
name: "client" name: "client"
@ -83,7 +82,6 @@ deployments:
env: env:
nonsecrets: nonsecrets:
pgdata: /var/lib/postgresql/data/pgdata pgdata: /var/lib/postgresql/data/pgdata
postgresDb: db
secrets: secrets:
postgres-password: password postgres-password: password
postgres-user: username postgres-user: username

6
run.sh Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
minikube start
./build.sh -b
minikube addons enable ingress
helm install exam ./helm