Skip to content
Merged
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
87 changes: 28 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,71 +57,40 @@ jobs:
deploy:
needs: [build-artemis-adapter]
runs-on: ubuntu-latest
environment: hades-test
environment:
name: hades-artemis-adapter-k8s
url: https://hades-artemis-connector.student.k8s.aet.cit.tum.de
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Create deployment directory on VM
uses: appleboy/ssh-action@v1.2.5
- name: Setup Helm
uses: azure/setup-helm@v4
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: mkdir -p /opt/hades/traefik
version: v3.14.0

- name: Copy deployment files to VM
uses: appleboy/scp-action@v1.0.0
- name: Setup kubectl
uses: azure/setup-kubectl@v4
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
source: "docker-compose.test.yml,traefik/traefik.yml"
target: /opt/hades
strip_components: 0
version: 'latest'

- name: Create .env file on VM
uses: appleboy/ssh-action@v1.2.5
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
touch /opt/hades/traefik/acme.json
chmod 600 /opt/hades/traefik/acme.json
install -m 600 /dev/null /opt/hades/.env
cat > /opt/hades/.env <<'EOF'
IMAGE_TAG=${{ needs.build-artemis-adapter.outputs.image_tag }}
HADES_API_HOST=${{ vars.HADES_API_HOST }}
LETSENCRYPT_EMAIL=${{ vars.LETSENCRYPT_EMAIL }}
ARTEMIS_BASE_URL=${{ vars.ARTEMIS_BASE_URL }}
ARTEMIS_NEW_RESULT_ENDPOINT=${{ vars.ARTEMIS_NEW_RESULT_ENDPOINT }}
ARTEMIS_AUTH_TOKEN=${{ secrets.ARTEMIS_AUTH_TOKEN }}
EOF
- name: Setup Kubeconfig
run: |
# Write kubeconfig from secret to file
echo "${{ secrets.KUBECONFIG }}" > kubeconfig
export KUBECONFIG=$PWD/kubeconfig
chmod 600 kubeconfig

- name: Deploy with docker compose
uses: appleboy/ssh-action@v1.2.5
with:
host: ${{ vars.VM_HOST }}
username: ${{ vars.VM_USERNAME }}
key: ${{ secrets.VM_SSH_PRIVATE_KEY }}
proxy_host: ${{ vars.DEPLOYMENT_GATEWAY_HOST }}
proxy_username: ${{ vars.DEPLOYMENT_GATEWAY_USER }}
proxy_key: ${{ secrets.DEPLOYMENT_GATEWAY_SSH_KEY }}
proxy_port: ${{ vars.DEPLOYMENT_GATEWAY_PORT }}
script: |
cd /opt/hades
docker compose -f docker-compose.test.yml up --pull=always -d --remove-orphans
docker image prune -af --filter "until=24h"
# Verify connection to cluster
kubectl config get-contexts
kubectl get nodes

- name: Deploy to Kubernetes
env:
KUBECONFIG: ${{ github.workspace }}/kubeconfig
run: |
helm upgrade --install hades-artemis-adapter ./helm/hades-artemis-adapter -f ./helm/values-deploy.yaml \
--namespace hades-artemis-connector --create-namespace \
--set image.tag="${{ needs.build-artemis-adapter.outputs.image_tag }}" \
--set env.ARTEMIS_BASE_URL="https://artemis-test8.artemis.cit.tum.de" \
--set env.ARTEMIS_AUTH_TOKEN="${{ secrets.ARTEMIS_AUTH_TOKEN }}"
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
# hades-artemis-adapter
# hades-artemis-adapter

> [!WARNING]
> This is a work in progress repository.

## Deployment

```shell

helm upgrade --install hades-artemis-adapter ./helm/hades-artemis-adapter -f ./helm/values-deploy.yaml \
--namespace hades-artemis-connector --create-namespace \
--set image.tag="main" \
--set env.ARTEMIS_BASE_URL="https://artemis-test8.artemis.cit.tum.de" \
--set env.ARTEMIS_AUTH_TOKEN="<TOKEN>"

```
36 changes: 0 additions & 36 deletions docker-compose.deploy.yml

This file was deleted.

43 changes: 0 additions & 43 deletions docker-compose.test.yml

This file was deleted.

23 changes: 23 additions & 0 deletions helm/hades-artemis-adapter/.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 helm/hades-artemis-adapter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: hades-artemis-adapter
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: 0.1.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: "1.16.0"
35 changes: 35 additions & 0 deletions helm/hades-artemis-adapter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
1. Get the application URL by running these commands:
{{- if .Values.httpRoute.enabled }}
{{- if .Values.httpRoute.hostnames }}
export APP_HOSTNAME={{ .Values.httpRoute.hostnames | first }}
{{- else }}
export APP_HOSTNAME=$(kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o jsonpath="{.spec.listeners[0].hostname}")
{{- end }}
{{- if and .Values.httpRoute.rules (first .Values.httpRoute.rules).matches (first (first .Values.httpRoute.rules).matches).path.value }}
echo "Visit http://$APP_HOSTNAME{{ (first (first .Values.httpRoute.rules).matches).path.value }} to use your application"

NOTE: Your HTTPRoute depends on the listener configuration of your gateway and your HTTPRoute rules.
The rules can be set for path, method, header and query parameters.
You can check the gateway configuration with 'kubectl get --namespace {{(first .Values.httpRoute.parentRefs).namespace | default .Release.Namespace }} gateway/{{ (first .Values.httpRoute.parentRefs).name }} -o yaml'
{{- end }}
{{- else if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $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 "hades-artemis-adapter.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 its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "hades-artemis-adapter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "hades-artemis-adapter.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 "hades-artemis-adapter.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 }}
51 changes: 51 additions & 0 deletions helm/hades-artemis-adapter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "hades-artemis-adapter.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 "hades-artemis-adapter.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 "hades-artemis-adapter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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