Skip to content

Commit

Permalink
Merge pull request #1 from daifoundation/TECH-1861
Browse files Browse the repository at this point in the history
TECH-1861 - Migrating cla-assistant to Kubernetes
  • Loading branch information
OleksandrUA authored Aug 28, 2023
2 parents ebd28b2 + 120543d commit 8d10602
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 89 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build-and-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
on:
push:
branches:
- main
- TECH-1861

name: Deploy to AWS Production (K8s)

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production
env:
AWS_REGION: us-east-1
CLUSTER_NAME: maker-prod
SERVICE_NAME: cla-assistant
AWS_ECR_NAME: cla-assistant
ENVIRONMENT_TAG: prod

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Extract commit hash
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
SHA_TAG: ${{ steps.vars.outputs.sha_short }}
LATEST_TAG: latest
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# Build Docker containers and push them to ECR ${{ env.AWS_ECR_NAME }}
docker pull $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG || true
docker build -t $AWS_ECR_NAME \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$SHA_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$LATEST_TAG \
-t $ECR_REGISTRY/$AWS_ECR_NAME:$ENVIRONMENT_TAG \
-f Dockerfile \
.
docker push $ECR_REGISTRY/$AWS_ECR_NAME --all-tags
- name: Preparing Helm values files
id: preparing-helm-values
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
sed -i 's/${ECR_REGISTRY}/'$(echo $ECR_REGISTRY)/ deploy/prod/cla-assistant.yaml
- name: Deploying CLA Assistant Logger to Kubernetes with Helm
uses: bitovi/[email protected]
with:
values: image.repository=${{ steps.login-ecr.outputs.registry }}/${{ env.AWS_ECR_NAME }},image.tag=${{ steps.vars.outputs.sha_short }}
cluster-name: ${{ env.CLUSTER_NAME }}
config-files: deploy/prod/cla-assistant.yaml
chart-path: techops-services/common
namespace: cla-assistant
timeout: 5m0s
name: ${{ env.SERVICE_NAME }}
chart-repository: https://techops-services.github.io/helm-charts
version: 0.0.14
atomic: true
89 changes: 0 additions & 89 deletions .github/workflows/build.yml

This file was deleted.

74 changes: 74 additions & 0 deletions deploy/prod/cla-assistant.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
replicaCount: 1
service:
enabled: true
name: cla-assistent
port: 8080
type: ClusterIP
containerPort: 8080
tls:
enabled: true
issuerName: cloudflare
image:
repository: ${ECR_REGISTRY}/cla-assistent
pullPolicy: Always
tag: prod
serviceAccount:
create: false
ingress:
enabled: true
host: cla.daifoundation.org
annotations:
external-dns.alpha.kubernetes.io/cloudflare-proxied: "true"
podAnnotations:
reloader.stakater.com/auto: "true"
resources:
limits:
cpu: 2
memory: 4096Mi
requests:
cpu: 250m
memory: 256Mi
autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 2
targetCPUUtilizationPercentage: 80
targetMemoryUtilizationPercentage: 60
env:
PROTOCOL:
type: kv
value: "https"
PORT:
type: kv
value: "8080"
HOST:
type: kv
value: "cla.daifoundation.org"
GITHUB_CLIENT:
type: parameterStore
name: github-client
parameter_name: /eks/maker-prod/cla-assistent/github-client
GITHUB_SECRET:
type: parameterStore
name: github-secret
parameter_name: /eks/maker-prod/cla-assistent/github-secret
GITHUB_TOKEN:
type: parameterStore
name: github-token
parameter_name: /eks/maker-prod/cla-assistent/github-token
MONGODB:
type: parameterStore
name: mongodb
parameter_name: /eks/maker-prod/cla-assistent/mongodb
GITHUB_ADMIN_USERS:
type: parameterStore
name: github-admin-users
parameter_name: /eks/maker-prod/cla-assistent/github-admin-users
externalSecrets:
clusterSecretStoreName: maker-prod
readinessProbe:
tcpSocket:
port: 8080
livenessProbe:
tcpSocket:
port: 8080

0 comments on commit 8d10602

Please sign in to comment.