diff --git a/templates/api/api-config.yml b/templates/api/api-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..5d37ada9d011a8d28e17881369a853d783a6db19 --- /dev/null +++ b/templates/api/api-config.yml @@ -0,0 +1,8 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api +data: + DB_ENDPOINT: {{ .Values.name }}-pg:{{ .Values.pg.port }} +{{- end }} \ No newline at end of file diff --git a/templates/api/api-deployment.yml b/templates/api/api-deployment.yml new file mode 100644 index 0000000000000000000000000000000000000000..3f2297e397da2d524acbde33a5cf18acf8960121 --- /dev/null +++ b/templates/api/api-deployment.yml @@ -0,0 +1,61 @@ +{{- if .Values.api.enabled }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-api + labels: + app: api +spec: + replicas: {{ .Values.api.replicaCount }} + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + imagePullSecrets: + - name: takima-school-registry + containers: + - name: api + image: {{ .Values.api.image.repository }}:{{ .Values.api.image.tag }} + resources: + requests: + memory: "192Mi" + cpu: "100m" + limits: + memory: "256Mi" + cpu: 2 + livenessProbe: + httpGet: + path: "/actuator/health/liveness" + port: 8080 + readinessProbe: + httpGet: + path: "/actuator/health/readiness" + port: 8080 + ports: + - containerPort: 8080 + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg + key: password + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg + key: username + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-pg + key: POSTGRES_DB + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: DB_ENDPOINT +{{- end }} \ No newline at end of file diff --git a/templates/api/api-ingress.yml b/templates/api/api-ingress.yml new file mode 100644 index 0000000000000000000000000000000000000000..9b4b7d76dba2a279386e12d09a33206718dfc92d --- /dev/null +++ b/templates/api/api-ingress.yml @@ -0,0 +1,25 @@ +{{- if .Values.api.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Values.name }}-api +spec: + ingressClassName: nginx + rules: + - host: {{ .Values.api.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Values.name }}-api + port: + number: 8080 + path: / + pathType: Prefix + {{- if .Values.api.ingress.tlsEnabled }} + tls: + - hosts: + - {{ .Values.api.ingress.host }} + secretName: app-wildcard + {{- end }} +{{- end }} \ No newline at end of file diff --git a/templates/api/api-service.yml b/templates/api/api-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..6b48384cfe9ec6831afc397484ec87cc8507f2e0 --- /dev/null +++ b/templates/api/api-service.yml @@ -0,0 +1,13 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-api +spec: + selector: + app: api + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 +{{- end }} \ No newline at end of file diff --git a/templates/database/pg-config.yml b/templates/database/pg-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..e6868649ac5221512e8f8e00366e0b075e793755 --- /dev/null +++ b/templates/database/pg-config.yml @@ -0,0 +1,9 @@ +{{- if .Values.pg.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-pg +data: + POSTGRES_DB: "cdb-db" + DB_PATH: "/var/lib/postgresql/data/pgdata" +{{- end }} \ No newline at end of file diff --git a/templates/database/pg-credentials.yml b/templates/database/pg-credentials.yml new file mode 100644 index 0000000000000000000000000000000000000000..c30b3592d51bad6d1ff66b5c0bf42a9cbf8247cd --- /dev/null +++ b/templates/database/pg-credentials.yml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.name }}-pg +type: Opaque +data: + username: cm9vdA== # root + password: cm9vdA== # root \ No newline at end of file diff --git a/templates/database/pg-deployment.yml b/templates/database/pg-deployment.yml new file mode 100644 index 0000000000000000000000000000000000000000..054e5b98be39ab7e82a00534cb6edfcbe1902de4 --- /dev/null +++ b/templates/database/pg-deployment.yml @@ -0,0 +1,58 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-pg + labels: + app: pg +spec: + replicas: {{ .Values.pg.replicaCount }} + selector: + matchLabels: + app: pg + template: + metadata: + labels: + app: pg + spec: + imagePullSecrets: + - name: takima-school-registry + volumes: + - name: pg-data + persistentVolumeClaim: + claimName: pg-db + containers: + - name: pg + image: {{ .Values.pg.image.repository }}:{{ .Values.pg.image.tag }} + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: pg-data + resources: + requests: + memory: "192Mi" + cpu: "100m" + limits: + memory: "256Mi" + cpu: 1 + ports: + - containerPort: 5432 + env: + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg + key: password + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg + key: username + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-pg + key: POSTGRES_DB + - name: PGDATA + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-pg + key: DB_PATH \ No newline at end of file diff --git a/templates/database/pg-pvc.yml b/templates/database/pg-pvc.yml new file mode 100644 index 0000000000000000000000000000000000000000..5cd2ea75a7acaefa81bbdd9788698b880ea21200 --- /dev/null +++ b/templates/database/pg-pvc.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Values.name }}-pg +spec: + storageClassName: gp2 + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + resources: + requests: + storage: 3Gi \ No newline at end of file diff --git a/templates/database/pg-service.yml b/templates/database/pg-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..792a71cfdfcde479e0d64863ec3c8513ff00ea78 --- /dev/null +++ b/templates/database/pg-service.yml @@ -0,0 +1,13 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-pg +spec: + selector: + app: pg + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 +{{- end }} \ No newline at end of file diff --git a/templates/front-config.yaml b/templates/www/front-config.yaml similarity index 100% rename from templates/front-config.yaml rename to templates/www/front-config.yaml diff --git a/templates/front-deployment.yaml b/templates/www/front-deployment.yaml similarity index 100% rename from templates/front-deployment.yaml rename to templates/www/front-deployment.yaml diff --git a/templates/front-ingress.yaml b/templates/www/front-ingress.yaml similarity index 95% rename from templates/front-ingress.yaml rename to templates/www/front-ingress.yaml index 297d8009a95c0a9e763a5d13ff971c8bd00a678c..746dbfc12725cce7e1a684a03575b24a4df9d480 100644 --- a/templates/front-ingress.yaml +++ b/templates/www/front-ingress.yaml @@ -13,7 +13,7 @@ spec: service: name: {{ .Values.name }}-front port: - number: 80 + number: 8080 path: / pathType: Prefix {{- if .Values.front.ingress.tlsEnabled }} diff --git a/templates/front-service.yaml b/templates/www/front-service.yaml similarity index 92% rename from templates/front-service.yaml rename to templates/www/front-service.yaml index 8031d1a9e190946393c8359877c954bfb10ec2d5..3bda6c5083814911a1169b7410284b571eeedf76 100644 --- a/templates/front-service.yaml +++ b/templates/www/front-service.yaml @@ -8,6 +8,6 @@ spec: app: front ports: - protocol: TCP - port: 80 + port: 8080 targetPort: 8080 {{- end }} \ No newline at end of file diff --git a/values.yaml b/values.yaml index abb218b8a0a45c3165e89549617f8f29264562c6..9bf9372bb9f5193ac80028d45ea125d820c6412e 100644 --- a/values.yaml +++ b/values.yaml @@ -4,9 +4,22 @@ # We have only done front for now name: cdb +pg: + enabled: true + port: 5432 + image: + repository: registry.takima.io/school/proxy/postgres + tag: latest + replicaCount: 1 + api: + enabled: true + image: + repository: registry.gitlab.com/takima-school/images/cdb/api + tag: latest + replicaCount: 1 ingress: - tlsEnabled: false + tlsEnabled: true host: api.bmaignan.takima.school front: @@ -16,5 +29,5 @@ front: tag: latest replicaCount: 1 ingress: - tlsEnabled: false + tlsEnabled: true host: www.bmaignan.takima.school \ No newline at end of file