diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..849ddff3b7ec917b5f4563e9a6d3ea63ea512a70 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dist/ diff --git a/templates/api-config.yaml b/templates/api-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..85da321954b9194673cfb676e7b744064ebf8370 --- /dev/null +++ b/templates/api-config.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api-config +data: + DB_ENDPOINT: {{ .Values.name }}-pg:{{ .Values.pg.port }} \ No newline at end of file diff --git a/templates/api-deployment.yaml b/templates/api-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..6fe51ddece61a21258370c56fd7544a942a7794f --- /dev/null +++ b/templates/api-deployment.yaml @@ -0,0 +1,53 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + app: api + name: {{ .Values.name }}-api +spec: + replicas: {{ .Values.api.replicaCount }} + selector: + matchLabels: + app: api + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + app: api + spec: + containers: + - image: {{ .Values.api.image.repository }}:{{ .Values.api.image.tag }} + name: api + resources: + limits: + memory: 256M + cpu: 1 + requests: + memory: 192M + cpu: 100m + env: + - name: DB_ENDPOINT # Vrai key de la variable d'env. Peut-être différent de la valeur dans le configmap + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api-config # Nom du configmap + key: DB_ENDPOINT # nom de la clef dans le configmap + - name: POSTGRES_DB # Vrai key de la variable d'env. Peut-être différent de la valeur dans le configmap + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-pg-config + key: POSTGRES_DB + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg-credentials + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg-credentials + key: POSTGRES_PASSWORD + imagePullSecrets: + - name: takima-school-registry # à variabiliser +status: {} diff --git a/templates/api-ingress.yaml b/templates/api-ingress.yaml new file mode 100644 index 0000000000000000000000000000000000000000..5511ed189923b966e55dd2f171374d5825f64dfe --- /dev/null +++ b/templates/api-ingress.yaml @@ -0,0 +1,18 @@ +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: {{ .Values.api.port }} + path: / + pathType: Prefix diff --git a/templates/api-service.yaml b/templates/api-service.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1b42e6e8306cee9b978125cd1eabb9927f72a4e9 --- /dev/null +++ b/templates/api-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-api +spec: + selector: + app: api + ports: + - protocol: TCP + port: {{ .Values.api.port }} + targetPort: {{ .Values.api.targetPort }} diff --git a/templates/pg-config.yaml b/templates/pg-config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..fc7c694ddcab7c070568f21c4106ef7aef201eb4 --- /dev/null +++ b/templates/pg-config.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-pg-config +data: + POSTGRES_DB: {{ .Values.name }}-db + db_path: "/var/lib/postgresql/data/pgdata" \ No newline at end of file diff --git a/templates/pg-credentials.yaml b/templates/pg-credentials.yaml new file mode 100644 index 0000000000000000000000000000000000000000..756e91802fc027b806d394a874e0b39e653800c3 --- /dev/null +++ b/templates/pg-credentials.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.name }}-pg-credentials +type: Opaque +data: + POSTGRES_USER: YXJha290b3Zhbw== + POSTGRES_PASSWORD: MTIzNDU2 \ No newline at end of file diff --git a/templates/pg-deployment.yaml b/templates/pg-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..78280da504b8f6eedd5916cbf411ebdc799a1a41 --- /dev/null +++ b/templates/pg-deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + creationTimestamp: null + labels: + app: pg + name: {{ .Values.name }}-pg +spec: + replicas: {{ .Values.pg.replicaCount }} + selector: + matchLabels: + app: pg + strategy: {} + template: + metadata: + creationTimestamp: null + labels: + app: pg + spec: + containers: + - image: {{ .Values.pg.image.repository }}:{{ .Values.pg.image.tag }} + name: postgres + resources: {} + env: + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-pg-config + key: POSTGRES_DB + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg-credentials + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.name }}-pg-credentials + key: POSTGRES_PASSWORD + - name: PGDATA + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-pg-config + key: db_path + volumeMounts: + - mountPath: /var/lib/postgresql/data + name: {{ .Values.name }}-pg-data + imagePullSecrets: + - name: takima-school-registry + volumes: + - name: {{ .Values.name }}-pg-data + persistentVolumeClaim: + claimName: {{ .Values.name }}-pg +status: {} diff --git a/templates/pg-pvc.yaml b/templates/pg-pvc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..1ebf06bdf69f98fcb8d9739bb3e3f35827f66a00 --- /dev/null +++ b/templates/pg-pvc.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ .Values.name }}-pg +spec: + storageClassName: gp2 + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + resources: + requests: + storage: 3Gi diff --git a/templates/pg-service.yml b/templates/pg-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..ada173ca9f37adcfff3f91f950cebf65e8e3f799 --- /dev/null +++ b/templates/pg-service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-pg +spec: + selector: + app: pg + ports: + - protocol: TCP + port: {{ .Values.pg.port }} + targetPort: {{ .Values.pg.targetPort }} diff --git a/values.yaml b/values.yaml index 9ab42efacd88ffc744ad5862da8aa53e9b1042bf..4f00f1aacd78e3789a004a1299c85408f00eb90c 100644 --- a/values.yaml +++ b/values.yaml @@ -7,7 +7,13 @@ name: cdb api: ingress: tlsEnabled: false - host: api.to-replace.takima.school + host: api.cdb.arakotovao.takima.school + replicaCount: 1 + image: + repository: registry.gitlab.com/takima-school/images/cdb/api + tag: latest + port: 80 + targetPort: 8080 front: enabled: true @@ -17,4 +23,12 @@ front: replicaCount: 1 ingress: tlsEnabled: false - host: www.to-replace.takima.school \ No newline at end of file + host: www.arakotovao.takima.school + +pg: + image: + repository: registry.takima.io/school/proxy/postgres + tag: latest + replicaCount: 1 + port: 80 + targetPort: 5432 \ No newline at end of file