diff --git a/templates/api/api-config.yaml b/templates/api/api-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..99f6db2fd405e0ac8025be8b00a09b0dd6bcb361 --- /dev/null +++ b/templates/api/api-config.yaml @@ -0,0 +1,9 @@ +{{- if .Values.api.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api +data: + DB_ENDPOINT: "{{ .Values.api.config.dbEndpoint }}:5432" + POSTGRES_DB: "cdb" +{{- end }} \ No newline at end of file diff --git a/templates/api/api-deployment.yaml b/templates/api/api-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c3aa4695d460351bcffabb2254c6dbb9ad13167f --- /dev/null +++ b/templates/api/api-deployment.yaml @@ -0,0 +1,56 @@ +{{- 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.front.image.tag }} + imagePullPolicy: Always + ports: + - containerPort: 8080 + resources: + requests: + memory: "192Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "1" + + env: + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: cdb.cdb-db.credentials.postgresql.acid.zalan.do # Nom du secret + key: username # nom de la clef dans le config map + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: cdb.cdb-db.credentials.postgresql.acid.zalan.do # Nom du secret + key: password + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: DB_ENDPOINT + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: POSTGRES_DB +{{- end }} \ No newline at end of file diff --git a/templates/api/api-ingress.yaml b/templates/api/api-ingress.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e47997103d9deb965958153a851811b27f4239d9 --- /dev/null +++ b/templates/api/api-ingress.yaml @@ -0,0 +1,26 @@ +{{- if .Values.api.enabled }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + name: {{ .Values.name }}-api +spec: + rules: + - host: {{ .Values.api.ingress.host }} + http: + paths: + - backend: + service: + name: {{ .Values.name }}-api + port: + number: 80 + 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.yaml b/templates/api/api-service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..78d141ca7f7270727ae0c2a02f4cada048ecddfe --- /dev/null +++ b/templates/api/api-service.yaml @@ -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: 80 + targetPort: 8080 +{{- end }} \ No newline at end of file diff --git a/templates/db/db-deployment.yaml b/templates/db/db-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d9fafdda851ef7e544a84c90caaddaa012e97873 --- /dev/null +++ b/templates/db/db-deployment.yaml @@ -0,0 +1,22 @@ +{{- if .Values.db.enabled }} +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: {{ .Values.name }}-db + labels: + app: db +spec: + replicas: {{ .Values.db.replicaCount }} + teamId: "formation" # le team id doit matcher le préfixe dans le metadata.name, ici formation + volume: + size: 1Gi + numberOfInstances: 2 + users: + cdb: # database owner + - superuser + - createdb + databases: + cdb: cdb # dbname: owner + postgresql: + version: "14" +{{- 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/values.yaml b/values.yaml index 9ab42efacd88ffc744ad5862da8aa53e9b1042bf..1600368bb1011ad06a5b1451f7e941104c0a8bfd 100644 --- a/values.yaml +++ b/values.yaml @@ -4,10 +4,24 @@ # We have only done front for now name: cdb +db: + enabled: true + 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: 3 ingress: - tlsEnabled: false - host: api.to-replace.takima.school + tlsEnabled: true + host: api.lzablit.takima.school + config: + dbEndpoint: cdb-db front: enabled: true @@ -16,5 +30,5 @@ front: tag: latest replicaCount: 1 ingress: - tlsEnabled: false - host: www.to-replace.takima.school \ No newline at end of file + tlsEnabled: true + host: www.lzablit.takima.school \ No newline at end of file