Skip to content

Commit

Permalink
Altered Deployment and CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
tobschli committed May 12, 2023
1 parent 9fd7040 commit 327c3c8
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/collaboration_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'backend/services/collaboration/**'

jobs:
build-collaboration:
build-carddeck:
uses: ./.github/workflows/build_service.yml
with:
image-name: kioku_collaboration
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
build-register:
uses: ./.github/workflows/build_service.yml
with:
image-name: kioku_register
image-name: kioku_carddeck
image-tag: prod
path: ./backend/services/register
path: ./backend/services/carddeck
context: ./backend

build-login:
uses: ./.github/workflows/build_service.yml
with:
image-name: kioku_login
image-name: kioku_user
image-tag: prod
path: ./backend/services/login
path: ./backend/services/user
context: ./backend

build-frontend-proxy:
Expand All @@ -34,4 +34,12 @@ jobs:
image-name: kioku_frontend_proxy
image-tag: prod
path: ./backend/services/frontend
context: ./backend

build-collaboration:
uses: ./.github/workflows/build_service.yml
with:
image-name: kioku_collaboration
image-tag: prod
path: ./backend/services/collaboration
context: ./backend
17 changes: 12 additions & 5 deletions helm/kioku/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ app.kubernetes.io/name: {{ .Values.frontend.name }}
{{/*
Login labels
*/}}
{{- define "kioku.login.labels" -}}
app.kubernetes.io/name: {{ .Values.login.name }}
{{- define "kioku.carddeck.labels" -}}
app.kubernetes.io/name: {{ .Values.carddeck.name }}
{{- end }}

{{/*
Register labels
*/}}
{{- define "kioku.register.labels" -}}
app.kubernetes.io/name: {{ .Values.register.name }}
app: {{ .Values.register.name }}
{{- define "kioku.user.labels" -}}
app.kubernetes.io/name: {{ .Values.user.name }}
app: {{ .Values.user.name }}
{{- end }}

{{/*
Expand All @@ -82,6 +82,13 @@ Frontend Proxy labels
app.kubernetes.io/name: {{ .Values.frontend_proxy.name }}
{{- end }}

{{/*
Collaboration labels
*/}}
{{- define "kioku.collaboration.labels" -}}
app.kubernetes.io/name: {{ .Values.collaboration.name }}
{{- end }}


{{/*
Selector labels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ .Values.register.name }}-deployment"
name: "{{ .Values.carddeck.name }}-deployment"
labels:
{{- include "kioku.register.labels" . | nindent 4 }}
{{- include "kioku.carddeck.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "kioku.register.labels" . | nindent 6 }}
{{- include "kioku.carddeck.labels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "kioku.register.labels" . | nindent 8 }}
{{- include "kioku.carddeck.labels" . | nindent 8 }}
spec:
serviceAccountName: go-micro
containers:
- name: {{ .Values.register.name }}
image: "{{ .Values.register.image }}:{{ .Values.register.tag }}"
- name: {{ .Values.carddeck.name }}
image: "{{ .Values.carddeck.image }}:{{ .Values.carddeck.tag }}"
{{ if eq .Values.mode "production" }}
imagePullPolicy: Always
{{ else }}
Expand All @@ -40,6 +40,7 @@ spec:
fieldPath: metadata.name
- name: PORT
value: "8080"

envFrom:
- secretRef:
name: {{ .Values.database.secret.name }}
Expand All @@ -49,23 +50,23 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: "{{ .Values.register.name }}-service"
name: "{{ .Values.carddeck.name }}-service"
spec:
selector:
{{- include "kioku.register.labels" . | nindent 4 }}
{{- include "kioku.carddeck.labels" . | nindent 4 }}
ports:
- port: 8080
targetPort: 8080
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: "hpa-{{ .Values.register.name }}-deployment"
name: "hpa-{{ .Values.carddeck.name }}-deployment"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: "{{ .Values.register.name }}-deployment"
minReplicas: {{ .Values.register.autoscaler.min }}
maxReplicas: {{ .Values.register.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.register.autoscaler.targetCPUUtilizationPercentage }}
name: "{{ .Values.carddeck.name }}-deployment"
minReplicas: {{ .Values.carddeck.autoscaler.min }}
maxReplicas: {{ .Values.carddeck.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.carddeck.autoscaler.targetCPUUtilizationPercentage }}
71 changes: 71 additions & 0 deletions helm/kioku/templates/collaboration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ .Values.collaboration.name }}-deployment"
labels:
{{- include "kioku.collaboration.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "kioku.collaboration.labels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "kioku.collaboration.labels" . | nindent 8 }}
spec:
serviceAccountName: go-micro
containers:
- name: {{ .Values.collaboration.name }}
image: "{{ .Values.collaboration.image }}:{{ .Values.collaboration.tag }}"
{{ if eq .Values.mode "production" }}
imagePullPolicy: Always
{{ else }}
imagePullPolicy: Never
{{ end }}
ports:
- containerPort: 8080
resources:
limits:
cpu: 500m
memory: 500M
requests:
cpu: 200m
memory: 200M
env:
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: PORT
value: "8080"
envFrom:
- secretRef:
name: {{ .Values.database.secret.name }}
- configMapRef:
name: service-env
---
apiVersion: v1
kind: Service
metadata:
name: "{{ .Values.collaboration.name }}-service"
spec:
selector:
{{- include "kioku.collaboration.labels" . | nindent 4 }}
ports:
- port: 8080
targetPort: 8080
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: "hpa-{{ .Values.collaboration.name }}-deployment"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: "{{ .Values.collaboration.name }}-deployment"
minReplicas: {{ .Values.collaboration.autoscaler.min }}
maxReplicas: {{ .Values.collaboration.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.collaboration.autoscaler.targetCPUUtilizationPercentage }}
27 changes: 13 additions & 14 deletions helm/kioku/templates/login.yaml → helm/kioku/templates/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: "{{ .Values.login.name }}-deployment"
name: "{{ .Values.user.name }}-deployment"
labels:
{{- include "kioku.login.labels" . | nindent 4 }}
{{- include "kioku.user.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "kioku.login.labels" . | nindent 6 }}
{{- include "kioku.user.labels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "kioku.login.labels" . | nindent 8 }}
{{- include "kioku.user.labels" . | nindent 8 }}
spec:
serviceAccountName: go-micro
containers:
- name: {{ .Values.login.name }}
image: "{{ .Values.login.image }}:{{ .Values.login.tag }}"
- name: {{ .Values.user.name }}
image: "{{ .Values.user.image }}:{{ .Values.user.tag }}"
{{ if eq .Values.mode "production" }}
imagePullPolicy: Always
{{ else }}
Expand All @@ -40,7 +40,6 @@ spec:
fieldPath: metadata.name
- name: PORT
value: "8080"

envFrom:
- secretRef:
name: {{ .Values.database.secret.name }}
Expand All @@ -50,23 +49,23 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: "{{ .Values.login.name }}-service"
name: "{{ .Values.user.name }}-service"
spec:
selector:
{{- include "kioku.login.labels" . | nindent 4 }}
{{- include "kioku.user.labels" . | nindent 4 }}
ports:
- port: 8080
targetPort: 8080
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: "hpa-{{ .Values.login.name }}-deployment"
name: "hpa-{{ .Values.user.name }}-deployment"
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: "{{ .Values.login.name }}-deployment"
minReplicas: {{ .Values.login.autoscaler.min }}
maxReplicas: {{ .Values.login.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.login.autoscaler.targetCPUUtilizationPercentage }}
name: "{{ .Values.user.name }}-deployment"
minReplicas: {{ .Values.user.autoscaler.min }}
maxReplicas: {{ .Values.user.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.user.autoscaler.targetCPUUtilizationPercentage }}
20 changes: 14 additions & 6 deletions helm/kioku/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,32 @@ frontend_proxy:
targetCPUUtilizationPercentage: 50


login:
name: kioku-login
image: ghcr.io/kioku-project/kioku_login
carddeck:
name: kioku-carddeck
image: ghcr.io/kioku-project/kioku_carddeck
tag: prod

autoscaler:
min: 1
max: 10
targetCPUUtilizationPercentage: 50

register:
name: kioku-register
image: ghcr.io/kioku-project/kioku_register
user:
name: kioku-user
image: ghcr.io/kioku-project/kioku_user
tag: prod

autoscaler:
min: 1
max: 10
targetCPUUtilizationPercentage: 50

collaboration:
name: kioku-collaboration
image: ghcr.io/kioku-project/kioku_collaboration
tag: prod

autoscaler:
min: 1
max: 10
targetCPUUtilizationPercentage: 50

0 comments on commit 327c3c8

Please sign in to comment.