Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eks release workflow #405

Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dc57b2c
eks release workflow
Delyc Dec 11, 2024
6ff4ab2
changing cluster location
Delyc Dec 11, 2024
f299bb9
fix: fix identation
Delyc Dec 13, 2024
61a1d3a
deploy: publishing to eks cluster
Delyc Dec 18, 2024
a747489
deploy: publishing to eks cluster
Delyc Dec 18, 2024
b892d82
fix: cjanging eks path
Delyc Dec 18, 2024
5c163d8
deploy: publishing to eks cluster
Delyc Dec 18, 2024
fc9fd96
deploy: publishing to eks cluster
Delyc Dec 18, 2024
10d1565
deploy: publishing to eks cluster
Delyc Dec 18, 2024
29a34ff
deploy: publishing to eks cluster
Delyc Dec 18, 2024
299368c
deploy: publishing to eks cluster
Delyc Dec 18, 2024
a7f5939
deploy: publishing to eks cluster
Delyc Dec 18, 2024
36c7d99
deploy: publishing to eks cluster
Delyc Dec 18, 2024
30d42e5
deploy: publishing to eks cluster
Delyc Dec 18, 2024
fe147d4
kubectl config
Delyc Dec 18, 2024
0b2a48b
kubectl config
Delyc Dec 18, 2024
b59a040
kubectl config
Delyc Dec 18, 2024
6ee5d8c
kubectl config
Delyc Dec 18, 2024
a1bcb98
kubectl deploy
Delyc Dec 19, 2024
a5578a1
running seeding command in workflow
Delyc Dec 19, 2024
b0fd527
running seeding command in workflow
Delyc Dec 19, 2024
86d3f6b
running seeding command in workflow
Delyc Dec 19, 2024
5e85dfb
running seeding command in workflow
Delyc Dec 19, 2024
a2978de
running seeding command in workflow
Delyc Dec 19, 2024
e756687
restarting pods in worflow
Delyc Dec 19, 2024
d2ec53f
restarting pods in worflow
Delyc Dec 19, 2024
93ecfaf
restarting pods in worflow
Delyc Dec 19, 2024
6f6b37f
restarting pods in worflow
Delyc Dec 19, 2024
15ac246
fix: formatting and indentation
Delyc Dec 19, 2024
081d422
fix: formatting and indentation
Delyc Dec 19, 2024
01879be
fix: formatting and indentation
Delyc Dec 19, 2024
ab76e41
combining publishing to dockerhub and deploying to eks
Delyc Dec 19, 2024
dd17915
combining publishing to dockerhub and deploying to eks
Delyc Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/release-publish-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Deploy to EKS

on:
release:
types:
- published
workflow_dispatch:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this as a separate workflow won't work. If a new release gets created this will run immediately. However, the deploy to DockerHub job takes around 1h usually. So, we Pull the Docker image before the new one is even available.

Could you instead, move the deploy job into the already existing release-publish-dockerhub.yaml, also rename it to deploy-demo. Then please add a need (see here) to depend on the release-publish


jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-central-1

- name: Setup kubectl
uses: azure/setup-kubectl@v3
with:
version: latest

- name: Authenticate kubectl with EKS
run: |
aws eks update-kubeconfig --region eu-central-1 --name mpm

- name: Deploy to EKS
run: |
if kubectl get deployment mpm-backend; then
kubectl rollout restart deployment/mpm-backend
else
echo "mpm-backend deployment does not exist, applying initial deployment..."
kubectl apply -f k8s/deployments/mpm-backend.yaml
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the if/else here. We always want to run both apply and rollout restart.

  • The apply is needed such that changes to the kubernetes yaml files are picked up. Which shouldn't happen that often.
  • The rollout restart is needed such that the new image gets deployed.


if kubectl get deployment mpm-frontend; then
kubectl rollout restart deployment/mpm-frontend
else
echo "mpm-frontend deployment does not exist, applying initial deployment..."
kubectl apply -f k8s/deployments/mpm-frontend.yaml
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a step that runs apply on services.

58 changes: 47 additions & 11 deletions k8s/deployments/mpm-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,34 @@ kind: Deployment
metadata:
name: mpm-backend
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, please do not change this file.

app: mpm-backend
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: mpm-backend
spec:
containers:
- name: mpm-backend
image: enaccess/micropowermanager-backend:latest
imagePullPolicy: Always
ports:
- containerPort: 80
env:
- env:
- name: APP_NAME
value: MicroPowerManager
- name: APP_ENV
value: demo
- name: APP_KEY
valueFrom:
secretKeyRef:
name: mpm-secrets
key: APP_KEY
name: mpm-secrets
- name: APP_DEBUG
value: "false"
- name: MPM_LOAD_DEMO_DATA
Expand All @@ -37,32 +40,65 @@ spec:
- name: DB_HOST
valueFrom:
secretKeyRef:
name: mpm-secrets
key: DB_HOST
name: mpm-secrets
- name: DB_PORT
value: "3306"
- name: DB_DATABASE
value: micro_power_manager
- name: DB_USERNAME
valueFrom:
secretKeyRef:
name: mpm-secrets
key: DB_USERNAME
name: mpm-secrets
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: mpm-secrets
key: DB_PASSWORD
name: mpm-secrets
- name: REDIS_HOST
value: redis-db-service
- name: REDIS_PORT
value: "6379"
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: mpm-secrets
key: JWT_SECRET
name: mpm-secrets
- name: CACHE_DRIVER
value: redis
- name: QUEUE_DRIVER
value: database
image: enaccess/micropowermanager-backend:latest
imagePullPolicy: Always
name: mpm-backend
ports:
- containerPort: 80
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
status:
availableReplicas: 1
conditions:
- lastTransitionTime: "2024-12-13T05:47:18Z"
lastUpdateTime: "2024-12-13T05:47:18Z"
message: Deployment has minimum availability.
reason: MinimumReplicasAvailable
status: "True"
type: Available
- lastTransitionTime: "2024-12-13T05:46:55Z"
lastUpdateTime: "2024-12-13T05:47:18Z"
message: ReplicaSet "mpm-backend-7b59564f89" has successfully progressed.
reason: NewReplicaSetAvailable
status: "True"
type: Progressing
observedGeneration: 1
readyReplicas: 1
replicas: 1
updatedReplicas: 1
Loading