Skip to content

WIP feature(demo): add a example for cms #41

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
23 changes: 23 additions & 0 deletions applications/cms/charts/strapi/.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/
6 changes: 6 additions & 0 deletions applications/cms/charts/strapi/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: replicated
repository: oci://registry.replicated.com/library
version: 1.2.0
digest: sha256:2dc1a4c90d9297812b800e35913980fccdf3e5d0d31dd08f1df32e7e4da86ec6
generated: "2025-03-31T14:34:59.348191+13:00"
29 changes: 29 additions & 0 deletions applications/cms/charts/strapi/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: v2
name: strapi
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: "3.6.8"
dependencies:
- name: replicated
version: "~1.2.0"
repository: "oci://registry.replicated.com/library"
condition: replicated.enabled
22 changes: 22 additions & 0 deletions applications/cms/charts/strapi/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 }}://{{ $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 "strapi.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 "strapi.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "strapi.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 "strapi.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 }}
62 changes: 62 additions & 0 deletions applications/cms/charts/strapi/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "strapi.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 "strapi.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 "strapi.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "strapi.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "strapi.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions applications/cms/charts/strapi/templates/claim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.storage.claim.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "strapi.fullname" . }}-pvc
annotations:
"helm.sh/resource-policy": keep
labels:
{{- include "strapi.labels" . | nindent 4 }}
spec:
accessModes: {{ .Values.storage.accessModes }}
{{- if .Values.storage.storageClassName }}
storageClassName: {{ .Values.storage.storageClassName }}
{{- end }}
resources:
requests:
storage: {{ .Values.storage.capacity }}
{{- end }}
10 changes: 10 additions & 0 deletions applications/cms/charts/strapi/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.configMap.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "strapi.fullname" . }}
data:
{{- range $key, $value := .Values.configMap.data }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
80 changes: 80 additions & 0 deletions applications/cms/charts/strapi/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "strapi.fullname" . }}
labels:
{{- include "strapi.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "strapi.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "strapi.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "strapi.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.storage.claim.enabled }}
volumeMounts:
- name: {{ include "strapi.fullname" . }}-storage
mountPath: {{ .Values.storage.mountPath }}
{{- end }}
{{- if or .Values.configMap.enabled .Values.secret.enabled }}
envFrom:
{{- if .Values.configMap.enabled }}
- configMapRef:
name: {{ include "strapi.fullname" . }}
{{- end }}
{{- if .Values.secret.enabled }}
- secretRef:
name: {{ include "strapi.fullname" . }}
{{- end }}
{{- end }}
{{- if .Values.storage.claim.enabled }}
volumes:
- name: {{ include "strapi.fullname" . }}-storage
persistentVolumeClaim:
claimName: {{ include "strapi.fullname" . }}-pvc
{{- 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 }}
67 changes: 67 additions & 0 deletions applications/cms/charts/strapi/templates/postgres-db.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{{- if .Values.postgres.embedded.enabled -}}
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: postgres
{{- with .Values.postgres.embedded.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
{{- end }}
labels:
{{- with .Values.postgres.embedded.additionalLabels }}
{{ toYaml . | nindent 4 }}
{{- end }}
spec:
bootstrap:
initdb:
database: {{ .Values.postgres.embedded.initdb.database | quote }}
owner: {{ .Values.postgres.embedded.initdb.owner | quote }}
secret:
name: {{ .Values.postgres.embedded.initdb.secret.name }}
instances: 1
imageName: "{{ .Values.postgres.embedded.image.repository }}:{{ .Values.postgres.embedded.image.tag }}"
imagePullPolicy: {{ .Values.postgres.embedded.imagePullPolicy }}
{{- with .Values.postgres.embedded.imagePullSecrets}}
imagePullSecrets:
{{- . | toYaml | nindent 4 }}
{{- end }}
postgresUID: {{ .Values.postgres.embedded.postgresUID }}
postgresGID: {{ .Values.postgres.embedded.postgresGID }}
storage:
size: {{ .Values.postgres.embedded.storage.size }}
storageClass: {{ .Values.postgres.embedded.storage.storageClass }}
{{- with .Values.postgres.embedded.resources }}
resources:
{{- toYaml . | nindent 4 }}
{{ end }}
{{- with .Values.postgres.embedded.affinity }}
affinity:
{{- toYaml . | nindent 4 }}
{{- end }}
priorityClassName: {{ .Values.postgres.embedded.priorityClassName }}
primaryUpdateMethod: {{ .Values.postgres.embedded.primaryUpdateMethod }}
primaryUpdateStrategy: {{ .Values.postgres.embedded.primaryUpdateStrategy }}
logLevel: {{ .Values.postgres.embedded.logLevel }}
{{- with .Values.postgres.embedded.certificates }}
certificates:
{{- toYaml . | nindent 4 }}
{{ end }}
enableSuperuserAccess: {{ .Values.postgres.embedded.enableSuperuserAccess }}
{{- with .Values.postgres.embedded.superuserSecret }}
superuserSecret:
name: {{ . }}
{{ end }}
postgresql:
{{- with .Values.postgres.embedded.postgresql }}
parameters:
{{- toYaml . | nindent 6 }}
{{ end }}
managed:
{{- with .Values.postgres.embedded.roles }}
roles:
{{- toYaml . | nindent 6 }}
{{ end }}
{{- end -}}
21 changes: 21 additions & 0 deletions applications/cms/charts/strapi/templates/postgres-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.postgres.embedded.enabled -}}
apiVersion: v1
kind: Secret
metadata:
name: postgres-initdb-secret
{{- with .Values.postgres.embedded.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
{{- end }}
labels:
{{- with .Values.postgres.embedded.additionalLabels }}
{{ toYaml . | nindent 4 }}
{{- end }}
type: kubernetes.io/basic-auth
stringData:
username: {{ .Values.postgres.auth.username }}
password: {{ .Values.postgres.auth.password }}
{{- end -}}
24 changes: 24 additions & 0 deletions applications/cms/charts/strapi/templates/postgres-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.postgres.embedded.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: postgres-nodeport
labels:
app.kubernetes.io/name: postgres
app.kubernetes.io/instance: postgres
app.kubernetes.io/component: primary
cnpg.io/cluster: postgres
cnpg.io/instanceRole: primary
spec:
type: {{ .Values.postgres.embedded.service.type | default "ClusterIP" }}
ports:
- name: postgres
port: {{ .Values.postgres.embedded.service.port | default 5432 }}
targetPort: {{ .Values.postgres.embedded.service.targetPort | default 5432 }}
{{- if eq .Values.postgres.embedded.service.type "NodePort" }}
nodePort: {{ .Values.postgres.embedded.service.nodePort | default 5432 }}
{{- end }}
selector:
cnpg.io/cluster: postgres
cnpg.io/instanceRole: primary
{{- end -}}
11 changes: 11 additions & 0 deletions applications/cms/charts/strapi/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.secret.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "strapi.fullname" . }}
type: Opaque
data:
{{- range $key, $value := .Values.secret.data }}
{{ $key }}: {{ $value | b64enc }}
{{- end }}
{{- end }}
Loading