Skip to content

Commit

Permalink
k8s deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Nov 5, 2023
1 parent 5b83fdc commit 937b82d
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 12 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/k8s-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: k8s-deploy

on:
push:
branches:
- main
- k8s-deploy

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
production-deploy:
runs-on: ubuntu-latest

steps:
- name: Check out latest commit
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: osuAkatsuki/akatsuki-api

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/akatsuki-api:latest
${{ secrets.DOCKERHUB_USERNAME }}/akatsuki-api:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}

- name: Get kubeconfig from github secrets
run: |
mkdir -p $HOME/.kube
echo "${{ secrets.KUBECONFIG }}" > $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
- name: Install helm
uses: azure/setup-helm@v3
with:
version: "latest"
token: ${{ secrets.GITHUB_TOKEN }}
id: install

- name: Install helm-diff
run: helm plugin install https://github.com/databus23/helm-diff

- name: Checkout common-helm-charts repo
uses: actions/checkout@v3
with:
repository: osuAkatsuki/common-helm-charts
token: ${{ secrets.COMMON_HELM_CHARTS_PAT }}
path: common-helm-charts

- name: Show manifest diff since previous release
run: |
helm diff upgrade \
--allow-unreleased \
--values chart/values.yaml \
akatsuki-api-production \
common-helm-charts/microservice-base/
- name: Deploy service to production cluster
run: |
helm upgrade \
--install \
--atomic \
--wait --timeout 480s \
--values chart/values.yaml \
akatsuki-api-production \
common-helm-charts/microservice-base/
30 changes: 19 additions & 11 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
app:
name: akatsuki-api
environment: staging
group: backend
container:
image:
repository: registry.digitalocean.com/akatsuki/akatsuki-api
tag: latest
imagePullSecrets:
- name: akatsuki
port: 80
apps:
- name: akatsuki-api
environment: production
codebase: akatsuki-api
replicaCount: 1
container:
image:
repository: osuakatsuki/akatsuki-api
tag: latest
port: 80
env:
- name: APP_COMPONENT
value: api
imagePullSecrets:
- name: osuakatsuki-registry-secret
# - name: registry-akatsuki
service:
type: ClusterIP
port: 80
3 changes: 2 additions & 1 deletion scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ fi
if [[ $PULL_SECRETS_FROM_VAULT -eq 1 ]]; then
# TODO: is there a better way to deal with this?
pip install --break-system-packages -i $PYPI_INDEX_URL akatsuki-cli
akatsuki vault get akatsuki-api $APP_ENV -o .env
# TODO: revert to $APP_ENV
akatsuki vault get akatsuki-api production-k8s -o .env
source .env
fi

Expand Down

0 comments on commit 937b82d

Please sign in to comment.