diff --git a/.github/workflows/chart.yml b/.github/workflows/chart.yml new file mode 100644 index 00000000..0af15646 --- /dev/null +++ b/.github/workflows/chart.yml @@ -0,0 +1,102 @@ +name: chart + +env: + HELM_VERSION: v3.14.0 + +on: + push: + tags: + - 'chart-v[0-9].[0-9]+.[0-9]+' + pull_request: + paths: + - 'charts/**' + - '.github/workflows/chart.yml' + +jobs: + validate: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Fetch main branch for chart-testing + run: | + git fetch origin main:main + + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: ${{ env.HELM_VERSION }} + + # Used by helm chart-testing below + - name: Set up Python + uses: actions/setup-python@v5.0.0 + with: + python-version: '3.12.2' + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.6.1 + with: + version: v3.10.1 + yamllint_version: 1.35.1 + yamale_version: 5.0.0 + + - name: Run chart-testing (lint) + run: | + ct lint --config charts/wadm/ct.yaml + + - name: Create kind cluster + uses: helm/kind-action@v1.9.0 + with: + version: "v0.22.0" + + - name: Install nats in the test cluster + run: | + helm repo add nats https://nats-io.github.io/k8s/helm/charts/ + helm repo update + helm install nats nats/nats + + - name: Run chart-testing (install) + run: | + ct install --config charts/wadm/ct.yaml + + publish: + if: ${{ startsWith(github.ref, 'refs/tags/chart-v') }} + runs-on: ubuntu-22.04 + needs: validate + permissions: + packages: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up Helm + uses: azure/setup-helm@v4 + with: + version: ${{ env.HELM_VERSION }} + + - name: Package + run: | + helm package chart -d .helm-charts + + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Lowercase the organization name for ghcr.io + run: | + echo "GHCR_REPO_NAMESPACE=${GITHUB_REPOSITORY_OWNER,,}" >>${GITHUB_ENV} + + - name: Publish + run: | + for chart in .helm-charts/*; do + if [ -z "${chart:-}" ]; then + break + fi + helm push "${chart}" "oci://ghcr.io/${{ env.GHCR_REPO_NAMESPACE }}/charts" + done diff --git a/charts/wadm/.helmignore b/charts/wadm/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/wadm/.helmignore @@ -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/ diff --git a/charts/wadm/Chart.yaml b/charts/wadm/Chart.yaml new file mode 100644 index 00000000..72f509d4 --- /dev/null +++ b/charts/wadm/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: wadm +description: A Helm chart for deploying wadm on 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: "v0.10.0" diff --git a/charts/wadm/ci/install-values.yaml b/charts/wadm/ci/install-values.yaml new file mode 100644 index 00000000..120b9de0 --- /dev/null +++ b/charts/wadm/ci/install-values.yaml @@ -0,0 +1,4 @@ +wadm: + config: + nats: + server: "nats.default.svc.cluster.local:4222" diff --git a/charts/wadm/ct.yaml b/charts/wadm/ct.yaml new file mode 100644 index 00000000..1d8f20a8 --- /dev/null +++ b/charts/wadm/ct.yaml @@ -0,0 +1,3 @@ +validate-maintainers: false +target-branch: main # TODO: Remove this once chart-testing 3.10.1+ is released +helm-extra-args: --timeout 60s \ No newline at end of file diff --git a/charts/wadm/templates/NOTES.txt b/charts/wadm/templates/NOTES.txt new file mode 100644 index 00000000..e69de29b diff --git a/charts/wadm/templates/_helpers.tpl b/charts/wadm/templates/_helpers.tpl new file mode 100644 index 00000000..472212c7 --- /dev/null +++ b/charts/wadm/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "wadm.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 "wadm.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 "wadm.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "wadm.labels" -}} +helm.sh/chart: {{ include "wadm.chart" . }} +{{ include "wadm.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "wadm.selectorLabels" -}} +app.kubernetes.io/name: {{ include "wadm.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} \ No newline at end of file diff --git a/charts/wadm/templates/deployment.yaml b/charts/wadm/templates/deployment.yaml new file mode 100644 index 00000000..a8afae0f --- /dev/null +++ b/charts/wadm/templates/deployment.yaml @@ -0,0 +1,116 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "wadm.fullname" . }} + labels: + {{- include "wadm.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "wadm.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "wadm.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.wadm.image.repository }}:{{ .Values.wadm.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.wadm.image.pullPolicy }} + env: + - name: WADM_NATS_SERVER + value: {{ .Values.wadm.config.nats.server | quote }} + {{- if .Values.wadm.config.nats.seed }} + - name: WADM_NATS_NKEY + value: {{ .Values.wadm.config.nats.seed | quote }} + {{- end }} + {{- if .Values.wadm.config.nats.jwt }} + - name: WADM_NATS_JWT + value: {{ .Values.wadm.config.nats.jwt | quote }} + {{- end }} + {{- if .Values.wadm.config.nats.credsFile }} + - name: WADM_NATS_CREDS_FILE + value: {{ .Values.wadm.config.nats.credsFile | quote }} + {{- end }} + {{- if .Values.wadm.config.nats.tlsCaFile }} + - name: WADM_NATS_TLS_CA_FILE + value: {{ .Values.wadm.config.nats.tlsCaFile | quote }} + {{- end }} + {{- if .Values.wadm.config.hostId }} + - name: WADM_HOST_ID + value: {{ .Values.wadm.config.hostId | quote }} + {{- end }} + {{- if .Values.wadm.config.structuredLogging }} + - name: WADM_STRUCTURED_LOGGING + value: {{ .Values.wadm.config.structuredLogging | quote }} + {{- end }} + {{- if .Values.wadm.config.tracing }} + - name: WADM_TRACING_ENABLED + value: {{ .Values.wadm.config.tracing | quote }} + {{- end }} + {{- if .Values.wadm.config.tracingEndpoint }} + - name: WADM_TRACING_ENDPOINT + value: {{ .Values.wadm.config.tracingEndpoint | quote }} + {{- end }} + {{- if .Values.wadm.config.jetstreamDomain }} + - name: WADM_JETSTREAM_DOMAIN + value: {{ .Values.wadm.config.jetstreamDomain | quote }} + {{- end }} + {{- if .Values.wadm.config.maxJobs }} + - name: WADM_MAX_JOBS + value: {{ .Values.wadm.config.maxJobs }} + {{- end }} + {{- if .Values.wadm.config.stateBucket }} + - name: WADM_STATE_BUCKET_NAME + value: {{ .Values.wadm.config.stateBucket | quote }} + {{- end }} + {{- if .Values.wadm.config.manifestBucket }} + - name: WADM_MANIFEST_BUCKET_NAME + value: {{ .Values.wadm.config.manifestBucket | quote }} + {{- end }} + {{- if .Values.wadm.config.cleanupInterval }} + - name: WADM_CLEANUP_INTERVAL + value: {{ .Values.wadm.config.cleanupInterval }} + {{- end }} + {{- if .Values.wadm.config.apiPrefix }} + - name: WADM_API_PREFIX + value: {{ .Values.wadm.config.apiPrefix }} + {{- end }} + {{- if .Values.wadm.config.streamPrefix }} + - name: WADM_STREAM_PREFIX + value: {{ .Values.wadm.config.streamPrefix }} + {{- end }} + {{- if .Values.wadm.config.multitenant }} + - name: WADM_MULTITENANT + value: {{ .Values.wadm.config.multitenant | quote }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/wadm/values.yaml b/charts/wadm/values.yaml new file mode 100644 index 00000000..ec46815c --- /dev/null +++ b/charts/wadm/values.yaml @@ -0,0 +1,80 @@ +wadm: + # replicas represents the number of copies of wadm to run + replicas: 1 + # image represents the image and tag for running wadm + image: + repository: ghcr.io/wasmcloud/wadm + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + config: + apiPrefix: "" + streamPrefix: "" + cleanupInterval: "" + hostId: "" + logLevel: "" + nats: + credsFile: "" + jetstreamDomain: "" + jwt: "" + seed: "" + server: "127.0.0.1:4222" + tlsCaFile: "" + maxJobs: "" + stateBucket: "" + manifestBucket: "" + multitenant: false + structuredLogging: false + tracing: false + tracingEndpoint: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 1000 + +securityContext: + runAsUser: 1000 + runAsGroup: 1000 + runAsNonRoot: true + allowPrivilegeEscalation: false + capabilities: + drop: + - "ALL" + seccompProfile: + type: "RuntimeDefault" + + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}