From fc1d4f5154bf5efed1d0e4df4b7da791726e5337 Mon Sep 17 00:00:00 2001 From: Marcin-Ramotowski Date: Mon, 5 May 2025 20:31:58 +0000 Subject: [PATCH] Added initial configuration to deploy user microservice --- deploy.yaml | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++ ingress.yaml | 20 ++++++++++ 2 files changed, 123 insertions(+) create mode 100644 deploy.yaml create mode 100644 ingress.yaml diff --git a/deploy.yaml b/deploy.yaml new file mode 100644 index 0000000..5683c0f --- /dev/null +++ b/deploy.yaml @@ -0,0 +1,103 @@ +--- +# Namespace (opcjonalnie) +apiVersion: v1 +kind: Namespace +metadata: + name: user-microservice +--- +# MySQL Deployment +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql + namespace: user-microservice +spec: + replicas: 1 + selector: + matchLabels: + app: mysql + template: + metadata: + labels: + app: mysql + spec: + containers: + - name: mysql + image: mysql:latest + env: + - name: MYSQL_USER + value: admin + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-password + key: MYSQL_PASSWORD + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-root-password + key: MYSQL_ROOT_PASSWORD + - name: MYSQL_DATABASE + value: user-microservice + ports: + - containerPort: 3306 + volumeMounts: + - name: mysql-pv + mountPath: /var/lib/mysql + volumes: + - name: mysql-pv + emptyDir: {} +--- +# MySQL Service +apiVersion: v1 +kind: Service +metadata: + name: db + namespace: user-microservice +spec: + ports: + - port: 3306 + selector: + app: mysql +--- +# API Deployment +apiVersion: apps/v1 +kind: Deployment +metadata: + name: api + namespace: user-microservice +spec: + replicas: 1 + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + containers: + - name: api + image: marcin00.azurecr.io/user-microservice:76a351710fffe2be1ae10471bc1a2f511f481126 + ports: + - containerPort: 80 + env: + - name: SQLALCHEMY_DATABASE_URI + valueFrom: + secretKeyRef: + name: sqlalchemy-database-uri + key: SQLALCHEMY_DATABASE_URI +--- +# API Service +apiVersion: v1 +kind: Service +metadata: + name: api + namespace: user-microservice +spec: + selector: + app: api + ports: + - port: 80 + targetPort: 80 + diff --git a/ingress.yaml b/ingress.yaml new file mode 100644 index 0000000..14fd25d --- /dev/null +++ b/ingress.yaml @@ -0,0 +1,20 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: user-microservice-ingress + namespace: user-microservice + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: todolist.marcin00.pl + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: api + port: + number: 80