Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize k8s-deployment #285

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
kind-up:
./hacks/kind-up.sh

kind-down:
kind delete cluster --name kioku

deploy:
./hacks/deploy.sh

kind-deploy:
docker compose -f ./docker-compose.build.yml build
kind load docker-image kioku-frontend:latest kioku-carddeck_service:latest kioku-frontend_proxy:latest kioku-srs_service:latest kioku-user_service:latest kioku-collaboration_service:latest kioku-notification_service:latest
kind load --name kioku docker-image kioku-frontend:latest kioku-carddeck_service:latest kioku-frontend_proxy:latest kioku-srs_service:latest kioku-user_service:latest kioku-collaboration_service:latest kioku-notification_service:latest
./hacks/deploy.sh ./hacks/values_local.yaml
2 changes: 1 addition & 1 deletion hacks/kind-up.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cat <<EOF | kind create cluster --config=-
cat <<EOF | kind create cluster --name kioku --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
Expand Down
25 changes: 18 additions & 7 deletions hacks/values_local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ mode: latestuction

vapidSecret: vapid-secret

ingress:
enabled: true
hostname: "*"

cassandra:
username: cassandra
password: cassandra
Expand Down Expand Up @@ -30,9 +34,10 @@ frontend:
httpPath: /

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100

frontend_proxy:
name: kioku-frontend-proxy
Expand All @@ -46,56 +51,62 @@ frontend_proxy:
containerPort: 8090

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100

carddeck:
name: kioku-carddeck
image: kioku-carddeck_service
tag: latest

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100

srs:
name: kioku-srs
image: kioku-srs_service
tag: latest

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100

notification:
name: kioku-notification
image: kioku-notification_service
tag: latest

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100

user:
name: kioku-user
image: kioku-user_service
tag: latest

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100

collaboration:
name: kioku-collaboration
image: kioku-collaboration_service
tag: latest

autoscaler:
enabled: false
min: 1
max: 10
targetCPUUtilizationPercentage: 50
targetCPUUtilizationPercentage: 100
10 changes: 6 additions & 4 deletions helm/kioku/templates/carddeck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ spec:
{{ end }}
ports:
- containerPort: 8080
{{ if .Values.carddeck.autoscaler.enabled }}
resources:
limits:
cpu: 500m
memory: 500M
requests:
cpu: 50m
memory: 50M
{{ end }}
env:
- name: HOSTNAME
valueFrom:
Expand Down Expand Up @@ -64,6 +63,8 @@ spec:
ports:
- port: 8080
targetPort: 8080

{{- if .Values.carddeck.autoscaler.enabled -}}
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
Expand All @@ -76,4 +77,5 @@ spec:
name: "{{ .Values.carddeck.name }}-deployment"
minReplicas: {{ .Values.carddeck.autoscaler.min }}
maxReplicas: {{ .Values.carddeck.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.carddeck.autoscaler.targetCPUUtilizationPercentage }}
targetCPUUtilizationPercentage: {{ .Values.carddeck.autoscaler.targetCPUUtilizationPercentage }}
{{- end -}}
1 change: 0 additions & 1 deletion helm/kioku/templates/cassandra_secret.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: v1
kind: Secret
metadata:
name: cassandra-secret
namespace: monitoring
labels:
{{- include "kioku.labels" . | nindent 4 }}
type: Opaque
Expand Down
10 changes: 6 additions & 4 deletions helm/kioku/templates/collaboration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ spec:
{{ end }}
ports:
- containerPort: 8080
{{ if .Values.collaboration.autoscaler.enabled }}
resources:
limits:
cpu: 500m
memory: 500M
requests:
cpu: 50m
memory: 50M
{{ end }}
env:
- name: HOSTNAME
valueFrom:
Expand Down Expand Up @@ -63,6 +62,8 @@ spec:
ports:
- port: 8080
targetPort: 8080

{{- if .Values.collaboration.autoscaler.enabled -}}
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
Expand All @@ -75,4 +76,5 @@ spec:
name: "{{ .Values.collaboration.name }}-deployment"
minReplicas: {{ .Values.collaboration.autoscaler.min }}
maxReplicas: {{ .Values.collaboration.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.collaboration.autoscaler.targetCPUUtilizationPercentage }}
targetCPUUtilizationPercentage: {{ .Values.collaboration.autoscaler.targetCPUUtilizationPercentage }}
{{- end -}}
8 changes: 5 additions & 3 deletions helm/kioku/templates/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ spec:
{{ end }}
ports:
- containerPort: {{ .Values.frontend.port }}
{{ if .Values.frontend.autoscaler.enabled }}
resources:
limits:
cpu: 500m
requests:
cpu: 200m
{{ end }}
env:
# TODO: Export to values.yaml
- name: NEXT_PUBLIC_ENVIRONMENT
Expand All @@ -49,7 +49,8 @@ spec:
ports:
- port: {{ .Values.frontend.port }}
targetPort: {{ .Values.frontend.containerPort }}
type: LoadBalancer
type: ClusterIP
{{- if .Values.frontend.autoscaler.enabled -}}
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
Expand All @@ -63,3 +64,4 @@ spec:
minReplicas: {{ .Values.frontend.autoscaler.min }}
maxReplicas: {{ .Values.frontend.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.frontend.autoscaler.targetCPUUtilizationPercentage }}
{{- end -}}
10 changes: 6 additions & 4 deletions helm/kioku/templates/frontend_proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ spec:
ports:
- containerPort: {{ .Values.frontend_proxy.containerPort }}
protocol: TCP
{{ if .Values.frontend_proxy.autoscaler.enabled }}
resources:
limits:
cpu: 500m
memory: 500M
requests:
cpu: 50m
memory: 50M
{{ end }}
envFrom:
- configMapRef:
name: service-env
Expand All @@ -57,7 +56,9 @@ spec:
ports:
- port: {{ .Values.frontend_proxy.port }}
targetPort: {{ .Values.frontend_proxy.containerPort }}
type: LoadBalancer
type: ClusterIP

{{- if .Values.frontend_proxy.autoscaler.enabled -}}
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
Expand All @@ -71,3 +72,4 @@ spec:
minReplicas: {{ .Values.frontend_proxy.autoscaler.min }}
maxReplicas: {{ .Values.frontend_proxy.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.frontend_proxy.autoscaler.targetCPUUtilizationPercentage }}
{{- end -}}
11 changes: 5 additions & 6 deletions helm/kioku/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{{- if .Values.ingress.enabled -}}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: endpoint-ingress
labels:
app: nginx
annotations:
#nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
- host: {{ .Values.ingress.hostname }}
http:
paths:
- path: {{ .Values.frontend.httpPath }}
pathType: Prefix
Expand All @@ -24,4 +22,5 @@ spec:
service:
name: "{{ .Values.frontend_proxy.name }}-service"
port:
number: {{ .Values.frontend_proxy.port }}
number: {{ .Values.frontend_proxy.port }}
{{- end }}
15 changes: 1 addition & 14 deletions helm/kioku/templates/jaeger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: jaeger-deployment
namespace: monitoring
labels:
app: jaeger
spec:
Expand Down Expand Up @@ -48,7 +47,6 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: jaeger-configmap
namespace: monitoring
data:
METRICS_STORAGE_TYPE: prometheus
PROMETHEUS_SERVER_URL: http://prometheus-service.monitoring.svc.cluster.local:9090
Expand All @@ -58,7 +56,6 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: jaeger-configmap-files
namespace: monitoring
data:
jaeger-ui.json: |-
{
Expand Down Expand Up @@ -117,7 +114,6 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: otelcol-deployment
namespace: monitoring
labels:
app: otelcol
spec:
Expand Down Expand Up @@ -154,7 +150,6 @@ apiVersion: v1
kind: Service
metadata:
name: otelcol-service
namespace: monitoring
spec:
selector:
app: otelcol
Expand All @@ -173,7 +168,6 @@ apiVersion: v1
kind: Service
metadata:
name: jaeger-service
namespace: monitoring
spec:
selector:
app: jaeger
Expand All @@ -191,11 +185,4 @@ metadata:
name: tracing-config
data:
TRACING_ENABLED: "true"
TRACING_COLLECTOR: "otelcol-service.monitoring.svc.cluster.local:4318"
---
apiVersion: v1
kind: Namespace
metadata:
name: monitoring
labels:
name: monitoring
TRACING_COLLECTOR: "otelcol-service.monitoring.svc.cluster.local:4318"
8 changes: 5 additions & 3 deletions helm/kioku/templates/notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ spec:
{{ end }}
ports:
- containerPort: 8080
{{ if .Values.notification.autoscaler.enabled }}
resources:
limits:
cpu: 500m
memory: 500M
requests:
cpu: 50m
memory: 50M
{{ end }}
env:
- name: HOSTNAME
valueFrom:
Expand Down Expand Up @@ -66,6 +65,8 @@ spec:
ports:
- port: 8080
targetPort: 8080

{{- if .Values.notification.autoscaler.enabled -}}
---
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
Expand All @@ -79,3 +80,4 @@ spec:
minReplicas: {{ .Values.notification.autoscaler.min }}
maxReplicas: {{ .Values.notification.autoscaler.max }}
targetCPUUtilizationPercentage: {{ .Values.notification.autoscaler.targetCPUUtilizationPercentage }}
{{- end -}}
Loading
Loading