diff --git a/api/api-config.yml b/api/api-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..ad003a7dadb22fb747ae9bc0913fbf0523c601d2 --- /dev/null +++ b/api/api-config.yml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: api-config +data: + endpoint: database-service:5432 diff --git a/api/api-deployment.yml b/api/api-deployment.yml new file mode 100644 index 0000000000000000000000000000000000000000..a6a45d85fdce5973b9f0565c8ae35b5f9cf390e0 --- /dev/null +++ b/api/api-deployment.yml @@ -0,0 +1,50 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: api-deployment + name: api-deployment +spec: + replicas: 3 + selector: + matchLabels: + app: api-deployment + strategy: {} + template: + metadata: + labels: + app: api-deployment + spec: + containers: + - image: registry.gitlab.com/takima-school/images/cdb/api:latest + name: simple-app + resources: + limits: + memory: "720Mi" + cpu: "390m" + ports: + - containerPort: 8080 + env: + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: database-config + key: name + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: db-secret + key: user + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: api-config + key: endpoint + imagePullSecrets: + - name: takima-school-registry +status: {} diff --git a/api/api-ingress.yml b/api/api-ingress.yml new file mode 100644 index 0000000000000000000000000000000000000000..3ff7ab13333fd57b208d631419f0a1c5044729be --- /dev/null +++ b/api/api-ingress.yml @@ -0,0 +1,18 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: nginx + name: api-ingress +spec: + rules: + - host: api.asejourne.takima.school + http: + paths: + - backend: + service: + name: api-service + port: + number: 80 + path: / + pathType: Prefix diff --git a/api/api-service.yml b/api/api-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..3b52a4a81659df5048939333f3645b4380e4ee81 --- /dev/null +++ b/api/api-service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: api-service +spec: + selector: + app: api-deployment + ports: + - protocol: TCP + port: 80 + targetPort: 8080 diff --git a/pg-operator/operator.yml b/pg-operator/operator.yml new file mode 100644 index 0000000000000000000000000000000000000000..593b4288e2f82f34bbb8ee0dc2c7db93739d5d98 --- /dev/null +++ b/pg-operator/operator.yml @@ -0,0 +1,17 @@ +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: formation-cdb +spec: + 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" diff --git a/pg/database-service.yml b/pg/database-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..7d4b35cd1b2d24ec5424529b129a4f41122aac3c --- /dev/null +++ b/pg/database-service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: database-service +spec: + selector: + app: database-deployment + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 diff --git a/pg/database-stateful-set.yml b/pg/database-stateful-set.yml new file mode 100644 index 0000000000000000000000000000000000000000..d0ae1e425b7e05a046b9ffce7ba7a717e657c35b --- /dev/null +++ b/pg/database-stateful-set.yml @@ -0,0 +1,60 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + labels: + app: database-deployment + name: database-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: database-deployment + serviceName: database-service + template: + metadata: + labels: + app: database-deployment + spec: + containers: + - image: registry.takima.io/school/proxy/postgres:latest + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: pg-data + name: simple-database + resources: + limits: + memory: "512Mi" + cpu: "390m" + ports: + - containerPort: 5432 + env: + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: database-config + key: name + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: db-secret + key: user + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + - name: PGDATA + valueFrom: + configMapKeyRef: + name: database-config + key: db_path + imagePullSecrets: + - name: takima-school-registry + volumeClaimTemplates: + - metadata: + name: pg-data + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi diff --git a/pg/pg-config.yml b/pg/pg-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..d5274fbd852352a18f8a9076ba12d2115d9e7286 --- /dev/null +++ b/pg/pg-config.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: database-config +data: + name: "cdb-db" + db_path: "/var/lib/postgresql/data/pgdata" diff --git a/pg/pg-credentials.yml b/pg/pg-credentials.yml new file mode 100644 index 0000000000000000000000000000000000000000..642c1b0b72079ebdcaf33743f16362cc98c77d24 --- /dev/null +++ b/pg/pg-credentials.yml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: db-secret +type: Opaque +data: + user: ZGItdXNlcg== + password: ZGItcGFzc3dvcmQ= \ No newline at end of file diff --git a/pg/pg-pvc.yml b/pg/pg-pvc.yml new file mode 100644 index 0000000000000000000000000000000000000000..acc28fc26a0dbd0ff15635f972796ae3221d8156 --- /dev/null +++ b/pg/pg-pvc.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: pg-db +spec: + storageClassName: gp2 + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + resources: + requests: + storage: 3Gi \ No newline at end of file diff --git a/templates/front-config.yaml b/templates/front-config.yml similarity index 100% rename from templates/front-config.yaml rename to templates/front-config.yml diff --git a/templates/front-deployment.yaml b/templates/front-deployment.yml similarity index 100% rename from templates/front-deployment.yaml rename to templates/front-deployment.yml diff --git a/templates/front-ingress.yaml b/templates/front-ingress.yml similarity index 100% rename from templates/front-ingress.yaml rename to templates/front-ingress.yml diff --git a/templates/front-service.yaml b/templates/front-service.yml similarity index 100% rename from templates/front-service.yaml rename to templates/front-service.yml