diff --git a/README.md b/README.md index 5940cad6f9888db50d61bd93c992077d9bf1a6ba..fa91f5189021aef74b2571c834060e28541b8a0f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ # Kubernetes +TP : http://school.pages.takima.io/kubernetes-01/k8s-trainees/ + +Dashboard : https://kube-learning.takima.school/#/workloads?namespace=llaiolo + +> Dashboard authentication token in ~/.kube/config + ## Helm Resource generation: @@ -8,4 +14,9 @@ Resource generation: Start resources: - helm install cdbapp ./ + helm upgrade --install cdbapp ./ + + +API : https://api.llaiolo.takima.school/computers + +front : https://helm.llaiolo.takima.school/computers \ No newline at end of file diff --git a/templates/api/api-config.yml b/templates/api/api-config.yml new file mode 100644 index 0000000000000000000000000000000000000000..28bfe81421aa9b902ef2c409ce93e9eb532c351a --- /dev/null +++ b/templates/api/api-config.yml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Values.name }}-api +data: + db-endpoint: {{ .Values.name }}-pg:5432 + db-name: cdb diff --git a/templates/api/api-deployment.yml b/templates/api/api-deployment.yml new file mode 100644 index 0000000000000000000000000000000000000000..969cb83170bcd2e8b673ba884d3f1f4f63990398 --- /dev/null +++ b/templates/api/api-deployment.yml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.name }}-api + labels: + app: api +spec: + replicas: 2 + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + imagePullSecrets: + - name: takima-school-registry + containers: + - name: api + image: registry.gitlab.com/takima-school/images/cdb/api:latest + ports: + - containerPort: 8080 + resources: + requests: + memory: "256Mi" + cpu: "500m" + limits: + memory: "512Mi" + cpu: "2" + env: + - name: DB_ENDPOINT + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: db-endpoint + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: cdb.{{ .Values.name }}-pg.credentials.postgresql.acid.zalan.do + key: password + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: cdb.{{ .Values.name }}-pg.credentials.postgresql.acid.zalan.do + key: username + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: {{ .Values.name }}-api + key: db-name + livenessProbe: + httpGet: + path: /actuator/health/liveness + port: 8080 + httpHeaders: + - name: Custom-Header + value: Awesome + initialDelaySeconds: 10 + periodSeconds: 3 + readinessProbe: + httpGet: + path: /actuator/health/readiness + port: 8080 + httpHeaders: + - name: Custom-Header + value: Awesome + initialDelaySeconds: 10 + periodSeconds: 3 + securityContext: + runAsUser: 1001 + runAsGroup: 1001 \ 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..299fcf27c1b5d59aa5877c7040cc704460210597 --- /dev/null +++ b/templates/api/api-ingress.yml @@ -0,0 +1,21 @@ +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: 80 + path: / + pathType: Prefix + tls: + - hosts: + - {{ .Values.api.ingress.host }} + secretName: app-wildcard diff --git a/templates/api/api-service.yml b/templates/api/api-service.yml new file mode 100644 index 0000000000000000000000000000000000000000..fa8881e09bf190f1294d55d05dafbbed633702a2 --- /dev/null +++ b/templates/api/api-service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.name }}-api +spec: + selector: + app: api + ports: + - protocol: TCP + port: 80 + targetPort: 8080 diff --git a/templates/database/pg-postgresql.yaml b/templates/database/pg-postgresql.yaml new file mode 100644 index 0000000000000000000000000000000000000000..f8c60cbf0626386a2161db84aa34412a6e2b59e4 --- /dev/null +++ b/templates/database/pg-postgresql.yaml @@ -0,0 +1,19 @@ +apiVersion: "acid.zalan.do/v1" +kind: postgresql +metadata: + name: {{ .Values.name }}-pg +spec: + teamId: {{ .Values.name }}-pg # le team id doit matcher le préfixe dans le metadata.name + volume: + size: 1Gi + numberOfInstances: 2 + users: + cdb: # database owner + - superuser + - createdb + databases: + cdb: cdb # dbname: owner + postgresql: + version: "14" + enableLogicalBackup: true + logicalBackupSchedule: 30 00 * * * \ 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 00374faa7d65f4b42cce95bb6cbb4c3d763ca132..a2c0ee01f6430167cfbbb0ec3faba23e1fb61d66 100644 --- a/values.yaml +++ b/values.yaml @@ -6,7 +6,7 @@ name: cdbapp api: ingress: - tlsEnabled: false + tlsEnabled: true host: api.llaiolo.takima.school front: @@ -16,5 +16,5 @@ front: tag: latest replicaCount: 1 ingress: - tlsEnabled: false + tlsEnabled: true host: helm.llaiolo.takima.school \ No newline at end of file