diff options
Diffstat (limited to 'kubernetes/common')
16 files changed, 428 insertions, 18 deletions
diff --git a/kubernetes/common/common/templates/_service.tpl b/kubernetes/common/common/templates/_service.tpl index 25e373a7c9..77b77d059a 100644 --- a/kubernetes/common/common/templates/_service.tpl +++ b/kubernetes/common/common/templates/_service.tpl @@ -17,8 +17,8 @@ {{/* Resolve the name of a chart's service. - The default will be the chart name, unless - overridden in the service configuration. + The default will be the chart name (or .Values.nameOverride if set). + And the use of .Values.service.name overrides all. - .Values.service.name : override default service (ie. chart) name */}} @@ -26,5 +26,6 @@ Expand the service name for a chart. */}} {{- define "common.servicename" -}} - {{- default .Chart.Name .Values.service.name | trunc 63 | trimSuffix "-" -}} + {{- $name := default .Chart.Name .Values.nameOverride -}} + {{- default $name .Values.service.name | trunc 63 | trimSuffix "-" -}} {{- end -}}
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/.helmignore b/kubernetes/common/mariadb-galera/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/kubernetes/common/mariadb-galera/.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 diff --git a/kubernetes/common/mariadb-galera/Chart.yaml b/kubernetes/common/mariadb-galera/Chart.yaml new file mode 100644 index 0000000000..85f36dc6fb --- /dev/null +++ b/kubernetes/common/mariadb-galera/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +description: Chart for MariaDB Galera cluster +name: mariadb-galera +version: 2.0.0 +keywords: + - mariadb + - mysql + - database + - sql + - galera + - cluster
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/requirements.yaml b/kubernetes/common/mariadb-galera/requirements.yaml new file mode 100644 index 0000000000..c169924d82 --- /dev/null +++ b/kubernetes/common/mariadb-galera/requirements.yaml @@ -0,0 +1,4 @@ +dependencies: + - name: common + version: ~2.0.0 + repository: 'file://../common'
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/templates/NOTES.txt b/kubernetes/common/mariadb-galera/templates/NOTES.txt new file mode 100644 index 0000000000..3dd25ac4b7 --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/NOTES.txt @@ -0,0 +1,12 @@ +MariaDB-Galera service can be accessed via port 3306 on the following DNS name from within your cluster: +{{ include "common.fullname" . }}.{{ .Release.Namespace }}.svc.cluster.local + +To connect to your database: + +1. Run a pod that you can use as a client: + + kubectl run {{ include "common.fullname" . }}-client --rm --tty -i --image mariadb --command -- bash + +2. Connect using the mysql cli, then provide your password: + $ mysql -h {{ include "common.fullname" . }} {{- if .Values.mysqlRootPassword }} -p {{ .Values.mysqlRootPassword }}{{- end -}} + diff --git a/kubernetes/common/mariadb-galera/templates/configmap.yaml b/kubernetes/common/mariadb-galera/templates/configmap.yaml new file mode 100644 index 0000000000..094a76cf45 --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/configmap.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "common.fullname" . }}-confd + namespace: {{ include "common.namespace" . }} +data: +{{ tpl (.Files.Glob "resources/config/mariadb/conf.d/*").AsConfig . | indent 2 }} +--- +{{- if .Values.externalConfig }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "common.fullname" . }}-externalConfig + namespace: {{ include "common.namespace" . }} +data: + my_extra.cnf: |- +{{ toYaml .Values.externalConfig | indent 4 }} +{{- end -}}
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/templates/pv.yaml b/kubernetes/common/mariadb-galera/templates/pv.yaml new file mode 100644 index 0000000000..184728f8ad --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/pv.yaml @@ -0,0 +1,37 @@ +{{/* +# Copyright © 2017 Amdocs, Bell Canada +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +*/}} + +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} +kind: PersistentVolume +apiVersion: v1 +metadata: + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + name: {{ include "common.fullname" . }} +spec: + capacity: + storage: {{ .Values.persistence.size}} + accessModes: + - {{ .Values.persistence.accessMode }} + persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }} + hostPath: + path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }} +{{- end -}} diff --git a/kubernetes/common/mariadb-galera/templates/pvc.yaml b/kubernetes/common/mariadb-galera/templates/pvc.yaml new file mode 100644 index 0000000000..e27c3311e9 --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/pvc.yaml @@ -0,0 +1,48 @@ +{{/* +# Copyright © 2017 Amdocs, Bell Canada +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +*/}} + +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +{{- if .Values.persistence.annotations }} + annotations: +{{ toYaml .Values.persistence.annotations | indent 4 }} +{{- end }} +spec: + selector: + matchLabels: + name: {{ include "common.fullname" . }} + accessModes: + - {{ .Values.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.persistence.size }} +{{- if .Values.persistence.storageClass }} +{{- if (eq "-" .Values.persistence.storageClass) }} + storageClassName: "" +{{- else }} + storageClassName: "{{ .Values.persistence.storageClass }}" +{{- end }} +{{- end }} +{{- end -}} diff --git a/kubernetes/common/mariadb-galera/templates/secrets.yaml b/kubernetes/common/mariadb-galera/templates/secrets.yaml new file mode 100644 index 0000000000..101a7eba79 --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/secrets.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +type: Opaque +data: + db-root-password: {{ .Values.config.mariadbRootPassword | b64enc | quote }} + user-password: {{ default "" .Values.config.userPassword | b64enc | quote }}
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/templates/service.yaml b/kubernetes/common/mariadb-galera/templates/service.yaml new file mode 100644 index 0000000000..f5f93ed9b6 --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + annotations: + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + ports: + - name: {{ .Values.service.name }} + port: {{ .Values.service.internalPort }} + clusterIP: None + selector: + app: {{ include "common.fullname" . }}
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/templates/statefulset.yaml b/kubernetes/common/mariadb-galera/templates/statefulset.yaml new file mode 100644 index 0000000000..b8ba75e52c --- /dev/null +++ b/kubernetes/common/mariadb-galera/templates/statefulset.yaml @@ -0,0 +1,119 @@ +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +spec: + serviceName: {{ include "common.fullname" . }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ include "common.fullname" . }} + annotations: + pod.alpha.kubernetes.io/initialized: "true" + spec: + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + volumes: + {{- if .Values.externalConfig }} + - name: config + configMap: + name: {{ include "common.fullname" . }}-externalConfig + {{- end}} + - name: localtime + hostPath: + path: /etc/localtime + imagePullSecrets: + - name: {{ include "common.namespace" . }}-docker-registry-key + containers: + - name: {{ include "common.fullname" . }} + image: "{{ .Values.global.repository | default .Values.repository }}/{{ .Values.image }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy | quote}} + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + - name: MYSQL_USER + value: {{ default "" .Values.config.userName | quote }} + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "common.fullname" . }} + key: user-password + - name: MYSQL_DATABASE + value: {{ default "" .Values.config.mysqlDatabase | quote }} + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "common.fullname" . }} + key: db-root-password + ports: + - containerPort: {{ .Values.service.internalPort }} + name: {{ .Values.service.name }} + - containerPort: {{ .Values.service.sstPort }} + name: {{ .Values.service.sstName }} + - containerPort: {{ .Values.service.replicationPort }} + name: {{ .Values.service.replicationName }} + - containerPort: {{ .Values.service.istPort }} + name: {{ .Values.service.istName }} + readinessProbe: + exec: + command: + - /usr/share/container-scripts/mysql/readiness-probe.sh + initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} + periodSeconds: {{ .Values.readiness.periodSeconds }} + {{- if eq .Values.liveness.enabled true }} + livenessProbe: + exec: + command: ["mysqladmin", "ping"] + initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} + periodSeconds: {{ .Values.liveness.periodSeconds }} + timeoutSeconds: {{ .Values.liveness.timeoutSeconds }} + {{- end }} + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + {{- if .Values.externalConfig }} + - mountPath: /etc/config + name: config + {{- end}} + - mountPath: /etc/localtime + name: localtime + readOnly: true +{{- if .Values.persistence.enabled }} + - mountPath: /var/lib/mysql + name: {{ include "common.fullname" . }}-data + subPath: data + initContainers: + - name: mariadb-galera-prepare + image: {{ .Values.global.repository | default .Values.repository }}/{{ .Values.imageInit }} + command: ["sh", "-c", "chown -R 27:27 /var/lib/mysql"] + volumeMounts: + - name: {{ include "common.fullname" . }}-data + mountPath: /var/lib/mysql + volumeClaimTemplates: + - metadata: + name: {{ include "common.fullname" . }}-data + annotations: + {{- if .Values.persistence.storageClass }} + volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }} + {{- else }} + volume.alpha.kubernetes.io/storage-class: default + {{- end }} + spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end }}
\ No newline at end of file diff --git a/kubernetes/common/mariadb-galera/values.yaml b/kubernetes/common/mariadb-galera/values.yaml new file mode 100644 index 0000000000..f65a8a57e6 --- /dev/null +++ b/kubernetes/common/mariadb-galera/values.yaml @@ -0,0 +1,115 @@ +################################################################# +# Global configuration defaults. +################################################################# +global: + nodePortPrefix: 302 + repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ== + persistence: {} + repository: nexus3.onap.org:10001 + + +################################################################# +# Application configuration defaults. +################################################################# + +#repository: mysql +repository: nexus3.onap.org:10001 +image: adfinissygroup/k8s-mariadb-galera-centos:v002 +imageInit: busybox +pullPolicy: IfNotPresent + +# application configuration +config: + mariadbRootPassword: secretpassword + userName: my-user + userPassword: my-password + mysqlDatabase: my-database + +# default number of instances in the StatefulSet +replicaCount: 3 + +nodeSelector: {} + +affinity: {} + +# probe configuration parameters +liveness: + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + # necessary to disable liveness probe when setting breakpoints + # in debugger so K8s doesn't restart unresponsive container + enabled: true + +readiness: + initialDelaySeconds: 15 + periodSeconds: 10 + +## Persist data to a persitent volume +persistence: + enabled: false + + ## A manually managed Persistent Volume and Claim + ## Requires persistence.enabled: true + ## If defined, PVC must be created manually before volume will be bound + # existingClaim: + volumeReclaimPolicy: Retain + + ## database data Persistent Volume Storage Class + ## If defined, storageClassName: <storageClass> + ## If set to "-", storageClassName: "", which disables dynamic provisioning + ## If undefined (the default) or set to null, no storageClassName spec is + ## set, choosing the default provisioner. (gp2 on AWS, standard on + ## GKE, AWS & OpenStack) + ## + # storageClass: "-" + accessMode: ReadWriteOnce + size: 2Gi + + +service: + internalPort: 3306 + name: mariadb-galera + sstPort: 4444 + sstName: sst + replicationPort: 4567 + replicationName: replication + istPort: 4568 + istName: ist + +ingress: + enabled: false + + +## Configure MariaDB-Galera with a custom my.cnf file +## ref: https://mariadb.com/kb/en/mariadb/configuring-mariadb-with-mycnf/#example-of-configuration-file +## +externalConfig: {} +# externalConfig: |- + # [mysqld] + # innodb_buffer_pool_size=2G + +#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:'. + # + # Example: + # Configure resource requests and limits + # ref: http://kubernetes.io/docs/user-guide/compute-resources/ + # Minimum memory for development is 2 CPU cores and 4GB memory + # Minimum memory for production is 4 CPU cores and 8GB memory +resources: + limits: + cpu: 2 + memory: 4Gi + requests: + cpu: 2 + memory: 4Gi + +# Name for mariadb-galera cluster - should be unique accross all projects or other clusters +nameOverride: mariadb-galera + +# DNS name for mariadb-galera cluster - should be unique accross all projects other clusters +#dnsnameOverride: mariadb-galera
\ No newline at end of file diff --git a/kubernetes/common/mysql/templates/nfs-provisoner.yaml b/kubernetes/common/mysql/templates/nfs-provisoner.yaml index 3f19977ae2..35894df7a7 100644 --- a/kubernetes/common/mysql/templates/nfs-provisoner.yaml +++ b/kubernetes/common/mysql/templates/nfs-provisoner.yaml @@ -14,7 +14,7 @@ # limitations under the License. */}} -#{{ if not .Values.disableNfsProvisioner }} +{{ if not .Values.disableNfsProvisioner }} apiVersion: extensions/v1beta1 kind: Deployment metadata: @@ -75,4 +75,4 @@ spec: - name: export-volume hostPath: path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Namespace }}/{{ .Values.persistence.mountSubPath }} -#{{ end }} +{{ end }} diff --git a/kubernetes/common/mysql/templates/pvc.yaml b/kubernetes/common/mysql/templates/pvc.yaml index edb370ae35..d1558f131f 100644 --- a/kubernetes/common/mysql/templates/pvc.yaml +++ b/kubernetes/common/mysql/templates/pvc.yaml @@ -14,7 +14,7 @@ # limitations under the License. */}} -{{- if (and (and (.Values.persistence.enabled) (not .Values.persistence.existingClaim)) ( .Values.disableNfsProvisioner)) -}} +{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}} kind: PersistentVolumeClaim apiVersion: v1 metadata: diff --git a/kubernetes/common/mysql/templates/statefulset.yaml b/kubernetes/common/mysql/templates/statefulset.yaml index e43698865e..ff73b45620 100644 --- a/kubernetes/common/mysql/templates/statefulset.yaml +++ b/kubernetes/common/mysql/templates/statefulset.yaml @@ -236,18 +236,7 @@ spec: hostPath: path: /etc/localtime - name: {{ include "common.fullname" . }}-data -#{{ if not .Values.disableNfsProvisioner }} - volumeClaimTemplates: - - metadata: - name: {{ include "common.fullname" . }}-data - annotations: - volume.beta.kubernetes.io/storage-class: "{{ include "common.fullname" . }}-data" - spec: - accessModes: ["ReadWriteMany"] - resources: - requests: - storage: 1Gi -#{{ else if .Values.persistence.enabled }} +#{{ if .Values.persistence.enabled }} persistentVolumeClaim: claimName: {{ include "common.fullname" . }}-data #{{ else }} diff --git a/kubernetes/common/mysql/templates/storageclass.yaml b/kubernetes/common/mysql/templates/storageclass.yaml index 398c998e0f..3cd502ea30 100644 --- a/kubernetes/common/mysql/templates/storageclass.yaml +++ b/kubernetes/common/mysql/templates/storageclass.yaml @@ -14,9 +14,11 @@ # limitations under the License. */}} +{{ if not .Values.disableNfsProvisioner }} kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: "{{ include "common.fullname" . }}-data" namespace: {{ include "common.namespace" . }} provisioner: {{ include "common.fullname" . }}/nfs +{{ end }} |