diff --git a/templates/api-config.yaml b/templates/api/api-config.yaml similarity index 56% rename from templates/api-config.yaml rename to templates/api/api-config.yaml index 8f6b21236cd94c0b11a9dd18fefc2de54d0cc490..b20aafd3a00086db5f5a6357f6c445bef72858f2 100644 --- a/templates/api-config.yaml +++ b/templates/api/api-config.yaml @@ -1,7 +1,9 @@ +{{- if .Values.api.enabled }} apiVersion: v1 kind: ConfigMap metadata: name: api-config data: DB_ENDPOINT: "postgres:5432" - DB_NAME: "cdb-db" + DB_NAME: "{{ .Values.name }}-db" +{{- end}} diff --git a/templates/api-deployment.yaml b/templates/api/api-deployment.yaml similarity index 92% rename from templates/api-deployment.yaml rename to templates/api/api-deployment.yaml index ddccf57e2a96ff2162922778d06875b393a2f6a0..dd06696e18885826f92266659ec35bf38af7b292 100644 --- a/templates/api-deployment.yaml +++ b/templates/api/api-deployment.yaml @@ -1,3 +1,4 @@ +{{- if .Values.api.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +6,7 @@ metadata: labels: app: api spec: - replicas: 1 + replicas: {{ .Values.api.replicaCount }} selector: matchLabels: app: api @@ -21,7 +22,7 @@ spec: - name: takima-school-registry containers: - name: api - image: registry.gitlab.com/takima-school/images/cdb/api:latest + image: {{ .Values.api.image.repository }}:{{ .Values.api.image.tag }} resources: requests: memory: "192M" @@ -76,3 +77,4 @@ spec: secretKeyRef: name: pg-credentials # Nom du secret key: pg_password +{{- end}} \ No newline at end of file diff --git a/templates/api-ingress.yaml b/templates/api/api-ingress.yaml similarity index 68% rename from templates/api-ingress.yaml rename to templates/api/api-ingress.yaml index c8f7f5c598d2886cef29ae4e2436e0560755a3dc..57a8b3a7636e39ffbbe4b87ba33b1b8b6e9e9f8e 100644 --- a/templates/api-ingress.yaml +++ b/templates/api/api-ingress.yaml @@ -1,3 +1,4 @@ +{{- if .Values.api.enabled }} apiVersion: networking.k8s.io/v1 kind: Ingress metadata: @@ -6,7 +7,7 @@ metadata: name: api spec: rules: - - host: api.lherve.takima.school + - host: {{ .Values.api.ingress.host }} http: paths: - backend: @@ -18,5 +19,6 @@ spec: pathType: Prefix tls: - hosts: - - api.lherve.takima.school - secretName: app-wildcard \ No newline at end of file + - {{ .Values.api.ingress.host }} + secretName: app-wildcard +{{- end}} \ No newline at end of file diff --git a/templates/api-service.yaml b/templates/api/api-service.yaml similarity index 66% rename from templates/api-service.yaml rename to templates/api/api-service.yaml index ab7f8b94b9b8d3e757f3c2168b140c615f58e9f6..2cc25a08b4aafcb408e56655b7800c4a0297197e 100644 --- a/templates/api-service.yaml +++ b/templates/api/api-service.yaml @@ -1,3 +1,4 @@ +{{- if .Values.api.enabled }} apiVersion: v1 kind: Service metadata: @@ -8,4 +9,5 @@ spec: ports: - protocol: TCP port: 80 - targetPort: 8080 \ No newline at end of file + targetPort: 8080 +{{- end }} \ No newline at end of file diff --git a/templates/pg-config.yaml b/templates/database/pg-config.yaml similarity index 57% rename from templates/pg-config.yaml rename to templates/database/pg-config.yaml index 7f993a814ecc754e3164312ce679b34359bb2214..f768aeee20e3e371d9cf89bb1bb3baa77ff4ebcf 100644 --- a/templates/pg-config.yaml +++ b/templates/database/pg-config.yaml @@ -1,7 +1,9 @@ +{{- if .Values.database.enabled }} apiVersion: v1 kind: ConfigMap metadata: name: pg-config data: - db_name: "cdb-db" + db_name: "{{ .Values.name }}-db" db_path: "/var/lib/postgresql/data/pgdata" +{{- end}} diff --git a/templates/database/pg-credentials.yaml b/templates/database/pg-credentials.yaml new file mode 100644 index 0000000000000000000000000000000000000000..a44056126445454c76202a368bf94b3d5f306c15 --- /dev/null +++ b/templates/database/pg-credentials.yaml @@ -0,0 +1,10 @@ +{{- if .Values.database.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: pg-credentials +type: Opaque +data: + pg_username: {{ .Values.database.credentials.username }} + pg_password: {{ .Values.database.credentials.password }} +{{- end }} \ No newline at end of file diff --git a/templates/pg-deployment.yaml b/templates/database/pg-deployment.yaml similarity index 87% rename from templates/pg-deployment.yaml rename to templates/database/pg-deployment.yaml index 08684fb93f647179ecdd66dc15f8d201247a4fe1..37727b01f2a3a4f72f664b7250e909e7b62e16b5 100644 --- a/templates/pg-deployment.yaml +++ b/templates/database/pg-deployment.yaml @@ -1,3 +1,4 @@ +{{- if .Values.database.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -5,7 +6,7 @@ metadata: labels: app: pg spec: - replicas: 1 + replicas: {{ .Values.database.replicaCount }} selector: matchLabels: app: pg @@ -16,7 +17,7 @@ spec: spec: containers: - name: postgres - image: registry.takima.io/school/proxy/postgres:latest + image: {{ .Values.database.image.repository }}:{{ .Values.database.image.tag }} ports: - containerPort: 80 env: @@ -42,3 +43,4 @@ spec: key: pg_password # nom de la clef dans le secret contenant le password imagePullSecrets: - name: takima-school-registry +{{- end }} \ No newline at end of file diff --git a/templates/pg-service.yaml b/templates/database/pg-service.yaml similarity index 71% rename from templates/pg-service.yaml rename to templates/database/pg-service.yaml index db304c6fc445262f69aad6f22a9980aaccefc6b8..8fdacbeb33deb72fb349423eed270b6b5894c0f4 100644 --- a/templates/pg-service.yaml +++ b/templates/database/pg-service.yaml @@ -1,3 +1,4 @@ +{{- if .Values.database.enabled }} apiVersion: v1 kind: Service metadata: @@ -9,4 +10,5 @@ spec: ports: - port: 5432 selector: - app: pg \ No newline at end of file + app: pg +{{- end}} \ No newline at end of file diff --git a/templates/front-config.yaml b/templates/front/front-config.yaml similarity index 100% rename from templates/front-config.yaml rename to templates/front/front-config.yaml diff --git a/templates/front-deployment.yaml b/templates/front/front-deployment.yaml similarity index 100% rename from templates/front-deployment.yaml rename to templates/front/front-deployment.yaml diff --git a/templates/front-ingress.yaml b/templates/front/front-ingress.yaml similarity index 100% rename from templates/front-ingress.yaml rename to templates/front/front-ingress.yaml diff --git a/templates/front-service.yaml b/templates/front/front-service.yaml similarity index 100% rename from templates/front-service.yaml rename to templates/front/front-service.yaml diff --git a/templates/pg-credentials.yaml b/templates/pg-credentials.yaml deleted file mode 100644 index 0e80e90d395c43f714fd40f39b7a15d0d65f2423..0000000000000000000000000000000000000000 --- a/templates/pg-credentials.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: pg-credentials -type: Opaque -data: - pg_username: YWRtaW4= # user: admin - pg_password: dGVzdDEyMyo= # pwd: test123* diff --git a/values.yaml b/values.yaml index 9b2f23c13f8de5e8bd88b65c4ebdb9bc715a00aa..3de0c5fe449bcb4cc7e17c59b20bb282de7a8bec 100644 --- a/values.yaml +++ b/values.yaml @@ -4,12 +4,22 @@ # We have only done front for now name: cdb +database: + enabled: true + image: + repository: registry.takima.io/school/proxy/postgres + tag: latest + replicaCount: 1 + credentials: + username: YWRtaW4= # user: admin + password: dGVzdDEyMyo= # pwd: test123* + api: enabled: true image: repository: registry.gitlab.com/takima-school/images/cdb/api tag: latest - replicaCount: 1 + replicaCount: 2 ingress: tlsEnabled: true host: api.lherve.takima.school @@ -22,4 +32,4 @@ front: replicaCount: 1 ingress: tlsEnabled: true - host: cdb.lherve.takima.school \ No newline at end of file + host: www.lherve.takima.school \ No newline at end of file