feat: Implement Helm Chart and update CI/CD pipeline
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -50,33 +50,34 @@ jobs:
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# CD PART
|
||||
# CD PART (HELM)
|
||||
# -----------------------------------------------------------------
|
||||
- name: Install Kubectl Binary
|
||||
- name: Install Kubectl & Helm
|
||||
run: |
|
||||
# Install kubectl (ARM64)
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
|
||||
chmod +x kubectl
|
||||
sudo mv kubectl /usr/local/bin/
|
||||
|
||||
# Install Helm
|
||||
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
|
||||
|
||||
- name: Deploy to Kubernetes and Update
|
||||
- name: Deploy with Helm
|
||||
run: |
|
||||
# 1. Write Kubeconfig content to file
|
||||
echo "${{ secrets.KUBE_CONFIG }}" > /tmp/kubeconfig.yaml
|
||||
|
||||
# 2. Get the new image Digests
|
||||
BACKEND_DIGEST="${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend@${{ steps.docker_build_backend.outputs.digest }}"
|
||||
FRONTEND_DIGEST="${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend@${{ steps.docker_build_frontend.outputs.digest }}"
|
||||
|
||||
# 3. Update Deployment
|
||||
kubectl set image deployment/evrak-backend backend=${BACKEND_DIGEST} \
|
||||
--kubeconfig=/tmp/kubeconfig.yaml -n default
|
||||
# 2. Deploy using Helm Upgrade
|
||||
# We pass the image repository and tag explicitly to ensure we use the Gitea registry
|
||||
helm upgrade --install evrak ./deploy/charts/evrak \
|
||||
--kubeconfig /tmp/kubeconfig.yaml \
|
||||
--namespace default \
|
||||
--set backend.image.repository=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend \
|
||||
--set backend.image.tag=latest \
|
||||
--set frontend.image.repository=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend \
|
||||
--set frontend.image.tag=latest \
|
||||
--set postgres.auth.password=${{ secrets.DB_PASSWORD }}
|
||||
|
||||
kubectl set image deployment/evrak-frontend frontend=${FRONTEND_DIGEST} \
|
||||
--kubeconfig=/tmp/kubeconfig.yaml -n default
|
||||
|
||||
# 4. Rollout Restart to ensure fresh pods
|
||||
kubectl rollout restart deployment/evrak-backend \
|
||||
--kubeconfig=/tmp/kubeconfig.yaml -n default
|
||||
|
||||
kubectl rollout restart deployment/evrak-frontend \
|
||||
--kubeconfig=/tmp/kubeconfig.yaml -n default
|
||||
# 3. Force restart to pick up latest image if tag is 'latest' (Helm doesn't always redeploy if values didn't change)
|
||||
kubectl rollout restart deployment/evrak-backend --kubeconfig /tmp/kubeconfig.yaml -n default
|
||||
kubectl rollout restart deployment/evrak-frontend --kubeconfig /tmp/kubeconfig.yaml -n default
|
||||
|
||||
Reference in New Issue
Block a user