Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
ff05000
Test build and push script for k8s
andreas-repp Jan 29, 2024
8af9f4e
Test
andreas-repp Jan 29, 2024
b75ef2a
Test
andreas-repp Jan 29, 2024
db734cb
try adding build
andreas-repp Jan 29, 2024
18f0a70
try adding build
andreas-repp Jan 29, 2024
2c26655
Test
andreas-repp Jan 29, 2024
b9abe7f
Test multiline
andreas-repp Jan 29, 2024
8059f63
Test change name
andreas-repp Jan 29, 2024
dd62f27
Cleanup and enable gradle cache
andreas-repp Jan 29, 2024
fb723b4
Cleanup and enable gradle cache
andreas-repp Jan 29, 2024
8cbdbce
Try to deploy
andreas-repp Jan 29, 2024
45b13e4
Try servicebinding for DB
andreas-repp Jan 29, 2024
bc95344
Try with db
andreas-repp Jan 29, 2024
a1c3fe9
Remove imagepull secret
andreas-repp Jan 29, 2024
bad839f
Fix secret name
andreas-repp Jan 30, 2024
1760c3d
Fix secret name
andreas-repp Jan 30, 2024
6aad7f1
Add tls host
andreas-repp Jan 30, 2024
a090c9c
Fix ingress tls host
andreas-repp Feb 9, 2024
bfece6a
Set ingress class name
andreas-repp Feb 9, 2024
1da8077
Add loader.io config for quarkus-sync
andreas-repp Feb 9, 2024
3979d0e
Merge remote-tracking branch 'origin/main' into feature/k8s-deployment
andreas-repp Feb 9, 2024
facfde5
Update Quarkus to version 3.7.2
andreas-repp Feb 9, 2024
037c243
Add deployment for db to quarkus-sync pipeline
andreas-repp Feb 9, 2024
01cbd2d
Add deployment for db to quarkus-sync pipeline
andreas-repp Feb 9, 2024
bed2fad
Add deployment for db to quarkus-sync pipeline
andreas-repp Feb 9, 2024
b4dba04
Try using action for postgres deployment
andreas-repp Feb 15, 2024
d9b608f
Fix typo
andreas-repp Feb 15, 2024
5151aff
Rename bookstore-quarkus to bookstore-quarkus-reactive
andreas-repp Feb 15, 2024
75c7a62
Update postman collection
andreas-repp Feb 15, 2024
8461d3f
Test without explicit checkout
andreas-repp Feb 15, 2024
be670c2
Revert
andreas-repp Feb 15, 2024
9b65241
Test extracting quarkus building as composite action
andreas-repp Feb 15, 2024
596cc3b
Test extracting quarkus building as composite action
andreas-repp Feb 15, 2024
31011c1
Try with working directory
andreas-repp Feb 15, 2024
fed9d1c
Move working directory switch into action
andreas-repp Feb 15, 2024
bd5b1b9
Remove obsolete ingress class name
andreas-repp Feb 15, 2024
b8a7a43
Remove obsolete config from pipeline
andreas-repp Feb 15, 2024
12f8154
Remove obsolete config from pipeline
andreas-repp Feb 15, 2024
d77d404
Provide quarkus root path via env
andreas-repp Feb 15, 2024
4a4aa32
Test fixing if
andreas-repp Feb 15, 2024
cd942f4
Fix if
andreas-repp Feb 15, 2024
e2b83bc
Remove obsolete symbols
andreas-repp Feb 15, 2024
ada2b54
Only run quarkus-sync pipeline on changes to quarkus-sync directory
andreas-repp Feb 15, 2024
bb2d5e7
Dummy change
andreas-repp Feb 15, 2024
899447c
Try fixing paths pattern
andreas-repp Feb 15, 2024
621c790
Dummy change
andreas-repp Feb 15, 2024
39b4092
Deploy quarkus-reactive
andreas-repp Feb 15, 2024
97892b0
Make gradlew executable
andreas-repp Feb 15, 2024
49f000a
add loaderio verification file
andreas-repp Feb 15, 2024
90d9ad3
Push rust rocket image to ghcr
andreas-repp Feb 15, 2024
fb23d8d
Dummy change
andreas-repp Feb 15, 2024
7e965cc
Deploy rust rocket db
andreas-repp Feb 15, 2024
4cdd7ea
Deploy rust rocket db
andreas-repp Feb 15, 2024
c58a98c
Add helm chart to deploy to k8s
andreas-repp Feb 15, 2024
ebf6e56
Merge branch 'main' into feature/rocket-k8s-deployment
andreas-repp Feb 18, 2024
8bd5ab9
Merge branch 'refs/heads/main' into feature/rocket-k8s-deployment
andreas-repp Jun 7, 2024
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
54 changes: 54 additions & 0 deletions .github/workflows/k8s-rust-rocket.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build & Deploy Rust Rocket to k8s

on:
push:
branches:
- '**'
paths:
- bookstore-rocketrs/**
- k8s/**


jobs:
publish:
name: Build & Deploy RustRocket
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build, tag, and push image to Amazon ECR
run: |
docker build -t ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/bookstore-rocketrs:$GITHUB_SHA .
docker push ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/bookstore-rocketrs:$GITHUB_SHA
working-directory: ./bookstore-rocketrs


# - name: deploy rust rocket
# uses: vimeda/helm@v1.7.0
# # if: ${{ github.ref == inputs.deploy-branch }} # TODO FIXME enable again
# with:
# release: bookstore-rocketrs
# namespace: benchmarks
# chart: k8s/helm
# values: |
# image.name: bookstore-rocketrs
# image.tag: $GITHUB_SHA
# env:
# KUBECONFIG_FILE: ${{ secrets.KUBECONFIG }}


- name: deploy postgres
uses: ./.github/actions/k8s/deploy-postgres
with:
release-name: bookstore-rocketrs
anti-affinity-value: bookstore-rocketrs
kube-config: ${{ secrets.KUBECONFIG }}
23 changes: 23 additions & 0 deletions k8s/helm/.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/
7 changes: 7 additions & 0 deletions k8s/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: bookstore
description: A Helm chart for Kubernetes

type: application
version: 0.1.0
appVersion: "1.0.0"
22 changes: 22 additions & 0 deletions k8s/helm/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ tpl $host.host $ }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "helm.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "helm.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "helm.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "helm.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
61 changes: 61 additions & 0 deletions k8s/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "helm.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "helm.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "helm.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "helm.labels" -}}
helm.sh/chart: {{ include "helm.chart" . }}
{{ include "helm.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "helm.selectorLabels" -}}
app.kubernetes.io/name: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "helm.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "helm.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
83 changes: 83 additions & 0 deletions k8s/helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "helm.fullname" . }}
labels:
{{- include "helm.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "helm.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "helm.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{/* livenessProbe:*/}}
{{/* httpGet:*/}}
{{/* path: /*/}}
{{/* port: http*/}}
{{/* readinessProbe:*/}}
{{/* httpGet:*/}}
{{/* path: /*/}}
{{/* port: http*/}}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-postgresql
key: postgres-password
- name: DB_HOST
value: {{ tpl .Values.db.host $ }}
- name: DB_USERNAME
value: {{ tpl .Values.db.username $ }}
- name: DB_NAME
value: {{ tpl .Values.db.name $ }}
- name: DATABASE_URL
value: postgres://postgres:postgres@db/bookstore
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
61 changes: 61 additions & 0 deletions k8s/helm/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "helm.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "helm.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ tpl . $ | quote }}
{{- end }}
secretName: {{ tpl .secretName $ }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ tpl .host $ | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions k8s/helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "helm.fullname" . }}
labels:
{{- include "helm.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "helm.selectorLabels" . | nindent 4 }}
63 changes: 63 additions & 0 deletions k8s/helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
replicaCount: 1

image:
repository: ghcr.io/arconsis/server_benchmarks
name:
pullPolicy: IfNotPresent
tag:


db:
host: "{{ .Release.Name }}-postgresql"
name: books-db
username: postgres


nameOverride: ""
fullnameOverride: ""

imagePullSecrets: []

podAnnotations: {}
podLabels: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 80

ingress:
enabled: true
className: ""
annotations:
kubernetes.io/tls-acme: "true"
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: nginx
hosts:
- host: "{{ .Release.Name }}.benchmarks.k8s.dev.arconsis.com"
paths:
- path: /
pathType: ImplementationSpecific
tls:
- secretName: "{{ .Release.Name }}-tls"
hosts:
- "{{ .Release.Name }}.benchmarks.k8s.dev.arconsis.com"

resources:
limits:
cpu: 1000m
memory: 256Mi
requests:
cpu: 10m
memory: 32Mi

Loading