Эх сурвалжийг харах

Merge pull request #9 from truenas/nextcloud-chart

Add nextcloud chart
Waqar Ahmed 4 жил өмнө
parent
commit
a2d9e44469

+ 4 - 0
features_capability.json

@@ -18,5 +18,9 @@
   "definitions/timezone": {
     "stable": {"min":  "20.12-ALPHA"},
     "nightlies": {"min":  "20.12-MASTER"}
+  },
+  "definitions/nodeIP": {
+    "stable": {"min":  "20.12-ALPHA"},
+    "nightlies": {"min":  "20.12-MASTER"}
   }
 }

+ 21 - 0
test/nextcloud/2.3.2/.helmignore

@@ -0,0 +1,21 @@
+# 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
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj

+ 15 - 0
test/nextcloud/2.3.2/Chart.yaml

@@ -0,0 +1,15 @@
+apiVersion: v2
+name: nextcloud
+version: 2.3.2
+appVersion: 19.0.3
+description: A file sharing server that puts the control and security of your own data back into your hands.
+keywords:
+- nextcloud
+- storage
+- http
+- web
+- php
+home: https://nextcloud.com/
+icon: https://cdn.rawgit.com/docker-library/docs/defa5ffc7123177acd60ddef6e16bddf694cc35f/nextcloud/logo.svg
+sources:
+- https://github.com/nextcloud/docker

+ 11 - 0
test/nextcloud/2.3.2/README.md

@@ -0,0 +1,11 @@
+# nextcloud
+
+[nextcloud](https://nextcloud.com/) is a file sharing server that puts the control and security of your own data back into your hands.
+
+## Introduction
+
+This chart bootstraps an [nextcloud](https://hub.docker.com/_/nextcloud/) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
+
+## Configuration
+
+Please refer to questions.yaml for a detailed overview on supported configurable values.

+ 3 - 0
test/nextcloud/2.3.2/app-readme.md

@@ -0,0 +1,3 @@
+# nextcloud
+
+[nextcloud](https://nextcloud.com/) is a file sharing server that puts the control and security of your own data back into your hands.

+ 198 - 0
test/nextcloud/2.3.2/questions.yaml

@@ -0,0 +1,198 @@
+groups:
+  - name: "Container Images"
+    description: "Image to be used for container"
+  - name: "Nextcloud Configuration"
+    description: "Configuration details for Nextcloud workload"
+  - name: "Storage"
+    description: "Configure Storage for Nextcloud"
+  - name: "Container Configuration"
+    description: "Configure nextcloud container parameters"
+  - name: "Postgresql Configuration"
+    description: "Configure Postgresql for nextcloud"
+
+portals:
+  web_portal:
+    protocols:
+      - "http"
+    host:
+      - "$variable-nextcloud.host"
+    ports:
+      - "$variable-service.nodePort"
+
+questions:
+  # Image related
+  - variable: image
+    description: "Docker Image Details"
+    label: "Docker Image"
+    group: "Container Images"
+    schema:
+      type: dict
+      required: true
+      attrs:
+        - variable: repository
+          description: "Docker image repository"
+          label: "Image repository"
+          schema:
+            type: string
+            default: "nextcloud"
+            required: true
+        - variable: tag
+          description: "Tag to use for specified image"
+          label: "Image Tag"
+          schema:
+            type: string
+            default: "latest"
+        - variable: pullPolicy
+          description: "Docker Image Pull Policy"
+          label: "Image Pull Policy"
+          schema:
+            type: string
+            default: "IfNotPresent"
+            enum:
+              - value: "IfNotPresent"
+                description: "Only pull image if not present on host"
+              - value: "Always"
+                description: "Always pull image even if present on host"
+              - value: "Never"
+                description: "Never pull image even if it's not present on host"
+
+  - variable: nextcloud
+    description: "Nextcloud configuration details"
+    label: "Nextcloud Configuration"
+    group: "Nextcloud Configuration"
+    schema:
+      type: dict
+      required: true
+      additional_attrs: true
+      attrs:
+        - variable: host
+          description: "Nextcloud host to create application URLs"
+          label: "Nextcloud host"
+          schema:
+            type: string
+            $ref:
+              - "definitions/nodeIP"
+        - variable: username
+          label: "Username"
+          schema:
+            type: string
+            default: "admin"
+            required: true
+        - variable: password
+          label: "Password"
+          schema:
+            type: string
+            private: true
+            default: "changeme"
+            required: true
+        - variable: datadir
+          label: "Nextcloud data directory"
+          schema:
+            type: path
+            default: "/var/www/html/data"
+            required: true
+        - variable: strategy
+          label: "Nextcloud update strategy"
+          schema:
+            type: string
+            default: "Recreate"
+            enum:
+              - value: "RollingUpdate"
+                description: "Create new pods and then kill old ones"
+              - value: "Recreate"
+                description: "Kill existing pods before creating new ones"
+
+  - variable: service
+    description: "Nextcloud Service Configuration"
+    label: "Nextcloud Service Configuration"
+    group: "Nextcloud Configuration"
+    schema:
+      type: dict
+      required: true
+      attrs:
+        - variable: nodePort
+          label: "Node Port to use for Nextcloud"
+          schema:
+            type: int
+            min: 9000
+            max: 65535
+            default: 9000
+            required: true
+
+  - variable: nextcloudDataHostPathEnabled
+    label: "Configure Host Path for Nextcloud data"
+    group: "Storage"
+    schema:
+      type: boolean
+      default: false
+      show_subquestions_if: true
+      subquestions:
+        - variable: nextcloudHostPath
+          label: "Specify HostPath for Nextcloud data"
+          schema:
+            type: hostpath
+
+  - variable: nextcloudDataVolume
+    label: "Configure iXVolume"
+    group: "Storage"
+    schema:
+      type: dict
+      $ref:
+        - "normalize/ixVolume"
+      show_if: [["nextcloudDataHostPathEnabled", "=", false]]
+      attrs:
+        - variable: mountPath
+          label: "Mount Path"
+          description: "Path where the volume will be mounted inside the pod"
+          schema:
+            type: path
+            editable: false
+            default: "/var/www"
+        - variable: datasetName
+          label: "Dataset Name"
+          schema:
+            type: string
+            default: "ix-nextcloud_data"
+            editable: false
+
+  - variable: postgresBackupVolume
+    label: "Postgres Backup Volume"
+    group: "Storage"
+    schema:
+      type: dict
+      $ref:
+        - "normalize/ixVolume"
+      attrs:
+        - variable: mountPath
+          label: "Mount Path"
+          schema:
+            type: path
+            editable: false
+            default: "/postgres_backups"
+        - variable: datasetName
+          label: "Dataset Name"
+          schema:
+            type: string
+            default: "ix-postgres_backups"
+            editable: false
+
+  - variable: postgresDataVolume
+    label: "Postgresql Data Volume"
+    group: "Storage"
+    schema:
+      type: dict
+      $ref:
+        - "normalize/ixVolume"
+      attrs:
+        - variable: mountPath
+          label: "Mount Path"
+          schema:
+            type: path
+            editable: false
+            default: "/var/lib/postgresql/data"
+        - variable: datasetName
+          label: "Dataset Name"
+          schema:
+            type: string
+            default: "ix-postgres_data"
+            editable: false

+ 3 - 0
test/nextcloud/2.3.2/templates/NOTES.txt

@@ -0,0 +1,3 @@
+1. Get the nextcloud URL by running:
+
+  echo http://{{ .Values.nextcloud.host }}:{{ .Values.service.nodePort }}/

+ 115 - 0
test/nextcloud/2.3.2/templates/_helpers.tpl

@@ -0,0 +1,115 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "nextcloud.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 "nextcloud.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 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).
+*/}}
+{{- define "nextcloud.mariadb.fullname" -}}
+{{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+
+{{/*
+Create a default fully qualified redis app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+*/}}
+{{- define "nextcloud.redis.fullname" -}}
+{{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "nextcloud.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Retrieve host path from ix volumes based on dataset name
+*/}}
+{{- define "retrieveHostPathFromiXVolume" -}}
+{{- range $index, $hostPathConfiguration := $.ixVolumes }}
+{{- $dsName := base $hostPathConfiguration.hostPath -}}
+{{- if eq $.datasetName $dsName -}}
+{{- $hostPathConfiguration.hostPath -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Retrieve host path defined in volume
+*/}}
+{{- define "configuredHostPath" -}}
+{{- if .Values.emptyDirVolumes -}}
+{{- printf "" -}}
+{{- else if .Values.nextcloudDataHostPathEnabled -}}
+{{- required "Please specify a host path for nextcloud" .Values.nextcloudHostPath -}}
+{{- else -}}
+{{- $volDict := dict "datasetName" $.Values.nextcloudDataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
+{{- include "retrieveHostPathFromiXVolume" $volDict -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Retrieve backup postgresql host path defined in volume
+*/}}
+{{- define "configuredBackupPostgresHostPath" -}}
+{{- if .Values.emptyDirVolumes -}}
+{{- printf "" -}}
+{{- else -}}
+{{- $volDict := dict "datasetName" $.Values.postgresBackupVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
+{{- include "retrieveHostPathFromiXVolume" $volDict -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Retrieve postgresql data host path defined in volume
+*/}}
+{{- define "configuredPostgresHostPath" -}}
+{{- if .Values.emptyDirVolumes -}}
+{{- printf "" -}}
+{{- else -}}
+{{- $volDict := dict "datasetName" $.Values.postgresDataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
+{{- include "retrieveHostPathFromiXVolume" $volDict -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Selector labels
+*/}}
+{{- define "nextcloud.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "nextcloud.name" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- end }}
+
+{{/*
+Postgres Selector labels
+*/}}
+{{- define "nextcloud.postgres.selectorLabels" -}}
+app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres
+app.kubernetes.io/instance: {{ .Release.Name }}-postgres
+{{- end }}

+ 113 - 0
test/nextcloud/2.3.2/templates/deployment.yaml

@@ -0,0 +1,113 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ template "nextcloud.fullname" . }}
+  labels:
+    app.kubernetes.io/name: {{ include "nextcloud.name" . }}
+    helm.sh/chart: {{ include "nextcloud.chart" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    app.kubernetes.io/component: app
+  {{- if .Values.deploymentAnnotations }}
+  annotations:
+{{ toYaml .Values.deploymentAnnotations | indent 4 }}
+  {{- end }}
+spec:
+  replicas: 1
+  strategy:
+    type: {{ .Values.nextcloud.strategy }}
+  selector:
+    matchLabels:
+      app.kubernetes.io/name: {{ include "nextcloud.name" . }}
+      app.kubernetes.io/instance: {{ .Release.Name }}
+      app.kubernetes.io/component: app
+  template:
+    metadata:
+      labels:
+        app.kubernetes.io/name: {{ include "nextcloud.name" . }}
+        app.kubernetes.io/instance: {{ .Release.Name }}
+        app.kubernetes.io/component: app
+      annotations:
+        rollme: {{ randAlphaNum 5 | quote }}
+    spec:
+      {{- if .Values.image.pullSecrets }}
+      imagePullSecrets:
+      {{- range .Values.image.pullSecrets }}
+        - name: {{ . }}
+      {{- end}}
+      {{- end }}
+      initContainers:
+        - name: init-postgresdb
+          image: busybox:latest
+          command: ['sh', '-c', "until nslookup {{ template "nextcloud.fullname" . }}-postgres; do echo waiting for postgres; sleep 2; done"]
+          imagePullPolicy: {{ .Values.image.pullPolicy }}
+      containers:
+      - name: {{ .Chart.Name }}
+        image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+        imagePullPolicy: {{ .Values.image.pullPolicy }}
+        env:
+        - name: POSTGRES_HOST
+          value: {{ template "nextcloud.fullname" . }}-postgres:5432
+        - name: POSTGRES_DB
+          value: "nextcloud"
+        - name: POSTGRES_USER
+          valueFrom:
+            secretKeyRef:
+              name: db-details
+              key: db-user
+        - name: POSTGRES_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: db-details
+              key: db-password
+        - name: NEXTCLOUD_ADMIN_USER
+          valueFrom:
+            secretKeyRef:
+              name: {{ template "nextcloud.fullname" . }}
+              key: nextcloud-username
+        - name: NEXTCLOUD_ADMIN_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: {{ template "nextcloud.fullname" . }}
+              key: nextcloud-password
+        - name: NEXTCLOUD_TRUSTED_DOMAINS
+          value: {{ .Values.nextcloud.host }}
+        - name: NEXTCLOUD_DATA_DIR
+          value: {{ .Values.nextcloud.datadir | quote }}
+        ports:
+        - name: http
+          containerPort: 80
+          protocol: TCP
+        volumeMounts:
+        - name: nextcloud-data
+          mountPath: /var/www/
+          subPath: "root"
+        - name: nextcloud-data
+          mountPath: /var/www/html
+          subPath: "html"
+        - name: nextcloud-data
+          mountPath: {{ .Values.nextcloud.datadir }}
+          subPath: "data"
+        - name: nextcloud-data
+          mountPath: /var/www/html/config
+          subPath: "config"
+        - name: nextcloud-data
+          mountPath: /var/www/html/custom_apps
+          subPath: "custom_apps"
+        - name: nextcloud-data
+          mountPath: /var/www/tmp
+          subPath: "tmp"
+        - name: nextcloud-data
+          mountPath: /var/www/html/themes
+          subPath: "themes"
+      volumes:
+      - name: nextcloud-data
+      {{- if ne (include "configuredHostPath" .) "" }}
+        hostPath:
+          path: {{ template "configuredHostPath" . }}
+      {{- else }}
+        emptyDir: {}
+      {{- end }}
+      # Will mount configuration files as www-data (id: 33) for nextcloud
+      securityContext:
+        fsGroup: 33

+ 64 - 0
test/nextcloud/2.3.2/templates/postgres-deployment.yaml

@@ -0,0 +1,64 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: {{ template "nextcloud.fullname" . }}-postgres
+  labels:
+    helm.sh/chart: {{ include "nextcloud.chart" . }}
+    {{- include "nextcloud.postgres.selectorLabels" . | nindent 4 }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    app.kubernetes.io/component: database
+spec:
+  replicas: 1
+  strategy:
+    type: {{ .Values.nextcloud.strategy }}
+  selector:
+    matchLabels:
+      {{- include "nextcloud.postgres.selectorLabels" . | nindent 6 }}
+      app.kubernetes.io/component: database
+  template:
+    metadata:
+      labels:
+        {{- include "nextcloud.postgres.selectorLabels" . | nindent 8 }}
+        app.kubernetes.io/component: database
+      annotations:
+        rollme: {{ randAlphaNum 5 | quote }}
+    spec:
+      containers:
+      - name: {{ .Chart.Name }}-postgres
+        image: "postgres:13.1"
+        imagePullPolicy: {{ .Values.image.pullPolicy }}
+        env:
+        - name: POSTGRES_USER
+          valueFrom:
+            secretKeyRef:
+              name: db-details
+              key: db-user
+        - name: POSTGRES_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              name: db-details
+              key: db-password
+        volumeMounts:
+          - name: postgres-data
+            mountPath: /var/lib/postgresql/data
+          - name: postgres-backup
+            mountPath: /postgres_backups
+        ports:
+        - name: postgres-tcp
+          containerPort: 5432
+          protocol: TCP
+      volumes:
+      - name: postgres-data
+        {{- if ne (include "configuredPostgresHostPath" .) "" }}
+        hostPath:
+          path: {{ template "configuredPostgresHostPath" . }}
+        {{- else }}
+        emptyDir: {}
+        {{- end }}
+      - name: postgres-backup
+        {{- if ne (include "configuredBackupPostgresHostPath" .) "" }}
+        hostPath:
+          path: {{ template "configuredBackupPostgresHostPath" . }}
+        {{- else }}
+        emptyDir: {}
+        {{- end }}

+ 13 - 0
test/nextcloud/2.3.2/templates/postgres-secret.yaml

@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: db-details
+data:
+  db-user: postgres
+  {{- if .Release.IsInstall }}
+  db-password: {{ randAlphaNum 15 | b64enc | quote }}
+  {{ else }}
+  # `index` function is necessary because the property name contains a dash.
+  # Otherwise (...).data.db_password would have worked too.
+  db-password:  {{ index (lookup "v1" "Secret" .Release.Namespace "db-details").data "db-password" }}
+  {{ end }}

+ 18 - 0
test/nextcloud/2.3.2/templates/postgres-service.yaml

@@ -0,0 +1,18 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ template "nextcloud.fullname" . }}-postgres
+  labels:
+    app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres
+    helm.sh/chart: {{ include "nextcloud.chart" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    app.kubernetes.io/component: app
+spec:
+  type: ClusterIP
+  ports:
+  - port: 5432
+    protocol: TCP
+    name: postgres-tcp
+  selector:
+    {{- include "nextcloud.postgres.selectorLabels" . | nindent 4 }}

+ 17 - 0
test/nextcloud/2.3.2/templates/secrets.yaml

@@ -0,0 +1,17 @@
+apiVersion: v1
+kind: Secret
+metadata:
+  name: {{ template "nextcloud.fullname" . }}
+  labels:
+    app.kubernetes.io/name: {{ include "nextcloud.name" . }}
+    helm.sh/chart: {{ include "nextcloud.chart" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+type: Opaque
+data:
+  nextcloud-username: {{ .Values.nextcloud.username | b64enc | quote }}
+  {{ if .Values.nextcloud.password }}
+  nextcloud-password: {{ .Values.nextcloud.password | b64enc | quote }}
+  {{ else }}
+  nextcloud-password: {{ randAlphaNum 10 | b64enc | quote }}
+  {{ end }}

+ 20 - 0
test/nextcloud/2.3.2/templates/service.yaml

@@ -0,0 +1,20 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: {{ template "nextcloud.fullname" . }}
+  labels:
+    app.kubernetes.io/name: {{ include "nextcloud.name" . }}
+    helm.sh/chart: {{ include "nextcloud.chart" . }}
+    app.kubernetes.io/instance: {{ .Release.Name }}
+    app.kubernetes.io/managed-by: {{ .Release.Service }}
+    app.kubernetes.io/component: app
+spec:
+  type: NodePort
+  ports:
+  - port: 80
+    targetPort: http
+    protocol: TCP
+    name: http
+    nodePort: {{ default "" .Values.service.nodePort}}
+  selector:
+    {{- include "nextcloud.selectorLabels" . | nindent 4 }}

+ 27 - 0
test/nextcloud/2.3.2/test_values.yaml

@@ -0,0 +1,27 @@
+## Official nextcloud image version
+## ref: https://hub.docker.com/r/library/nextcloud/tags/
+##
+image:
+  repository: nextcloud
+  tag: 19.0.3-apache
+  pullPolicy: IfNotPresent
+
+nextcloud:
+  host: nextcloud.kube.home
+  username: admin
+  password: changeme
+  datadir: /var/www/html/data
+  strategy: "Recreate"
+
+postgresql:
+  backupVolume:
+    mountPath: "/postgres_backups"
+    datasetName: "ix-postgres_backups"
+  dataVolume:
+    mountPath: "/var/lib/postgresql/data"
+    datasetName: "ix-postgres_data"
+
+service:
+  nodePort: 31000
+
+emptyDirVolumes: true

+ 17 - 0
test/nextcloud/2.3.2/values.yaml

@@ -0,0 +1,17 @@
+## Official nextcloud image version
+## ref: https://hub.docker.com/r/library/nextcloud/tags/
+##
+image:
+  repository: nextcloud
+  tag: 19.0.3-apache
+  pullPolicy: IfNotPresent
+
+nextcloud:
+  host: nextcloud.kube.home
+  username: admin
+  password: changeme
+  datadir: /var/www/html/data
+  strategy: "Recreate"
+
+service:
+  nodePort: 9000

+ 3 - 0
test/nextcloud/item.yaml

@@ -0,0 +1,3 @@
+categories:
+  - productivity
+icon_url: https://cdn.rawgit.com/docker-library/docs/defa5ffc7123177acd60ddef6e16bddf694cc35f/nextcloud/logo.svg