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

feat: add chart to deploy trefx agent #849

Open
wants to merge 20 commits 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
71 changes: 71 additions & 0 deletions .github/workflows/charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build Helm Chart

on:
pull_request:
# Only consider PRs that change files for this asset, including ci scripts
paths:
- '.github/workflows/charts.yaml'
- 'charts/**'
# Make sure all workflows that are "required checks" for a given
# branch protection rule have the same paths: and branches-ignore:
# filters. Otherwise, you can end up in a deadlock waiting on a
# required check that will never be executed.
push:
# Only release off of release and maintenance branches for this asset
branches:
- 'main'
# Only consider pushes that change files for this asset, including ci scripts
paths:
- '.github/workflows/charts.yaml'
- 'charts/**'

permissions:
contents: write
pull-requests: write
actions: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# Needed to generate releases safely
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
# Job name must be unique across repo to target
# branch protection rules "required checks" properly!
agent-helm-chart:
uses: SwanseaUniversityMedical/workflows/.github/workflows/pr-and-release-chart.yaml@v2.0.3-charts
with:
job-name: agent-helm-chart
registry: ${{ vars.HARBOR_REGISTRY }}
registry-user: ${{ vars.HARBOR_USER }}
registry-project: ${{ vars.HARBOR_PROJECT }}
registry-repo: trefx-agent
release-tag-format: 'Agent-Helm-Chart-${version}'
cosign-public-key: ${{ vars.COSIGN_PUBLIC_KEY }}
chart: charts/agent
test-command: |
helm template $CHART --debug

secrets:
cosign-private-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
cosign-password: ${{ secrets.COSIGN_PASSWORD }}
registry-token: ${{ secrets.HARBOR_TOKEN }}

agent-stack-helm-chart:
uses: SwanseaUniversityMedical/workflows/.github/workflows/pr-and-release-chart.yaml@v2.0.3-charts
with:
job-name: agent-stack-helm-chart
registry: ${{ vars.HARBOR_REGISTRY }}
registry-user: ${{ vars.HARBOR_USER }}
registry-project: ${{ vars.HARBOR_PROJECT }}
registry-repo: agent-stack
release-tag-format: 'Agent-Stack-Helm-Chart-${version}'
cosign-public-key: ${{ vars.COSIGN_PUBLIC_KEY }}
chart: charts/agent-stack
test-command: |
helm template $CHART --debug

secrets:
cosign-private-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
cosign-password: ${{ secrets.COSIGN_PASSWORD }}
registry-token: ${{ secrets.HARBOR_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,6 @@ serp-forms-api/appsettings.Development.json
serp-forms-api/appsettings.Development.json

.idea

.DS_Store
**/.DS_Store
23 changes: 23 additions & 0 deletions charts/agent-stack/.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 charts/agent-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: agent-stack
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: "0.0.0"
70 changes: 70 additions & 0 deletions charts/agent-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "agent-deploy.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 "agent-deploy.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 "agent-deploy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

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

{{/*
Derive the oidc authority host from the full url
*/}}
{{- define "agent-deploy.oidcHost" -}}
{{- $parts := split "/" .Values.global.oidc.authority }}
{{- printf "%s" $parts._2 }}
{{- end }}
29 changes: 29 additions & 0 deletions charts/agent-stack/templates/hasura.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.hasura.enabled }}
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: hasura
namespace: {{ .Release.Namespace }}
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: {{ .Values.global.argo.project }}
destination:
namespace: {{ .Release.Namespace }}
server: {{ .Values.global.argo.destinationServer }}
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
- ApplyOutOfSyncOnly=true
source:
repoURL: {{ .Values.hasura.repoUrl }}
chart: {{ .Values.hasura.chart }}
targetRevision: {{ .Values.hasura.chartVersion }}
helm:
values: |
{{- .Values.hasura.helmValues | toYaml | nindent 8 }}

{{- end }}
44 changes: 44 additions & 0 deletions charts/agent-stack/templates/minio-cert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# {{- if .Values.minio.enabled }}
# apiVersion: cert-manager.io/v1
# kind: Certificate
# metadata:
# name: minio-tls-secret
# namespace: {{ .Release.Namespace }}
# spec:
# # Secret names are always required.
# secretName: minio-tls-secret
# duration: 2160h0m0s #90d
# renewBefore: 360h0m0s #15d
# subject:
# organizations:
# - serp
# privateKey:
# algorithm: RSA
# encoding: PKCS1
# size: 2048
# usages:
# - server auth
# - digital signature
# - client auth
# - key encipherment
# dnsNames:
# - "minio.{{ .Values.global.network.ingress.host }}"
# - "minio"
# - "minio.{{ .Release.Namespace }}"
# - "minio.{{ .Release.Namespace }}.svc"
# - "minio.{{ .Release.Namespace }}.svc.cluster.local"
# - "{{ .Values.minio.tenantName }}-hl"
# - "{{ .Values.minio.tenantName }}-hl.{{ .Release.Namespace }}"
# - "{{ .Values.minio.tenantName }}-hl.{{ .Release.Namespace }}.svc"
# - "{{ .Values.minio.tenantName }}-hl.{{ .Release.Namespace }}.svc.cluster.local"
# - "*.{{ .Values.minio.tenantName }}-hl.{{ .Release.Namespace }}.svc.cluster.local"
# - "*.{{ .Release.Namespace }}.svc.cluster.local"
# # we use this as a cheat/workaround to get it to trust the keycloak ca for oidc
# - {{ include "agent-deploy.oidcHost" . }}
# ipAddresses:
# - 127.0.0.1
# issuerRef:
# name: {{ .Values.global.network.certificate.clusterIssuer }}
# kind: ClusterIssuer
# group: cert-manager.io
# {{- end }}
Loading
Loading