From 2efb80a482db7f2a49e34ea044fcf89080252cdc Mon Sep 17 00:00:00 2001 From: Maik Schreiber Date: Tue, 14 Nov 2023 16:36:14 +0100 Subject: [PATCH] [sophora-seo-check]: add Sophora SEO Check (#60) * add Sophora SEO Check * use StatefulSet instead of Deployment; use emptyDir volume to store downloaded additional data files * remove unnecessary headless service --- charts/sophora-seo-check/.helmignore | 23 ++++ charts/sophora-seo-check/Chart.yaml | 6 + charts/sophora-seo-check/README.md | 51 +++++++++ .../sophora-seo-check/templates/_helpers.tpl | 64 +++++++++++ .../templates/configmap.yaml | 8 ++ .../templates/extra-list.yaml | 4 + .../sophora-seo-check/templates/ingress.yaml | 41 +++++++ .../sophora-seo-check/templates/service.yaml | 18 +++ .../templates/statefulset.yaml | 106 ++++++++++++++++++ charts/sophora-seo-check/test-values.yaml | 51 +++++++++ charts/sophora-seo-check/values.yaml | 61 ++++++++++ 11 files changed, 433 insertions(+) create mode 100644 charts/sophora-seo-check/.helmignore create mode 100644 charts/sophora-seo-check/Chart.yaml create mode 100644 charts/sophora-seo-check/README.md create mode 100644 charts/sophora-seo-check/templates/_helpers.tpl create mode 100644 charts/sophora-seo-check/templates/configmap.yaml create mode 100644 charts/sophora-seo-check/templates/extra-list.yaml create mode 100644 charts/sophora-seo-check/templates/ingress.yaml create mode 100644 charts/sophora-seo-check/templates/service.yaml create mode 100644 charts/sophora-seo-check/templates/statefulset.yaml create mode 100644 charts/sophora-seo-check/test-values.yaml create mode 100644 charts/sophora-seo-check/values.yaml diff --git a/charts/sophora-seo-check/.helmignore b/charts/sophora-seo-check/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/sophora-seo-check/.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/sophora-seo-check/Chart.yaml b/charts/sophora-seo-check/Chart.yaml new file mode 100644 index 0000000..9b344f4 --- /dev/null +++ b/charts/sophora-seo-check/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: sophora-seo-check +description: Sophora SEO Check +type: application +version: 1.0.0 +appVersion: 4.12.0 diff --git a/charts/sophora-seo-check/README.md b/charts/sophora-seo-check/README.md new file mode 100644 index 0000000..b41fc93 --- /dev/null +++ b/charts/sophora-seo-check/README.md @@ -0,0 +1,51 @@ +# Sophora SEO Check + +The [SEO Check] module supports the editorial team in the on-page content optimization of individual documents in the Sophora CMS. +The SEO Check checks the documents for occurrences of SEO keywords, readability, cross-linking and multimedia. Additionally, +the SEO Check shows relevant information about the document. + + +## Deployment of Additional Data Files + +SEO Check requires additional data files to run. These can be downloaded from the +[documentation](https://subshell.com/docs/seocheck/4/seocheck104.html#Example-Word-Lists-in-German-and-English) +and can then by modified by the administrator. + + +### Google Cloud Storage Credentials + +This chart runs an init container to make the additional files available to SEO Check. The files will be downloaded +from a Google Cloud Storage bucket, where they must be placed by the administrator. + +To authenticate with Google Cloud Storage, the init container will use the secret `-init-gcp-credentials`. +This secret must be created prior to the installation of the chart. + +To create the credentials secret, have your credentials JSON file ready. You can export this file +in the IAM section in Google Cloud Platform. + +To create the secret, run the following command: + +``` +kubectl create secret generic -init-gcp-credentials \ + --from-literal "credentials.json=$(cat my-project-credentials.json)" +``` + +Replace `` with the name of your release. +Replace the path to `my-project-credentials.json` with the path to your actual credentials JSON file. + + +### Google Cloud Storage Base URI + +The init container needs to know the base URI of the Google Cloud Storage bucket where it can find the +additional data files. In your `values.yaml` file, you must set `seoCheck.init.googleStorageBaseURI`. + +The data files must be placed inside the subfolder `/seo-check-data`. + +For example: + +- `seoCheck.init.googleStorageBaseURI: gs://sophora-seo-check` +- Folder to place additional data files in: `gs://sophora-seo-check/seo-check-data` + + + +[SEO Check]: https://subshell.com/sophora/modules/sophora-seo-check104.html diff --git a/charts/sophora-seo-check/templates/_helpers.tpl b/charts/sophora-seo-check/templates/_helpers.tpl new file mode 100644 index 0000000..05d66d8 --- /dev/null +++ b/charts/sophora-seo-check/templates/_helpers.tpl @@ -0,0 +1,64 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "sophora-seo-check.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 "sophora-seo-check.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 "sophora-seo-check.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "sophora-seo-check.labels" -}} +helm.sh/chart: {{ include "sophora-seo-check.chart" . }} +{{ include "sophora-seo-check.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "sophora-seo-check.selectorLabels" -}} +app.kubernetes.io/name: {{ include "sophora-seo-check.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Renders a value that contains template. +Usage: +{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $) }} +*/}} +{{- define "common.tplvalues.render" -}} + {{- if typeIs "string" .value }} + {{- tpl .value .context }} + {{- else }} + {{- tpl (.value | toYaml) .context }} + {{- end }} +{{- end -}} diff --git a/charts/sophora-seo-check/templates/configmap.yaml b/charts/sophora-seo-check/templates/configmap.yaml new file mode 100644 index 0000000..b438dc3 --- /dev/null +++ b/charts/sophora-seo-check/templates/configmap.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "sophora-seo-check.fullname" . }} + labels: + {{- include "sophora-seo-check.labels" . | nindent 4 }} +data: + application.yaml: |- {{ toYaml (required "A valid application.yaml config is required" .Values.sophora.configuration) | nindent 4 }} diff --git a/charts/sophora-seo-check/templates/extra-list.yaml b/charts/sophora-seo-check/templates/extra-list.yaml new file mode 100644 index 0000000..9ac65f9 --- /dev/null +++ b/charts/sophora-seo-check/templates/extra-list.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraDeploy }} +--- +{{ include "common.tplvalues.render" (dict "value" . "context" $) }} +{{- end }} diff --git a/charts/sophora-seo-check/templates/ingress.yaml b/charts/sophora-seo-check/templates/ingress.yaml new file mode 100644 index 0000000..198f372 --- /dev/null +++ b/charts/sophora-seo-check/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} + {{- $fullName := include "sophora-seo-check.fullname" . -}} + {{- $svcPort := .Values.service.port -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "sophora-seo-check.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName }} + {{- end -}} + {{- 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: + - path: {{ .path }} + pathType: {{ default "ImplementationSpecific" .pathType }} + backend: + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- end }} + {{- end }} diff --git a/charts/sophora-seo-check/templates/service.yaml b/charts/sophora-seo-check/templates/service.yaml new file mode 100644 index 0000000..b7bb721 --- /dev/null +++ b/charts/sophora-seo-check/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "sophora-seo-check.fullname" . }} + labels: + {{- include "sophora-seo-check.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + {{- include "sophora-seo-check.selectorLabels" . | nindent 4 }} + type: {{ .Values.service.type }} + ports: + - protocol: TCP + targetPort: http + port: {{ .Values.service.port }} diff --git a/charts/sophora-seo-check/templates/statefulset.yaml b/charts/sophora-seo-check/templates/statefulset.yaml new file mode 100644 index 0000000..e4e6b22 --- /dev/null +++ b/charts/sophora-seo-check/templates/statefulset.yaml @@ -0,0 +1,106 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "sophora-seo-check.fullname" . }} + labels: + {{- include "sophora-seo-check.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "sophora-seo-check.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + cluster-autoscaler.kubernetes.io/safe-to-evict: "true" + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "sophora-seo-check.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + initContainers: + - name: seo-check-init + image: docker.subshell.com/sophora/seocheck-k8s-init:latest + imagePullPolicy: IfNotPresent + restartPolicy: Always + env: + - name: GOOGLE_STORAGE_BASE_URI + value: {{ .Values.seoCheck.init.googleStorageBaseURI }} + volumeMounts: + - name: init-gcp-credentials + mountPath: /init-data + readOnly: true + - name: data + mountPath: /seo-check-data + containers: + - name: seo-check + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + volumeMounts: + - name: persistent-data + mountPath: /data + - name: config + mountPath: /data/config + readOnly: true + - name: data + mountPath: /init-data + readOnly: true + ports: + - name: http + protocol: TCP + containerPort: 8080 + env: + - name: JDK_JAVA_OPTIONS + value: {{ .Values.javaOptions }} + - name: SOPHORA_CLIENT_SERVERCONNECTION_USERNAME + valueFrom: + secretKeyRef: + name: {{ required "A valid secret name must be provided in .Values.sophora.authentication.secret.name" .Values.sophora.authentication.secret.name | quote }} + key: {{ .Values.sophora.authentication.secret.usernameKey | quote }} + - name: SOPHORA_CLIENT_SERVERCONNECTION_PASSWORD + valueFrom: + secretKeyRef: + name: {{ required "A valid secret name must be provided in .Values.sophora.authentication.secret.name" .Values.sophora.authentication.secret.name | quote }} + key: {{ .Values.sophora.authentication.secret.passwordKey | quote }} + {{- if .Values.seoCheck.extraEnv }} + {{- toYaml .Values.seoCheck.extraEnv | nindent 12 }} + {{- end }} + startupProbe: + httpGet: + port: http + path: /actuator/health + periodSeconds: 1 + failureThreshold: 30 + livenessProbe: + httpGet: + port: http + path: /actuator/health + readinessProbe: + httpGet: + port: http + path: /actuator/health + volumes: + - name: config + configMap: + name: {{ include "sophora-seo-check.fullname" . }} + - name: init-gcp-credentials + secret: + secretName: {{ include "sophora-seo-check.fullname" . }}-init-gcp-credentials + - name: data + emptyDir: + sizelimit: {{ .Values.storage.dataSize }} + volumeClaimTemplates: + - metadata: + name: persistent-data + spec: + accessModes: + - ReadWriteOnce + storageClassName: {{ .Values.storage.storageClass }} + resources: + requests: + storage: {{ .Values.storage.persistentDataSize }} diff --git a/charts/sophora-seo-check/test-values.yaml b/charts/sophora-seo-check/test-values.yaml new file mode 100644 index 0000000..e31c915 --- /dev/null +++ b/charts/sophora-seo-check/test-values.yaml @@ -0,0 +1,51 @@ +nameOverride: "" +fullnameOverride: "" + +image: + repository: docker.subshell.com/sophora/seocheck + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +imagePullSecrets: [] + +javaOptions: -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem + +sophora: + authentication: + secret: + name: sophora-secret + + # Represents the application.yaml of Sophora SEO Check + configuration: + # Settings for the Sophora server connection. + sophora: + client: + server-connection: + urls: [] + username: # in secret + password: # in secret + + # Settings for the SEO Check. + seo-check: + +seoCheck: + extraEnv: + +service: + type: ClusterIP + port: 8080 + annotations: {} + +ingress: + enabled: false + ingressClassName: nginx + annotations: {} + hosts: + tls: [] + +extraDeploy: [] + +podAnnotations: {} + +pvcAnnotations: {} diff --git a/charts/sophora-seo-check/values.yaml b/charts/sophora-seo-check/values.yaml new file mode 100644 index 0000000..05ff488 --- /dev/null +++ b/charts/sophora-seo-check/values.yaml @@ -0,0 +1,61 @@ +nameOverride: "" +fullnameOverride: "" + +image: + repository: docker.subshell.com/sophora/seocheck + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "4.0.0" + +imagePullSecrets: [] + +javaOptions: -XX:+ExitOnOutOfMemoryError -XX:+PerfDisableSharedMem + +sophora: + authentication: + secret: + name: "" + usernameKey: username + passwordKey: password + + # Represents the application.yaml of Sophora SEO Check + configuration: + # Settings for the Sophora server connection. + sophora: + client: + server-connection: + urls: [] + username: # in secret + password: # in secret + + # Settings for the SEO Check. + seo-check: + +seoCheck: + init: + googleStorageBaseURI: gs://sophora-seo-check + + extraEnv: + +storage: + storageClass: ssd + dataSize: 200Mi + persistentDataSize: 100Mi + +service: + type: ClusterIP + port: 8080 + annotations: {} + +ingress: + enabled: false + ingressClassName: nginx + annotations: {} + hosts: + tls: [] + +extraDeploy: [] + +podAnnotations: {} + +pvcAnnotations: {}