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

Add workflow for connector deployment #160

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Changes from all commits
Commits
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
91 changes: 91 additions & 0 deletions .github/workflows/deploy-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
###############################################
##
## Pipeline for deploying to Kubernetes
## cluster.
##
## Gets triggered on each completed run of
## the Docker build workflow.
##
## Effectively deletes the pods on the
## cluster and pulls the latest images
## again.
##
###############################################

name: Deploy to cluster

on:
workflow_dispatch:
inputs:
version:
description: "Docker image tag to deploy on the network"
required: true
type: string
environment:
description: "Target environment where to fetch secrets and vars"
required: true
type: choice
default: "staging"
options:
- "staging"
workflow_run:
workflows:
- "deploy"
types: [completed]
branches:
- 'master'

jobs:
deploy-internal:
name: Deploy on internal cluster
runs-on: ubuntu-latest
# If no input is provided, deploy to staging
environment: ${{ github.event.inputs.environment || 'staging' }}
# Deploy gets triggered only on master branch
steps:
- name: Checkout
uses: actions/checkout@v2

# EKS supports only authentication via IAM roles
# The AWS cli tool is mandatory
- 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: us-east-1

- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@v1
with:
version: 2
verbose: false
arch: amd64
rootdir: ""
workdir: ""

# Make sure to have kubectl and the kubeconfig from the secrets
- name: Install and configure kubectl
run: |
curl https://storage.googleapis.com/kubernetes-release/release/v1.27.3/bin/linux/amd64/kubectl \
--progress-bar \
--location \
--remote-name
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
echo '${{ secrets.KUBECONFIG }}' > kubeconfig.yaml

# Using "kubectl patch" updates connector versions one by one
- name: Update connector images
run: |
export KUBECONFIG=kubeconfig.yaml
pods=$(kubectl get pods -l type=connector -n timechain -o=jsonpath='{.items[*].metadata.name}')
echo "Update connector version to latest";

sleep 10;
for pod in $pods; do
echo "Updating $pod image to latest";
kubectl delete pod $pod -n timechain;
sleep 10;
# TODO: health check for pods would be super nice
done