You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2020/11/05 04:40:36 UTC

[sling-org-apache-sling-app-cms] 04/04: Adding initial helm configuration

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit 6ab4cfe121f7c9d8bece1e4810cbc776a15f57ba
Author: Dan Klco <dk...@apache.org>
AuthorDate: Wed Nov 4 23:35:58 2020 -0500

    Adding initial helm configuration
---
 .helmignore                                        | 23 ++++++
 Chart.yaml                                         | 23 ++++++
 helm/slingcms-standalone/.helmignore               | 23 ++++++
 helm/slingcms-standalone/Chart.yaml                | 23 ++++++
 helm/slingcms-standalone/README.md                 | 20 ++++++
 helm/slingcms-standalone/templates/NOTES.txt       | 21 ++++++
 helm/slingcms-standalone/templates/_helpers.tpl    | 62 ++++++++++++++++
 helm/slingcms-standalone/templates/deployment.yaml | 80 +++++++++++++++++++++
 helm/slingcms-standalone/templates/ingress.yaml    | 41 +++++++++++
 .../templates/persistentvolumeclaim.yaml           | 13 ++++
 helm/slingcms-standalone/templates/service.yaml    | 15 ++++
 .../templates/serviceaccount.yaml                  | 12 ++++
 .../templates/tests/test-connection.yaml           | 15 ++++
 helm/slingcms-standalone/values.yaml               | 84 ++++++++++++++++++++++
 14 files changed, 455 insertions(+)

diff --git a/.helmignore b/.helmignore
new file mode 100644
index 0000000..0e8a0eb
--- /dev/null
+++ b/.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/Chart.yaml b/Chart.yaml
new file mode 100644
index 0000000..2c9cc6c
--- /dev/null
+++ b/Chart.yaml
@@ -0,0 +1,23 @@
+apiVersion: v2
+name: slingcms
+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.
+appVersion: 1.16.0
diff --git a/helm/slingcms-standalone/.helmignore b/helm/slingcms-standalone/.helmignore
new file mode 100644
index 0000000..0e8a0eb
--- /dev/null
+++ b/helm/slingcms-standalone/.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/helm/slingcms-standalone/Chart.yaml b/helm/slingcms-standalone/Chart.yaml
new file mode 100644
index 0000000..e44bb67
--- /dev/null
+++ b/helm/slingcms-standalone/Chart.yaml
@@ -0,0 +1,23 @@
+apiVersion: v2
+name: slingcms-standalone
+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.
+appVersion: 1.16.0
diff --git a/helm/slingcms-standalone/README.md b/helm/slingcms-standalone/README.md
new file mode 100644
index 0000000..db7cbc6
--- /dev/null
+++ b/helm/slingcms-standalone/README.md
@@ -0,0 +1,20 @@
+# Apache Sling CMS Standalone Helm Chart
+
+A Helm template for running Apache Sling CMS as a standalone instance in Kubernetes.
+
+## Local Setup
+
+Setup a Sling CMS standalone instance running in a local minukube Kubernetes instance. 
+
+Requires [minikube](https://minikube.sigs.k8s.io/docs/start/)
+
+Steps: 
+
+ 1. Start minikube in a VM (for ingress support) `minikube start --vm=true`
+ 2. Enable ingress support: `minikube addons enable ingress`
+ 3. Set minkube to use the docker env `eval $(minikube docker-env)`
+ 4. Build the cms image `docker build -t org.apache.sling.cms.docker.cms:0.16.3-snapshot ../../docker/cms`
+ 5. Build the web image `docker build -t org.apache.sling.cms.docker.web:0.16.3-snapshot ../../docker/webcache`
+ 6. Get minikube's IP: `minikube ip`
+ 7. Update /etc/hosts with entries for `sling2.apache.local` and `cms.sling.apache.local` for minikube's IP\
+ 8. Install the helm chart with: `helm install [name] .`
\ No newline at end of file
diff --git a/helm/slingcms-standalone/templates/NOTES.txt b/helm/slingcms-standalone/templates/NOTES.txt
new file mode 100644
index 0000000..18bc230
--- /dev/null
+++ b/helm/slingcms-standalone/templates/NOTES.txt
@@ -0,0 +1,21 @@
+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 }}{{ . }}
+  {{- 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 "chart2.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 the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "chart2.fullname" . }}'
+  export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "chart2.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 "chart2.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+  echo "Visit http://127.0.0.1:8080 to use your application"
+  kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80
+{{- end }}
diff --git a/helm/slingcms-standalone/templates/_helpers.tpl b/helm/slingcms-standalone/templates/_helpers.tpl
new file mode 100644
index 0000000..c9d2ce0
--- /dev/null
+++ b/helm/slingcms-standalone/templates/_helpers.tpl
@@ -0,0 +1,62 @@
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "slingcms-standalone.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 "slingcms-standalone.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 "slingcms-standalone.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
+{{- end }}
+
+{{/*
+Common labels
+*/}}
+{{- define "slingcms-standalone.labels" -}}
+helm.sh/chart: {{ include "slingcms-standalone.chart" . }}
+{{ include "slingcms-standalone.selectorLabels" . }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end }}
+
+{{/*
+Selector labels
+*/}}
+{{- define "slingcms-standalone.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "slingcms-standalone.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "slingcms-standalone.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create }}
+{{- default (include "slingcms-standalone.fullname" .) .Values.serviceAccount.name }}
+{{- else }}
+{{- default "default" .Values.serviceAccount.name }}
+{{- end }}
+{{- end }}
diff --git a/helm/slingcms-standalone/templates/deployment.yaml b/helm/slingcms-standalone/templates/deployment.yaml
new file mode 100644
index 0000000..af81b26
--- /dev/null
+++ b/helm/slingcms-standalone/templates/deployment.yaml
@@ -0,0 +1,80 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ include "slingcms-standalone.fullname" . }}
+  labels:
+    {{- include "slingcms-standalone.labels" . | nindent 4 }}
+spec:
+{{- if not .Values.autoscaling.enabled }}
+  replicas: {{ .Values.replicaCount }}
+{{- end }}
+  selector:
+    matchLabels:
+      {{- include "slingcms-standalone.selectorLabels" . | nindent 6 }}
+  template:
+    metadata:
+    {{- with .Values.podAnnotations }}
+      annotations:
+        {{- toYaml . | nindent 8 }}
+    {{- end }}
+      labels:
+        {{- include "slingcms-standalone.selectorLabels" . | nindent 8 }}
+    spec:
+      {{- with .Values.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      serviceAccountName: {{ include "slingcms-standalone.serviceAccountName" . }}
+      securityContext:
+        {{- toYaml .Values.podSecurityContext | nindent 8 }}
+      containers:
+        - name: {{ printf "%s-cms" .Chart.Name }}
+          securityContext:
+            {{- toYaml .Values.securityContext | nindent 12 }}
+          image: "{{ .Values.image.cms.repository }}:{{ .Values.image.cms.tag | default .Chart.AppVersion }}"
+          imagePullPolicy: {{ .Values.image.cms.pullPolicy }}
+          ports:
+            - name: http
+              containerPort: 8080
+              protocol: TCP
+          livenessProbe:
+            httpGet:
+              path: /system/health
+              port: http
+          readinessProbe:
+            httpGet:
+              path: /system/health
+              port: http
+          resources:
+            {{- toYaml .Values.resources.cms | nindent 12 }}
+        - name: {{ printf "%s-web" .Chart.Name }}
+          securityContext:
+            {{- toYaml .Values.securityContext | nindent 12 }}
+          image: "{{ .Values.image.web.repository }}:{{ .Values.image.web.tag | default .Chart.AppVersion }}"
+          imagePullPolicy: {{ .Values.image.web.pullPolicy }}
+          ports:
+            - name: http
+              containerPort: 80
+              protocol: TCP
+          livenessProbe:
+            httpGet:
+              path: /
+              port: http
+          readinessProbe:
+            httpGet:
+              path: /
+              port: http
+          resources:
+            {{- toYaml .Values.resources.web | 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/helm/slingcms-standalone/templates/ingress.yaml b/helm/slingcms-standalone/templates/ingress.yaml
new file mode 100644
index 0000000..bd3d413
--- /dev/null
+++ b/helm/slingcms-standalone/templates/ingress.yaml
@@ -0,0 +1,41 @@
+{{- if .Values.ingress.enabled -}}
+{{- $fullName := include "slingcms-standalone.fullname" . -}}
+{{- $svcPort := .Values.service.port -}}
+{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
+apiVersion: networking.k8s.io/v1beta1
+{{- else -}}
+apiVersion: extensions/v1beta1
+{{- end }}
+kind: Ingress
+metadata:
+  name: {{ $fullName }}
+  labels:
+    {{- include "slingcms-standalone.labels" . | nindent 4 }}
+  {{- with .Values.ingress.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+spec:
+  {{- if .Values.ingress.tls }}
+  tls:
+    {{- range .Values.ingress.tls }}
+    - hosts:
+        {{- range .hosts }}
+        - {{ . | quote }}
+        {{- end }}
+      secretName: {{ .secretName }}
+    {{- end }}
+  {{- end }}
+  rules:
+    {{- range .Values.ingress.hosts }}
+    - host: {{ .host | quote }}
+      http:
+        paths:
+          {{- range .paths }}
+          - path: {{ . }}
+            backend:
+              serviceName: {{ $fullName }}
+              servicePort: {{ $svcPort }}
+          {{- end }}
+    {{- end }}
+  {{- end }}
diff --git a/helm/slingcms-standalone/templates/persistentvolumeclaim.yaml b/helm/slingcms-standalone/templates/persistentvolumeclaim.yaml
new file mode 100644
index 0000000..6b0bce7
--- /dev/null
+++ b/helm/slingcms-standalone/templates/persistentvolumeclaim.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: {{ include "slingcms-standalone.fullname" . }}
+  labels:
+    {{- include "slingcms-standalone.labels" . | nindent 4 }}
+spec:
+  accessModes:
+  - ReadWriteOnce
+  resources:
+    requests:
+      storage: {{ default "80Gi" .Values.storage }}
+status: {}
diff --git a/helm/slingcms-standalone/templates/service.yaml b/helm/slingcms-standalone/templates/service.yaml
new file mode 100644
index 0000000..ebea78d
--- /dev/null
+++ b/helm/slingcms-standalone/templates/service.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ include "slingcms-standalone.fullname" . }}
+  labels:
+    {{- include "slingcms-standalone.labels" . | nindent 4 }}
+spec:
+  type: {{ .Values.service.type }}
+  ports:
+    - port: {{ .Values.service.port }}
+      targetPort: http
+      protocol: TCP
+      name: http
+  selector:
+    {{- include "slingcms-standalone.selectorLabels" . | nindent 4 }}
diff --git a/helm/slingcms-standalone/templates/serviceaccount.yaml b/helm/slingcms-standalone/templates/serviceaccount.yaml
new file mode 100644
index 0000000..a2ba57c
--- /dev/null
+++ b/helm/slingcms-standalone/templates/serviceaccount.yaml
@@ -0,0 +1,12 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: {{ include "slingcms-standalone.serviceAccountName" . }}
+  labels:
+    {{- include "slingcms-standalone.labels" . | nindent 4 }}
+  {{- with .Values.serviceAccount.annotations }}
+  annotations:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+{{- end }}
diff --git a/helm/slingcms-standalone/templates/tests/test-connection.yaml b/helm/slingcms-standalone/templates/tests/test-connection.yaml
new file mode 100644
index 0000000..cd2a48b
--- /dev/null
+++ b/helm/slingcms-standalone/templates/tests/test-connection.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Pod
+metadata:
+  name: "{{ include "slingcms-standalone.fullname" . }}-test-connection"
+  labels:
+    {{- include "slingcms-standalone.labels" . | nindent 4 }}
+  annotations:
+    "helm.sh/hook": test-success
+spec:
+  containers:
+    - name: wget
+      image: busybox
+      command: ['wget']
+      args: ['{{ include "slingcms-standalone.fullname" . }}:{{ .Values.service.port }}']
+  restartPolicy: Never
diff --git a/helm/slingcms-standalone/values.yaml b/helm/slingcms-standalone/values.yaml
new file mode 100644
index 0000000..ac25fd4
--- /dev/null
+++ b/helm/slingcms-standalone/values.yaml
@@ -0,0 +1,84 @@
+# Default values for slingcms.
+# This is a YAML-formatted file.
+# Declare variables to be passed into your templates.
+
+replicaCount: 1
+
+image:
+  cms:
+    repository: org.apache.sling.cms.docker.cms
+    pullPolicy: Never
+    # Overrides the image tag whose default is the chart appVersion.
+    tag: 0.16.3-snapshot
+  web:
+    repository: org.apache.sling.cms.docker.web
+    pullPolicy: Never
+    # Overrides the image tag whose default is the chart appVersion.
+    tag: 0.16.3-snapshot
+
+resources:
+  cms:
+    requests:
+      cpu: 500m
+      memory: 512Mi
+  web: {}
+
+imagePullSecrets: {}
+nameOverride: ""
+fullnameOverride: ""
+
+serviceAccount:
+  # Specifies whether a service account should be created
+  create: 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: {}
+
+podSecurityContext:
+  {}
+  # fsGroup: 2000
+
+securityContext:
+  {}
+  # capabilities:
+  #   drop:
+  #   - ALL
+  # readOnlyRootFilesystem: true
+  # runAsNonRoot: true
+  # runAsUser: 1000
+
+service:
+  type: ClusterIP
+  port: 80
+
+ingress:
+  enabled: true
+  annotations:
+    {}
+    # kubernetes.io/ingress.class: nginx
+    # kubernetes.io/tls-acme: "true"
+  hosts:
+    - host: sling2.apache.local
+      paths: [/]
+    - host: cms.sling.apache.local
+      paths: [/]
+  tls: []
+  #  - secretName: chart-example-tls
+  #    hosts:
+  #      - chart-example.local
+
+autoscaling:
+  enabled: false
+  minReplicas: 1
+  maxReplicas: 100
+  targetCPUUtilizationPercentage: 80
+
+nodeSelector: {}
+
+tolerations: []
+
+affinity: {}