commit e84230ec292886a2696e90b50c71d20ed65d3b8e Author: Your Name Date: Thu Jun 17 10:14:15 2021 +0100 Initial Commit diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..7b87d66 --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: owncloud +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/README.md b/README.md new file mode 100644 index 0000000..9914fe4 --- /dev/null +++ b/README.md @@ -0,0 +1,58 @@ +# owncloud + +![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.16.0](https://img.shields.io/badge/AppVersion-1.16.0-informational?style=flat-square) + +A Helm chart for Kubernetes + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | | +| autoscaling.enabled | bool | `false` | | +| autoscaling.maxReplicas | int | `100` | | +| autoscaling.minReplicas | int | `1` | | +| autoscaling.targetCPUUtilizationPercentage | int | `80` | | +| externalDatabase.host | string | `""` | | +| externalDatabase.name | string | `"owncloud"` | | +| externalDatabase.password | string | `"owncloud"` | | +| externalDatabase.port | int | `3306` | | +| externalDatabase.type | string | `""` | | +| externalDatabase.user | string | `"owncloud"` | | +| fullnameOverride | string | `""` | | +| image.pullPolicy | string | `"IfNotPresent"` | | +| image.repository | string | `"docker.io/owncloud/server"` | | +| image.tag | float | `10.6` | | +| imagePullSecrets | list | `[]` | | +| ingress.annotations | string | `nil` | | +| ingress.enabled | bool | `true` | | +| ingress.hosts[0].host | string | `"owncloud.chart.example"` | | +| ingress.hosts[0].paths[0] | string | `"/*"` | | +| ingress.hosts[0].servicePort | int | `80` | | +| ingress.tls[0].hosts[0] | string | `"owncloud.chart.example"` | | +| ingress.tls[0].secretName | string | `"owncloud"` | | +| mariadb.enabled | bool | `false` | | +| nameOverride | string | `""` | | +| nodeSelector | object | `{}` | | +| owncloud.domain | string | `"owncloud.chart.example"` | | +| owncloud.password | string | `"owncloud"` | | +| owncloud.username | string | `"owncloud"` | | +| persistence.enabled | bool | `true` | | +| persistence.owncloud.accessMode | string | `"ReadWriteOnce"` | | +| persistence.owncloud.nfs | string | `nil` | | +| persistence.owncloud.size | string | `"8Gi"` | | +| podAnnotations | object | `{}` | | +| podSecurityContext | object | `{}` | | +| redis.enabled | bool | `false` | | +| replicaCount | int | `1` | | +| resources | object | `{}` | | +| securityContext | object | `{}` | | +| service.port | int | `80` | | +| service.type | string | `"LoadBalancer"` | | +| serviceAccount.annotations | object | `{}` | | +| serviceAccount.create | bool | `true` | | +| serviceAccount.name | string | `""` | | +| tolerations | list | `[]` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) diff --git a/templates/NOTES.txt b/templates/NOTES.txt new file mode 100644 index 0000000..e91441f --- /dev/null +++ b/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 "owncloud.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 "owncloud.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "owncloud.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 "owncloud.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/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000..63a4f9d --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "owncloud.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 "owncloud.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 "owncloud.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "owncloud.labels" -}} +helm.sh/chart: {{ include "owncloud.chart" . }} +{{ include "owncloud.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "owncloud.selectorLabels" -}} +app.kubernetes.io/name: {{ include "owncloud.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "owncloud.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "owncloud.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/templates/deployment.yaml b/templates/deployment.yaml new file mode 100644 index 0000000..ca07f0b --- /dev/null +++ b/templates/deployment.yaml @@ -0,0 +1,124 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "owncloud.fullname" . }} + labels: + {{- include "owncloud.labels" . | nindent 4 }} +spec: +{{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} +{{- end }} + selector: + matchLabels: + {{- include "owncloud.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "owncloud.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "owncloud.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 }} + env: + - name: OWNCLOUD_DOMAIN + value: {{ .Values.owncloudDomain | quote }} + - name: OWNCLOUD_ADMIN_USERNAME + value: {{ .Values.owncloud.username | quote }} + - name: OWNCLOUD_ADMIN_PASSWORD + value: {{ .Values.owncloud.password | quote }} + {{- if .Values.mariadb.enabled }} + - name: MARIADB_HOST + value: {{ template "owncloud.mariadb.fullname" . }} + - name: MARIADB_PORT_NUMBER + value: "3306" + - name: OWNCLOUD_DATABASE_NAME + value: {{ .Values.mariadb.db.name | quote }} + - name: OWNCLOUD_DATABASE_USER + value: {{ .Values.mariadb.db.user | quote }} + - name: OWNCLOUD_DATABASE_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "owncloud.mariadb.fullname" . }} + key: mariadb-password + {{- else }} + - name: OWNCLOUD_DB_TYPE + value: {{ .Values.externalDatabase.type | quote }} + - name: OWNCLOUD_DB_HOST + value: {{ .Values.externalDatabase.host | quote }} + - name: OWNCLOUD_DATABASE_PORT_NUMBER + value: {{ .Values.externalDatabase.port | quote }} + - name: OWNCLOUD_DB_NAME + value: {{ .Values.externalDatabase.name | quote }} + - name: OWNCLOUD_DB_USERNAME + value: {{ .Values.externalDatabase.user | quote }} + - name: OWNCLOUD_DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ printf "%s-%s" .Release.Name "externaldb" }} + key: db-password + {{- end }} + {{- if .Values.redis.enabled }} + - name: OWNCLOUD_REDIS_ENABLED + value: true + - name: OWNCLOUD_REDIS_HOST + value: {{ .Values.redis.host | quote }} + {{- end }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + livenessProbe: + httpGet: + path: /status.php + port: http + httpHeaders: + - name: Host + value: {{ .Values.owncloud.domain | quote }} + initialDelaySeconds: 120 + timeoutSeconds: 5 + failureThreshold: 6 + readinessProbe: + httpGet: + path: /status.php + port: http + httpHeaders: + - name: Host + value: {{ .Values.owncloud.domain | quote }} + initialDelaySeconds: 30 + timeoutSeconds: 3 + periodSeconds: 5 + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: owncloud-data + mountPath: /mnt/data + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + - name: owncloud-data + persistentVolumeClaim: + claimName: {{ include "owncloud.fullname" . }} diff --git a/templates/hpa.yaml b/templates/hpa.yaml new file mode 100644 index 0000000..15f7d41 --- /dev/null +++ b/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "owncloud.fullname" . }} + labels: + {{- include "owncloud.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "owncloud.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/templates/ingress.yaml b/templates/ingress.yaml new file mode 100644 index 0000000..ada6d88 --- /dev/null +++ b/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "owncloud.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 "owncloud.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/templates/pvc.yaml b/templates/pvc.yaml new file mode 100644 index 0000000..d41e30d --- /dev/null +++ b/templates/pvc.yaml @@ -0,0 +1,28 @@ +{{- if .Values.persistence.owncloud.nfs.enabled -}} +apiVersion: v1 +kind: PersistentVolume +metadata: + name: {{ include "owncloud.fullname" . }} +spec: + accessModes: + - ReadWriteOnce + capacity: + storage: 100Gi + nfs: + server: {{ .Values.persistence.owncloud.nfs.server }} + path: {{ .Values.persistence.owncloud.nfs.path }} +{{end}} +--- +{{- if .Values.persistence.enabled -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "owncloud.fullname" . }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 100Gi + storageClassName: standard +{{- end -}} \ No newline at end of file diff --git a/templates/secrets.yaml b/templates/secrets.yaml new file mode 100644 index 0000000..b189c76 --- /dev/null +++ b/templates/secrets.yaml @@ -0,0 +1,14 @@ +{{- if not .Values.mariadb.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ printf "%s-%s" .Release.Name "externaldb" }} + labels: + app: {{ printf "%s-%s" .Release.Name "externaldb" }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + db-password: {{ default "" .Values.externalDatabase.password | b64enc | quote }} +{{- end }} diff --git a/templates/service.yaml b/templates/service.yaml new file mode 100644 index 0000000..d80be22 --- /dev/null +++ b/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "owncloud.fullname" . }} + labels: + {{- include "owncloud.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 8080 + protocol: TCP + name: http + selector: + {{- include "owncloud.selectorLabels" . | nindent 4 }} diff --git a/templates/serviceaccount.yaml b/templates/serviceaccount.yaml new file mode 100644 index 0000000..afe18bc --- /dev/null +++ b/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "owncloud.serviceAccountName" . }} + labels: + {{- include "owncloud.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/templates/storageclass.yaml b/templates/storageclass.yaml new file mode 100644 index 0000000..c9b5b9b --- /dev/null +++ b/templates/storageclass.yaml @@ -0,0 +1,13 @@ +{{- if .Values.persistence.enabled -}} +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: {{ include "owncloud.fullname" . }} +provisioner: kubernetes.io/gce-pd +parameters: + type: pd-standard +reclaimPolicy: Retain +allowVolumeExpansion: true +mountOptions: + - debug +{{- end -}} \ No newline at end of file diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..eba690d --- /dev/null +++ b/values.yaml @@ -0,0 +1,109 @@ +# Default values for owncloud. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +owncloud: + domain: owncloud.chart.example + username: owncloud + password: owncloud + +mariadb: + enabled: false + +externalDatabase: + type: "" + host: "" + port: 3306 + name: owncloud + user: owncloud + password: owncloud + +persistence: + enabled: true + owncloud: + accessMode: ReadWriteOnce + size: 8Gi + nfs: + # enabled: true + # server: "" + # path: "" + +redis: + enabled: false + +image: + repository: docker.io/owncloud/server + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: 10.6 + +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: LoadBalancer + port: 80 + +ingress: + enabled: true + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: "owncloud.chart.example" + paths: ["/*"] + servicePort: 80 + tls: + - hosts: + - "owncloud.chart.example" + secretName: owncloud + +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 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}