diff --git a/k8s/aeris/templates/back/back.configmap.yaml b/k8s/aeris/templates/back/back.configmap.yaml new file mode 100644 index 0000000..18adef2 --- /dev/null +++ b/k8s/aeris/templates/back/back.configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: configmap-back +data: + WORKER_API_URL: http://api:8080/worker + WORKER_URL: http://worker:5000 + BACK_URL: https://aeris.westeurope.cloudapp.azure.com/api/ diff --git a/k8s/aeris/templates/back/back.deployment.yaml b/k8s/aeris/templates/back/back.deployment.yaml index ca291e9..fbf980a 100644 --- a/k8s/aeris/templates/back/back.deployment.yaml +++ b/k8s/aeris/templates/back/back.deployment.yaml @@ -1 +1,36 @@ -version \ No newline at end of file +apiVersion: apps/v1 +kind: Deployment +metadata: + name: aeris-back +spec: + replicas: 3 + selector: + matchLabels: + app: back + template: + metadata: + labels: + app: back + spec: + containers: + - name: back + imagePullPolicy: Always + image: {{ .Values.BACK_IMAGE }} + ports: + - containerPort: 8080 + volumeMounts: + - mountPath: "/cache" + name: postgres-volume-claim + envFrom: + - configMapRef: + name: configmap-postgres + - configMapRef: + name: configmap-back + - secretRef: + name: secret-postgres + - secretRef: + name: secret-back + volumes: + - name: postgres-volume-claim + persistentVolumeClaim: + claimName: volume-claim-back \ No newline at end of file diff --git a/k8s/aeris/templates/back/back.service.yaml b/k8s/aeris/templates/back/back.service.yaml index e69de29..bed46d6 100644 --- a/k8s/aeris/templates/back/back.service.yaml +++ b/k8s/aeris/templates/back/back.service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: api-service +spec: + type: LoadBalancer + # loadBalancerIP: "20.105.195.175" + selector: + app: back + ports: + - port: 8080 + targetPort: 8080 \ No newline at end of file diff --git a/k8s/aeris/templates/back/back.volume.yaml b/k8s/aeris/templates/back/back.volume.yaml new file mode 100644 index 0000000..9950b0e --- /dev/null +++ b/k8s/aeris/templates/back/back.volume.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: volume-back + labels: + type: local + name: volume-back +spec: + storageClassName: manual + capacity: + storage: 50M + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/data" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: volume-claim-back +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 50M \ No newline at end of file diff --git a/k8s/aeris/templates/back/back_cluster.service.yaml b/k8s/aeris/templates/back/back_cluster.service.yaml new file mode 100644 index 0000000..8b5e7e0 --- /dev/null +++ b/k8s/aeris/templates/back/back_cluster.service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: api +spec: + type: ClusterIP + # loadBalancerIP: "20.105.195.175" + selector: + app: back + ports: + - port: 8080 + targetPort: 8080 \ No newline at end of file diff --git a/k8s/aeris/templates/front/cluster-issuer.yaml b/k8s/aeris/templates/front/cluster-issuer.yaml new file mode 100644 index 0000000..c5019d6 --- /dev/null +++ b/k8s/aeris/templates/front/cluster-issuer.yaml @@ -0,0 +1,18 @@ +apiVersion: cert-manager.io/v1 +kind: ClusterIssuer +metadata: + name: letsencrypt +spec: + acme: + server: https://acme-v02.api.letsencrypt.org/directory + email: louis.auzuret@gmail.com + privateKeySecretRef: + name: letsencrypt + solvers: + - http01: + ingress: + class: nginx + podTemplate: + spec: + nodeSelector: + "kubernetes.io/os": linux diff --git a/k8s/aeris/templates/front/front.deployment.yaml b/k8s/aeris/templates/front/front.deployment.yaml index e69de29..70e8392 100644 --- a/k8s/aeris/templates/front/front.deployment.yaml +++ b/k8s/aeris/templates/front/front.deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: aeris-front +spec: + replicas: 3 + selector: + matchLabels: + app: front + template: + metadata: + labels: + app: front + spec: + containers: + - name: front + imagePullPolicy: Always + image: {{ .Values.FRONT_IMAGE }} + #args: ["/api"] + ports: + - containerPort: 80 \ No newline at end of file diff --git a/k8s/aeris/templates/front/front.ingress.yaml b/k8s/aeris/templates/front/front.ingress.yaml new file mode 100644 index 0000000..c11504a --- /dev/null +++ b/k8s/aeris/templates/front/front.ingress.yaml @@ -0,0 +1,52 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: aeris-ingress + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/rewrite-target: /$1 + nginx.ingress.kubernetes.io/use-regex: "true" + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - aeris.westeurope.cloudapp.azure.com + secretName: tls-secret + rules: + - host: aeris.westeurope.cloudapp.azure.com + http: + paths: + - path: /(.*) + pathType: Prefix + backend: + service: + name: front-cluster + port: + number: 80 +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: aeris-ingress-static + annotations: + kubernetes.io/ingress.class: nginx + nginx.ingress.kubernetes.io/rewrite-target: /static/$2 + nginx.ingress.kubernetes.io/use-regex: "true" + cert-manager.io/cluster-issuer: letsencrypt +spec: + tls: + - hosts: + - aeris.westeurope.cloudapp.azure.com + secretName: tls-secret + rules: + - host: aeris.westeurope.cloudapp.azure.com + http: + paths: + - path: + pathType: Prefix + backend: + service: + name: front-cluster + port: + number: 80 + path: /static(/|$)(.*) diff --git a/k8s/aeris/templates/front/front.service.yaml b/k8s/aeris/templates/front/front.service.yaml index e69de29..24d1f26 100644 --- a/k8s/aeris/templates/front/front.service.yaml +++ b/k8s/aeris/templates/front/front.service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: front-service +spec: + type: LoadBalancer + #loadBalancerIP: "13.81.34.213" + selector: + app: front + ports: + - port: 80 + targetPort: 80 \ No newline at end of file diff --git a/k8s/aeris/templates/front/front_cluster.service.yaml b/k8s/aeris/templates/front/front_cluster.service.yaml new file mode 100644 index 0000000..2a893eb --- /dev/null +++ b/k8s/aeris/templates/front/front_cluster.service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: front-cluster +spec: + type: ClusterIP + #loadBalancerIP: "13.81.34.213" + selector: + app: front + ports: + - port: 80 + targetPort: 80 \ No newline at end of file diff --git a/k8s/aeris/templates/postgres/postgres.deployment.yaml b/k8s/aeris/templates/postgres/postgres.deployment.yaml index 5687377..21c00ba 100644 --- a/k8s/aeris/templates/postgres/postgres.deployment.yaml +++ b/k8s/aeris/templates/postgres/postgres.deployment.yaml @@ -15,7 +15,7 @@ spec: spec: containers: - name: postgres - image: postgres:12 + image: {{ .Values.DB_IMAGE }} ports: - containerPort: 5432 hostPort: 5432 diff --git a/k8s/aeris/templates/worker/worker.deployment.yaml b/k8s/aeris/templates/worker/worker.deployment.yaml index e69de29..43c020f 100644 --- a/k8s/aeris/templates/worker/worker.deployment.yaml +++ b/k8s/aeris/templates/worker/worker.deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: aeris-worker +spec: + replicas: 3 + selector: + matchLabels: + app: worker + template: + metadata: + labels: + app: worker + spec: + restartPolicy: Always + containers: + - name: worker + imagePullPolicy: Always + image: {{ .Values.WORKER_IMAGE }} + ports: + - containerPort: 5000 + envFrom: + - secretRef: + name: secret-back + - configMapRef: + name: configmap-back \ No newline at end of file diff --git a/k8s/aeris/templates/worker/worker.service.yaml b/k8s/aeris/templates/worker/worker.service.yaml index e69de29..6a31656 100644 --- a/k8s/aeris/templates/worker/worker.service.yaml +++ b/k8s/aeris/templates/worker/worker.service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: worker +spec: + type: ClusterIP + selector: + app: worker + ports: + - port: 5000 + targetPort: 5000 \ No newline at end of file diff --git a/k8s/aeris/values.yaml b/k8s/aeris/values.yaml index 22fc3ad..f488ced 100644 --- a/k8s/aeris/values.yaml +++ b/k8s/aeris/values.yaml @@ -1,82 +1,4 @@ -# Default values for aeris. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - -replicaCount: 1 - -image: - repository: nginx - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" - -imagePullSecrets: [] -nameOverride: "" -fullnameOverride: "" - -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" - -podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - -service: - type: ClusterIP - port: 80 - -ingress: - enabled: false - className: "" - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - hosts: - - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - -nodeSelector: {} - -tolerations: [] - -affinity: {} +BACK_IMAGE: aeris.azurecr.io/back +FRONT_IMAGE: aeris.azurecr.io/front +WORKER_IMAGE: aeris.azurecr.io/worker +DB_IMAGE: aeris.azurecr.io/postgres \ No newline at end of file