Skip to content

Commit

Permalink
base k8s layer
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui authored and tsunyoku committed Nov 16, 2023
1 parent f7b8dc1 commit 0ffb462
Show file tree
Hide file tree
Showing 34 changed files with 1,836 additions and 1,041 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env*
.pre-commit-config.yaml
*.example
*.example
target/
10 changes: 8 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
APP_ENV=dev
API_HOST=127.0.0.1
API_PORT=8665
DATABASE_HOST=localhost
DATABASE_PORT=3306
Expand All @@ -16,6 +17,11 @@ REDIS_PORT=6379
REDIS_USERNAME=
REDIS_PASSWORD=
REDIS_DATABASE=0
BEATMAPS_PATH=
REDIS_USE_SSL=false
AWS_REGION=ca-central-1
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_ENDPOINT_URL=
AWS_BUCKET_NAME=
SERVICE_READINESS_TIMEOUT=60
RUST_LOG=performance_service=info
RUST_LOG=performance_service=info
91 changes: 91 additions & 0 deletions .github/workflows/k8s-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
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: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

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

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/performance-service:latest
${{ secrets.DOCKERHUB_USERNAME }}/performance-service:${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- 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 \
performance-service-production \
common-helm-charts/microservice-base/
- name: Deploy service to production cluster
run: |
helm upgrade \
--install \
--atomic \
--wait --timeout 480s \
--values chart/values.yaml \
performance-service-production \
common-helm-charts/microservice-base/
49 changes: 25 additions & 24 deletions .github/workflows/production-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
name: production-deploy
on:
push:
branches:
- main
# TODO: fix production deploys
# name: production-deploy
# on:
# push:
# branches:
# - main

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Run deploy on production
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script_stop: true
script: |
cd /home/akatsuki/performance-service
git pull origin main
docker build -t performance-service:latest .
cd /home/akatsuki/workbench
docker-compose restart performance-service-api performance-service-processor
# jobs:
# build:
# name: Build
# runs-on: ubuntu-latest
# steps:
# - name: Run deploy on production
# uses: appleboy/[email protected]
# with:
# host: ${{ secrets.SSH_HOST }}
# username: ${{ secrets.SSH_USERNAME }}
# key: ${{ secrets.SSH_KEY }}
# port: ${{ secrets.SSH_PORT }}
# script_stop: true
# script: |
# cd /home/akatsuki/performance-service
# git pull origin main
# docker build -t performance-service:latest .
# cd /home/akatsuki/workbench
# docker-compose restart performance-service-api performance-service-processor
Loading

0 comments on commit 0ffb462

Please sign in to comment.