From 0d9c44164f44f4e0f0f35acdc1f5ebb79be411ac Mon Sep 17 00:00:00 2001 From: "moosavi.smd" Date: Fri, 26 Apr 2024 19:50:52 +0330 Subject: [PATCH] Add mysql manifests --- .github/workflows/docker-image.yml | 2 +- app/dockerfile | 4 +- mysql/mysql.yaml | 70 ++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 mysql/mysql.yaml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 64cfb9f..afd0852 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -32,4 +32,4 @@ jobs: git config --global user.email 'actions@github.com' git add values.yaml git commit -m "Update values.yaml" - git push \ No newline at end of file + git push diff --git a/app/dockerfile b/app/dockerfile index 71bdfa1..209326d 100644 --- a/app/dockerfile +++ b/app/dockerfile @@ -1,3 +1,4 @@ +# First stage FROM golang:1.22 as builder WORKDIR /app @@ -7,7 +8,8 @@ RUN go mod download COPY . . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o myapp . -FROM alpine:latest +# Second Stage +FROM alpine:latest WORKDIR /root/ COPY --from=builder /app/myapp . diff --git a/mysql/mysql.yaml b/mysql/mysql.yaml new file mode 100644 index 0000000..e0302f1 --- /dev/null +++ b/mysql/mysql.yaml @@ -0,0 +1,70 @@ +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: mysql-pv + labels: + type: local +spec: + storageClassName: manual + capacity: + storage: 5Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/data" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-pv-claim +spec: + storageClassName: manual + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql +spec: + selector: + matchLabels: + app: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql + spec: + containers: + - image: mysql:8.0 + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + value: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: mysql-pv-claim +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql +spec: + ports: + - port: 3306 + selector: + app: mysql + clusterIP: None