Skip to content

Commit

Permalink
Add Helmchart
Browse files Browse the repository at this point in the history
Signed-off-by: Colin Wilk <colin.wilk@tum.de>
  • Loading branch information
kliwniloc committed Sep 5, 2024
1 parent 68ffe10 commit fa25ba6
Show file tree
Hide file tree
Showing 37 changed files with 1,362 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/helmchart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build and Push Helm Chart

on:
push:
branches:
- '*'

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Helm
uses: azure/setup-helm@v3
with:
version: v3.15.0

- name: Get branch name
id: branch
run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV

- name: Determine tag
id: determine-tag
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
SEM_VERSION="${GITHUB_REF#refs/tags/}"
else
SEM_VERSION="0.0.0-${{ env.BRANCH_NAME }}"
fi
echo "SEM_VERSION=${SEM_VERSION}" >> $GITHUB_ENV
- name: Update chart dependencies
run: helm dependency update artemis

- name: Chart | Push
uses: appany/helm-oci-chart-releaser@v0.3.0
with:
name: helm
repository: kliwniloc/artemis-helm
tag: ${{ env.SEM_VERSION }}
path: helm
registry: ghcr.io
registry_username: ${{ github.repository_owner }}
registry_password: ${{ secrets.GITHUB_TOKEN }}
update_dependencies: 'true'
1 change: 1 addition & 0 deletions helm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts
9 changes: 9 additions & 0 deletions helm/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dependencies:
- name: prometheus-adapter
repository: https://prometheus-community.github.io/helm-charts
version: 3.4.1
- name: prometheus
repository: https://prometheus-community.github.io/helm-charts
version: 15.18.0
digest: sha256:9eb272bb161e9a4bf9fff7ec31a7719664ff2dce11e28be0d94a83bded0cffa1
generated: "2024-08-10T17:33:10.801079972+02:00"
46 changes: 46 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v2
name: artemis
description: A Helm chart for Artemis

# 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/)
#TODO: figure out how and when this is updated
version: 0.1.2

# 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: "5.5.7"


sources:
- https://github.com/ls1intum/Artemis
- https://github.com/ls1intum/artemis-helm

maintainers:
- name: Matthias Linhuber
email: matthias.linhuber@tum.de

icon: "https://github.com/ls1intum/Artemis/blob/develop/src/main/resources/public/images/logo.png"

dependencies:
- name: prometheus-adapter
repository: https://prometheus-community.github.io/helm-charts
version: 3.4.1
condition: artemis.autoscaler.customPrometheus
- name: prometheus
repository: https://prometheus-community.github.io/helm-charts
version: 15.18.0
condition: artemis.autoscaler.customPrometheus
22 changes: 22 additions & 0 deletions 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.artemis.ingress.enabled }}
{{- range $host := .Values.artemis.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.artemis.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.artemis.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "artemis.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.artemis.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 "artemis.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "artemis.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.artemis.service.port }}
{{- else if contains "ClusterIP" .Values.artemis.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "artemis.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 }}
82 changes: 82 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "artemis.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 "artemis.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 "artemis.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "artemis.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "artemis.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}


{{/*
Generate common Artemis java spring profiles
*/}}
{{- define "artemis.springprofiles" -}}
prod,artemis,decoupling
{{- if .Values.application.userManagement.provider -}}
,{{ .Values.application.userManagement.provider }}
{{- end }}
{{- if .Values.application.userManagement.ldap.enabled -}}
,ldap
{{- end }}
{{- if .Values.application.versioncontrol.provider -}}
,{{ .Values.application.versioncontrol.provider }}
{{- end }}
{{- if .Values.application.continuousintegration.provider -}}
,{{ .Values.application.continuousintegration.provider }}
{{- end }}
{{- end }}
41 changes: 41 additions & 0 deletions helm/templates/autoscaler/horizontal-pod-autoscaler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.artemis.autoscaler.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "artemis.fullname" . }}
labels:
{{- include "artemis.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "artemis.fullname" . }}
minReplicas: {{ .Values.artemis.autoscaler.minReplicas }}
maxReplicas: {{ .Values.artemis.autoscaler.maxReplicas }}
{{- with .Values.artemis.autoscaler.behavior }}
behavior:
{{- toYaml . | nindent 8 }}
{{- end }}
metrics:
{{- if .Values.artemis.autoscaler.metrics.usersPerInstance }}
- type: Pods
pods:
metric:
name: artemis_instance_websocket_users
target:
type: AverageValue
averageValue: {{ .Values.artemis.autoscaler.metrics.usersPerInstance }}
{{- end }}
{{- range .Values.artemis.autoscaler.metrics.externalMetrics }}
- type: External
external:
metric:
name: {{ .name }}
selector:
matchLabels:
{{- toYaml .labels | nindent 12 }}
target:
type: AverageValue
averageValue: {{ .targetValue }}
{{- end }}
{{- end }}
74 changes: 74 additions & 0 deletions helm/templates/configmaps/activemq-broker-configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: activemq-broker-configmap
data:
broker.xml: |
<configuration xmlns="urn:activemq"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xi="http://www.w3.org/2001/XInclude"
xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:activemq:core ">
<name>ActiveMQ Kubernetes</name>
<journal-pool-files>10</journal-pool-files>
<max-disk-usage>100</max-disk-usage>
<acceptors>
<!-- Acceptor for every supported protocol -->
<acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true</acceptor>
<!-- STOMP Acceptor. -->
<acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true;heartBeatToConnectionTtlModifier=6</acceptor>
</acceptors>
<connectors>
<connector name="netty-connector">tcp://0.0.0.0:61616</connector>
</connectors>
<wildcard-addresses>
<routing-enabled>true</routing-enabled>
<delimiter>/</delimiter>
<any-words>#</any-words>
<single-word>*</single-word>
</wildcard-addresses>
<security-settings>
<security-setting match="#">
<permission type="createNonDurableQueue" roles="amq"/>
<permission type="deleteNonDurableQueue" roles="amq"/>
<permission type="createDurableQueue" roles="amq"/>
<permission type="deleteDurableQueue" roles="amq"/>
<permission type="createAddress" roles="amq"/>
<permission type="deleteAddress" roles="amq"/>
<permission type="consume" roles="amq"/>
<permission type="browse" roles="amq"/>
<permission type="send" roles="amq"/>
<!-- we need this otherwise ./artemis data imp wouldn't work -->
<permission type="manage" roles="amq"/>
</security-setting>
</security-settings>
<address-settings>
<!--default for catch all-->
<address-setting match="#">
<dead-letter-address>DLQ</dead-letter-address>
<expiry-address>ExpiryQueue</expiry-address>
<redelivery-delay>0</redelivery-delay>
<!-- with -1 only the global-max-size is in use for limiting -->
<max-size-bytes>-1</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>PAGE</address-full-policy>
<auto-create-queues>true</auto-create-queues>
<auto-create-addresses>true</auto-create-addresses>
<auto-create-jms-queues>true</auto-create-jms-queues>
<auto-create-jms-topics>true</auto-create-jms-topics>
</address-setting>
</address-settings>
</core>
</configuration>
12 changes: 12 additions & 0 deletions helm/templates/configmaps/artemis-ci-configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: artemis-ci-configmap
data:
artemis.continuous-integration.auth-token-value: {{ .Values.application.continuousintegration.artemis_authentication_token_value | quote }}
artemis.continuous-integration.specify-concurrent-builds: {{ .Values.application.continuousintegration.specify_concurrent_builds | quote }}
artemis.continuous-integration.concurrent-build-size: {{ .Values.application.continuousintegration.concurrent_build_size | quote }}
artemis.continuous-integration.specify-thread-pool-size: {{ .Values.application.continuousintegration.specify_thread_pool_size | quote }}
artemis.continuous-integration.image-cleanup.enabled: {{ .Values.application.continuousintegration.image_cleanup.enabled | quote }}
artemis.continuous-integration.image-cleanup.expiry-days: {{ .Values.application.continuousintegration.image_cleanup.expiry_days | quote }}
artemis.continuous-integration.image-cleanup.cleanup-schedule-time: {{ .Values.application.continuousintegration.image_cleanup.cleanup_schedule_time | quote }}
27 changes: 27 additions & 0 deletions helm/templates/configmaps/artemis-configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: artemis-app
data:
SPRING_DATASOURCE_URL: jdbc:mysql://artemis-mysql/artemis?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
SPRING_PROFILES_ACTIVE: {{ include "artemis.springprofiles" .}}
artemis.file-upload-path: {{ .Values.artemis.volumes.mountPath }}/uploads
artemis.submission-export-path: {{ .Values.artemis.volumes.mountPath }}/exports
artemis.repo-clone-path: {{ .Values.artemis.volumes.mountPath }}/repos
artemis.repo-download-clone-path: {{ .Values.artemis.volumes.mountPath }}/repos-download
eureka.client.enabled: "true"
eureka.instance.instanceId: "${HOSTNAME}"
spring.hazelcast.interface: "${MY_POD_IP}"
spring.websocket.broker.addresses: "{{ .Values.broker.service.name }}:{{ .Values.broker.service.port }}"
spring.artemis.mode: "native"
spring.artemis.broker-url: "tcp://{{ .Values.broker.service.name }}:61616"
logging.level.reactor.netty.transport.TransportConnector: "DEBUG"
{{- with (first .Values.artemis.ingress.hosts) }}
server.url: https://{{ .host }}
{{- end }}
EUREKA_CLIENT_SERVICE_URL_DEFAULTZONE: http://admin:${spring.security.user.password}@{{ .Values.registry.service.name }}:{{ .Values.registry.service.port }}/eureka/
{{- if .Values.artemis.autoscaler.enabled }}
management.metrics.export.prometheus.enabled: "true"
spring.prometheus.monitoringIp: {{ .Values.artemis.autoscaler.monitoringIp }}
{{- end }}
jhipster.security.authentication.jwt.base64-secret: {{ required "Registry JWT is required!" .Values.application.registry.jwt | b64enc | quote }}
8 changes: 8 additions & 0 deletions helm/templates/configmaps/artemis-mysql-configmap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
data:
MYSQL_ROOT_PASSWORD: ""
MYSQL_DATABASE: "Artemis"
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
kind: ConfigMap
metadata:
name: artemis-mysql
Loading

0 comments on commit fa25ba6

Please sign in to comment.