Skip to content

Commit

Permalink
Release to kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
oscrx committed Aug 5, 2023
1 parent c17fe79 commit 1ac6805
Show file tree
Hide file tree
Showing 13 changed files with 384 additions and 4 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
node-version: 20.x
-
name: Cache Node.js modules
uses: actions/cache@v3
uses: actions/cache@v2
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
Expand All @@ -42,7 +42,7 @@ jobs:
run: npm run lint --if-present
working-directory: ${{ matrix.folder }}
-
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v2
with:
directory: ${{ matrix.folder }}

Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
uses: docker/build-push-action@v3
with:
context: ${{ matrix.folder }}
push: ${{ github.event_name != 'pull_request' }}
Expand All @@ -121,3 +121,31 @@ jobs:
cache-from: type=gha
cache-to: type=gha
# https://docs.docker.com/build/building/cache/backends/#cache-mode

deploy:
needs:
- docker
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Deploy using Argo CD
run: |
# Access the commit SHA from GitHub context
COMMIT_SHA="${{ github.sha }}"
# Trim the first few characters to match the desired format (e.g., sha-c27d339)
SHORT_SHA="sha-${COMMIT_SHA:0:7}"
# Change appVersion in charts/drinkn/Chart.yaml
sed -i "s|appVersion:.*|appVersion: \"$SHORT_SHA\"|" charts/drinkn/Chart.yaml
# Commit and push the changes to the deploy branch
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add charts/drinkn/Chart.yaml
git commit -m "Update appVersion to $SHORT_SHA"
git push origin main
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ deploy_key
dist/
ecosystem.config.js
kubeconfig
secrets.y*ml
node_modules/
npm-debug.log*
pils-api
Expand Down
23 changes: 23 additions & 0 deletions charts/drinkn/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/drinkn/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: drinkn
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: sha-c17fe79
41 changes: 41 additions & 0 deletions charts/drinkn/templates/auth-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: drinkn-auth
name: drinkn-auth
spec:
replicas: 2
revisionHistoryLimit: 0
selector:
matchLabels:
app: drinkn-auth
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: drinkn-auth
spec:
containers:
- image: bierteam/auth
envFrom:
- secretRef:
name: drinkn-env
optional: false
imagePullPolicy: Always
name: drinkn-auth
---
apiVersion: v1
kind: Service
metadata:
name: drinkn-auth
spec:
selector:
app: drinkn-auth
ports:
- port: 80
name: default
protocol: TCP
targetPort: 3000
23 changes: 23 additions & 0 deletions charts/drinkn/templates/beer-import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: beer-import
spec:
jobTemplate:
spec:
template:
spec:
restartPolicy: Never
terminationGracePeriodSeconds: 30
containers:
- image: "ghcr.io/bierteam/beer-import:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: Always
name: beer-import
envFrom:
- secretRef:
name: drinkn-env
optional: false
schedule: 0 9,22 * * *
failedJobsHistoryLimit: 3
successfulJobsHistoryLimit: 3
41 changes: 41 additions & 0 deletions charts/drinkn/templates/cocktail-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: drinkn-cocktail-api
name: drinkn-cocktail-api
spec:
replicas: 2
revisionHistoryLimit: 0
selector:
matchLabels:
app: drinkn-cocktail-api
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: drinkn-cocktail-api
spec:
containers:
- image: bierteam/cocktail-api
envFrom:
- secretRef:
name: drinkn-env
optional: false
imagePullPolicy: Always
name: drinkn-cocktail-api
---
apiVersion: v1
kind: Service
metadata:
name: drinkn-cocktail-api
spec:
selector:
app: drinkn-cocktail-api
ports:
- port: 80
name: default
protocol: TCP
targetPort: 3000
57 changes: 57 additions & 0 deletions charts/drinkn/templates/drinkn-frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: drinkn-frontend
name: drinkn-frontend
spec:
replicas: 2
revisionHistoryLimit: 0
selector:
matchLabels:
app: drinkn-frontend
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: drinkn-frontend
spec:
containers:
- image: bierteam/frontend
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 80
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 2
name: drinkn-frontend
readinessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 80
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 2
successThreshold: 2
timeoutSeconds: 2
---
apiVersion: v1
kind: Service
metadata:
name: drinkn-frontend
spec:
selector:
app: drinkn-frontend
ports:
- port: 80
name: default
protocol: TCP
targetPort: 80
44 changes: 44 additions & 0 deletions charts/drinkn/templates/ingressroute.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: drinkn
spec:
entryPoints:
- websecure
routes:
- match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`)
kind: Rule
services:
- name: drinkn-frontend
port: 80
- match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`) && PathPrefix(`/api/v2/auth`)
kind: Rule
services:
- name: drinkn-auth
port: 80
- match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`) && PathPrefix(`/api/v2/beer`)
kind: Rule
services:
- name: drinkn-auth
port: 80
- match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`) && PathPrefix(`/api/v2/mix`)
kind: Rule
services:
- name: drinkn-cocktail-api
port: 80
- match: Host(`drinkn.oscarr.nl`, `xn--xj8haa.tk`) && PathPrefix(`/api/v2/supermarket`)
kind: Rule
services:
- name: drinkn-auth
port: 80
- match: Host(`pils.oscarr.nl`)
kind: Rule
services:
- name: pils-frontend
port: 80
- match: Host(`pils.oscarr.nl`) && PathPrefix(`/api`)
kind: Rule
services:
- name: pils
port: 80
41 changes: 41 additions & 0 deletions charts/drinkn/templates/pils-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: pils
name: pils
spec:
replicas: 2
revisionHistoryLimit: 0
selector:
matchLabels:
app: pils
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: pils
spec:
containers:
- image: "ghcr.io/bierteam/pils:{{ .Values.image.tag | default .Chart.AppVersion }}"
envFrom:
- secretRef:
name: drinkn-env
optional: false
imagePullPolicy: Always
name: pils
---
apiVersion: v1
kind: Service
metadata:
name: pils
spec:
selector:
app: pils
ports:
- port: 80
name: default
protocol: TCP
targetPort: 3000

0 comments on commit 1ac6805

Please sign in to comment.