From 561a91cadd2f75c831a3e4743365f58c82e951d3 Mon Sep 17 00:00:00 2001 From: Mandeep Khinda Date: Thu, 23 Aug 2018 14:08:52 +0000 Subject: Vid Template alignment. Moving vid readiness to version 2.0.1 Remove unnecessary config maps as a result of using readiness 2.0.1, 2 configmaps moved to resources. Check if replica instances are up dynamically. Issue-ID: VID-236 Change-Id: Iaf2989f556214f60467f7a1d7a745a95ae421506 Signed-off-by: Mandeep Khinda --- kubernetes/vid/charts/vid-galera/Chart.yaml | 25 ---- .../vid/charts/vid-galera/templates/NOTES.txt | 26 ---- .../vid/charts/vid-galera/templates/configmap.yaml | 35 ------ kubernetes/vid/charts/vid-galera/templates/pv.yaml | 37 ------ .../vid/charts/vid-galera/templates/pvc.yaml | 48 -------- .../vid/charts/vid-galera/templates/secrets.yaml | 28 ----- .../vid/charts/vid-galera/templates/service.yaml | 34 ------ .../charts/vid-galera/templates/statefulset.yaml | 135 --------------------- kubernetes/vid/charts/vid-galera/values.yaml | 132 -------------------- .../vid/charts/vid-mariadb-galera/Chart.yaml | 25 ++++ .../charts/vid-mariadb-galera/templates/NOTES.txt | 26 ++++ .../vid-mariadb-galera/templates/configmap.yaml | 35 ++++++ .../charts/vid-mariadb-galera/templates/pv.yaml | 37 ++++++ .../charts/vid-mariadb-galera/templates/pvc.yaml | 48 ++++++++ .../vid-mariadb-galera/templates/secrets.yaml | 28 +++++ .../vid-mariadb-galera/templates/service.yaml | 34 ++++++ .../vid-mariadb-galera/templates/statefulset.yaml | 135 +++++++++++++++++++++ .../vid/charts/vid-mariadb-galera/values.yaml | 132 ++++++++++++++++++++ kubernetes/vid/resources/config/db_cmd.sh | 23 ++++ kubernetes/vid/resources/config/vid-pre-init.sql | 29 +++++ .../templates/check-job-completion-configmap.yaml | 97 --------------- .../vid/templates/cluster-ready-configmap.yaml | 103 ---------------- kubernetes/vid/templates/configmap.yaml | 13 ++ kubernetes/vid/templates/dbcmd-configmap.yaml | 25 ---- kubernetes/vid/templates/deployment.yaml | 16 +-- kubernetes/vid/templates/galera-sql-configmap.yaml | 35 ------ .../vid/templates/vid-galera-config-job.yaml | 59 +++++---- kubernetes/vid/values.yaml | 8 +- 28 files changed, 598 insertions(+), 810 deletions(-) delete mode 100644 kubernetes/vid/charts/vid-galera/Chart.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/templates/NOTES.txt delete mode 100644 kubernetes/vid/charts/vid-galera/templates/configmap.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/templates/pv.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/templates/pvc.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/templates/secrets.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/templates/service.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/templates/statefulset.yaml delete mode 100644 kubernetes/vid/charts/vid-galera/values.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/Chart.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/NOTES.txt create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/configmap.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/pv.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/pvc.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/secrets.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/service.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/templates/statefulset.yaml create mode 100644 kubernetes/vid/charts/vid-mariadb-galera/values.yaml create mode 100644 kubernetes/vid/resources/config/db_cmd.sh create mode 100644 kubernetes/vid/resources/config/vid-pre-init.sql delete mode 100644 kubernetes/vid/templates/check-job-completion-configmap.yaml delete mode 100644 kubernetes/vid/templates/cluster-ready-configmap.yaml delete mode 100644 kubernetes/vid/templates/dbcmd-configmap.yaml delete mode 100644 kubernetes/vid/templates/galera-sql-configmap.yaml (limited to 'kubernetes/vid') diff --git a/kubernetes/vid/charts/vid-galera/Chart.yaml b/kubernetes/vid/charts/vid-galera/Chart.yaml deleted file mode 100644 index 47f9e7e31d..0000000000 --- a/kubernetes/vid/charts/vid-galera/Chart.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright © 2018 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. - -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/vid/charts/vid-galera/templates/NOTES.txt b/kubernetes/vid/charts/vid-galera/templates/NOTES.txt deleted file mode 100644 index c44fa8948e..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/NOTES.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright © 2018 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. - -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/vid/charts/vid-galera/templates/configmap.yaml b/kubernetes/vid/charts/vid-galera/templates/configmap.yaml deleted file mode 100644 index aff9f5b857..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/configmap.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright © 2018 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. - -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: |- - [mysqld] - lower_case_table_names = 1 - -#{{ toYaml .Values.externalConfig | indent 4 }} -#{{- end -}} diff --git a/kubernetes/vid/charts/vid-galera/templates/pv.yaml b/kubernetes/vid/charts/vid-galera/templates/pv.yaml deleted file mode 100644 index f682196931..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/pv.yaml +++ /dev/null @@ -1,37 +0,0 @@ -{{/* -# 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/vid/charts/vid-galera/templates/pvc.yaml b/kubernetes/vid/charts/vid-galera/templates/pvc.yaml deleted file mode 100644 index c3de6e8150..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/pvc.yaml +++ /dev/null @@ -1,48 +0,0 @@ -{{/* -# 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/vid/charts/vid-galera/templates/secrets.yaml b/kubernetes/vid/charts/vid-galera/templates/secrets.yaml deleted file mode 100644 index 233158f791..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/secrets.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright © 2018 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. - -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/vid/charts/vid-galera/templates/service.yaml b/kubernetes/vid/charts/vid-galera/templates/service.yaml deleted file mode 100644 index ae11a26629..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/service.yaml +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright © 2018 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. - -apiVersion: v1 -kind: Service -metadata: - annotations: - service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" -# name: {{ include "common.servicename" . }} - name: {{ .Values.service.name }} - 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.portName }} - port: {{ .Values.service.internalPort }} - clusterIP: None - selector: - app: {{ include "common.fullname" . }} diff --git a/kubernetes/vid/charts/vid-galera/templates/statefulset.yaml b/kubernetes/vid/charts/vid-galera/templates/statefulset.yaml deleted file mode 100644 index 816d473257..0000000000 --- a/kubernetes/vid/charts/vid-galera/templates/statefulset.yaml +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright © 2018 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. - -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" . }} - serviceName: {{ .Values.service.name }} - replicas: {{ .Values.replicaCount }} - template: - metadata: - labels: - app: {{ include "common.fullname" . }} - release: {{ .Release.Name }} - 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: "{{ include "common.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: "{{ include "common.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 }} diff --git a/kubernetes/vid/charts/vid-galera/values.yaml b/kubernetes/vid/charts/vid-galera/values.yaml deleted file mode 100644 index eb715a8b48..0000000000 --- a/kubernetes/vid/charts/vid-galera/values.yaml +++ /dev/null @@ -1,132 +0,0 @@ -# Copyright © 2018 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. - -################################################################# -# Global configuration defaults. -################################################################# -global: - nodePortPrefix: 302 - 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 - userName: vidadmin - userPassword: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U - mysqlDatabase: vid_openecomp_epsdk - - -# default number of instances in the StatefulSet -# keep in mind that if the number is increased you need to update vid-galera-config-job.yaml so that the job will know to wait for all pods. -replicaCount: 1 - -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: false - -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: - ## 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: vid-galera - portName: vid-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: |- - lower_case_table_names = 1 -#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: vid-galera - -# DNS name for mariadb-galera cluster - should be unique accross all projects other clusters -#dnsnameOverride: mariadb-galera diff --git a/kubernetes/vid/charts/vid-mariadb-galera/Chart.yaml b/kubernetes/vid/charts/vid-mariadb-galera/Chart.yaml new file mode 100644 index 0000000000..757d7c5a84 --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/Chart.yaml @@ -0,0 +1,25 @@ +# Copyright © 2018 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. + +apiVersion: v1 +description: ONAP VID MariaDB Galera cluster +name: vid_mariadb_galera +version: 3.0.0 +keywords: + - mariadb + - mysql + - database + - sql + - galera + - cluster \ No newline at end of file diff --git a/kubernetes/vid/charts/vid-mariadb-galera/templates/NOTES.txt b/kubernetes/vid/charts/vid-mariadb-galera/templates/NOTES.txt new file mode 100644 index 0000000000..c44fa8948e --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/templates/NOTES.txt @@ -0,0 +1,26 @@ +# Copyright © 2018 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. + +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/vid/charts/vid-mariadb-galera/templates/configmap.yaml b/kubernetes/vid/charts/vid-mariadb-galera/templates/configmap.yaml new file mode 100644 index 0000000000..aff9f5b857 --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/templates/configmap.yaml @@ -0,0 +1,35 @@ +# Copyright © 2018 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. + +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: |- + [mysqld] + lower_case_table_names = 1 + +#{{ toYaml .Values.externalConfig | indent 4 }} +#{{- end -}} diff --git a/kubernetes/vid/charts/vid-mariadb-galera/templates/pv.yaml b/kubernetes/vid/charts/vid-mariadb-galera/templates/pv.yaml new file mode 100644 index 0000000000..f682196931 --- /dev/null +++ b/kubernetes/vid/charts/vid-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/vid/charts/vid-mariadb-galera/templates/pvc.yaml b/kubernetes/vid/charts/vid-mariadb-galera/templates/pvc.yaml new file mode 100644 index 0000000000..c3de6e8150 --- /dev/null +++ b/kubernetes/vid/charts/vid-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/vid/charts/vid-mariadb-galera/templates/secrets.yaml b/kubernetes/vid/charts/vid-mariadb-galera/templates/secrets.yaml new file mode 100644 index 0000000000..233158f791 --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/templates/secrets.yaml @@ -0,0 +1,28 @@ +# Copyright © 2018 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. + +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/vid/charts/vid-mariadb-galera/templates/service.yaml b/kubernetes/vid/charts/vid-mariadb-galera/templates/service.yaml new file mode 100644 index 0000000000..ae11a26629 --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/templates/service.yaml @@ -0,0 +1,34 @@ +# Copyright © 2018 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. + +apiVersion: v1 +kind: Service +metadata: + annotations: + service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" +# name: {{ include "common.servicename" . }} + name: {{ .Values.service.name }} + 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.portName }} + port: {{ .Values.service.internalPort }} + clusterIP: None + selector: + app: {{ include "common.fullname" . }} diff --git a/kubernetes/vid/charts/vid-mariadb-galera/templates/statefulset.yaml b/kubernetes/vid/charts/vid-mariadb-galera/templates/statefulset.yaml new file mode 100644 index 0000000000..816d473257 --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/templates/statefulset.yaml @@ -0,0 +1,135 @@ +# Copyright © 2018 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. + +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" . }} + serviceName: {{ .Values.service.name }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ include "common.fullname" . }} + release: {{ .Release.Name }} + 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: "{{ include "common.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: "{{ include "common.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 }} diff --git a/kubernetes/vid/charts/vid-mariadb-galera/values.yaml b/kubernetes/vid/charts/vid-mariadb-galera/values.yaml new file mode 100644 index 0000000000..e9464b69ee --- /dev/null +++ b/kubernetes/vid/charts/vid-mariadb-galera/values.yaml @@ -0,0 +1,132 @@ +# Copyright © 2018 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. + +################################################################# +# Global configuration defaults. +################################################################# +global: + nodePortPrefix: 302 + 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 + userName: vidadmin + userPassword: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U + mysqlDatabase: vid_openecomp_epsdk + + +# default number of instances in the StatefulSet +# keep in mind that if the number is increased you need to update vid-galera-config-job.yaml so that the job will know to wait for all pods. +replicaCount: 1 + +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: false + +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: + ## 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: vid-galera + portName: vid-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: |- + lower_case_table_names = 1 +#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: vid-mariadb-galera + +# DNS name for mariadb-galera cluster - should be unique accross all projects other clusters +#dnsnameOverride: mariadb-galera diff --git a/kubernetes/vid/resources/config/db_cmd.sh b/kubernetes/vid/resources/config/db_cmd.sh new file mode 100644 index 0000000000..95b83d4b59 --- /dev/null +++ b/kubernetes/vid/resources/config/db_cmd.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Copyright © 2018 AT&T +# +# 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. + +echo "Going to run mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_HOST} -P${MYSQL_PORT} ..." +mysql -u${MYSQL_USER} -p${MYSQL_PASSWORD} -h${MYSQL_HOST} -P${MYSQL_PORT} < /db-config/vid-pre-init.sql +if [ $? -ne 0 ];then + echo "ERROR: Failed to run ${cmd} vid-pre-init.sql" + exit 1 +else + echo "INFO: Database initialized successfully" +fi diff --git a/kubernetes/vid/resources/config/vid-pre-init.sql b/kubernetes/vid/resources/config/vid-pre-init.sql new file mode 100644 index 0000000000..2dbbbcce6d --- /dev/null +++ b/kubernetes/vid/resources/config/vid-pre-init.sql @@ -0,0 +1,29 @@ +/* +# Copyright © 2018 AT&T +# +# 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. +*/ + +CREATE TABLE IF NOT EXISTS `vid_openecomp_epsdk`.`schema_info` ( +`SCHEMA_ID` VARCHAR(25) NOT NULL, +`SCHEMA_DESC` VARCHAR(75) NOT NULL, +`DATASOURCE_TYPE` VARCHAR(100) NULL DEFAULT NULL, +`CONNECTION_URL` VARCHAR(200) NOT NULL, +`USER_NAME` VARCHAR(45) NOT NULL, +`PASSWORD` VARCHAR(45) NULL DEFAULT NULL, +`DRIVER_CLASS` VARCHAR(100) NOT NULL, +`MIN_POOL_SIZE` INT(11) NOT NULL, +`MAX_POOL_SIZE` INT(11) NOT NULL, +`IDLE_CONNECTION_TEST_PERIOD` INT(11) NOT NULL) +ENGINE = InnoDB +DEFAULT CHARACTER SET = utf8; \ No newline at end of file diff --git a/kubernetes/vid/templates/check-job-completion-configmap.yaml b/kubernetes/vid/templates/check-job-completion-configmap.yaml deleted file mode 100644 index 270615a04b..0000000000 --- a/kubernetes/vid/templates/check-job-completion-configmap.yaml +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright © 2018 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. - -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "common.fullname" . }}-check-job-completion - namespace: {{ include "common.namespace" . }} -data: - vid_check_job_completion.py: | - #!/usr/bin/python - from __future__ import print_function - import time, argparse, logging, sys, os - import kubernetes.client - from kubernetes import client, config - from pprint import pprint - - #extract env variables. - namespace = os.environ['NAMESPACE'] - cert = os.environ['CERT'] - host = os.environ['KUBERNETES_SERVICE_HOST'] - token_path = os.environ['TOKEN'] - - with open(token_path, 'r') as token_file: - token = token_file.read().replace('\n', '') - - client.configuration.api_key['authorization'] = token - client.configuration.api_key_prefix['authorization'] = 'Bearer' - client.configuration.host = "https://" + str(host) - client.configuration.ssl_ca_cert = cert - - api_instance = client.BatchV1Api() - - #setup logging - log = logging.getLogger(__name__) - handler = logging.StreamHandler(sys.stdout) - handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) - handler.setLevel(logging.INFO) - log.addHandler(handler) - log.setLevel(logging.INFO) - - - def is_ready(job_name): - log.info( "[INFO] Checking if " + job_name + " is completed") - pretty = True - job_status = False - - try: - api_response = api_instance.read_namespaced_job_status(job_name, namespace, pretty=pretty) - except Exception as e: - print("Exception when calling BatchV1Api->read_namespaced_job_status: %s\n" % e) - - pprint(api_response) - if api_response.status.succeeded == 1: - job_status_type = api_response.status.conditions[0].type - if job_status_type == "Complete": - job_status = True - - print("[DBG] jobStatus: " + unicode(job_status)) - return job_status - - - def main(args): - for job_name in args: - timeout = time.time() + 60 * 10 - while True: - ready = is_ready(job_name) - if ready is True : - break - elif time.time() > timeout: - log.warning( "timed out waiting for '" + job_name + "' to be ready") - exit(1) - else: - time.sleep(5) - - - if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Process some names.') - parser.add_argument('--job-name', action='append', required=True, help='A container name') - args = parser.parse_args() - arg_dict = vars(args) - - for arg in arg_dict.itervalues(): - main(arg) - - diff --git a/kubernetes/vid/templates/cluster-ready-configmap.yaml b/kubernetes/vid/templates/cluster-ready-configmap.yaml deleted file mode 100644 index 86f8d9129b..0000000000 --- a/kubernetes/vid/templates/cluster-ready-configmap.yaml +++ /dev/null @@ -1,103 +0,0 @@ -# Copyright © 2018 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. - -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "common.fullname" . }}-cluster-ready-configmap - namespace: {{ include "common.namespace" . }} -data: - vid_ready.py : |- - #!/usr/bin/python - from kubernetes import client, config - import time, argparse, logging, sys, os - - #extract env variables. - namespace = os.environ['NAMESPACE'] - cert = os.environ['CERT'] - host = os.environ['KUBERNETES_SERVICE_HOST'] - token_path = os.environ['TOKEN'] - - with open(token_path, 'r') as token_file: - token = token_file.read().replace('\n', '') - - client.configuration.host = "https://" + host - client.configuration.ssl_ca_cert = cert - client.configuration.api_key['authorization'] = token - client.configuration.api_key_prefix['authorization'] = 'Bearer' - - #setup logging - log = logging.getLogger(__name__) - handler = logging.StreamHandler(sys.stdout) - handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) - handler.setLevel(logging.INFO) - log.addHandler(handler) - log.setLevel(logging.INFO) - - - def is_ready(container_name): - log.info( "Checking if " + container_name + " is ready") - # config.load_kube_config() # for local testing - # namespace='onap-sdc' # for local testing - v1 = client.CoreV1Api() - - ready = False - - try: - response = v1.list_namespaced_pod(namespace=namespace, watch=False) - - for i in response.items: - #log.info(i.metadata.name) - for s in i.status.container_statuses: - #log.info(s.name) - if i.metadata.name == container_name: - ready = s.ready - if not ready: - log.info( container_name + " is not ready.") - else: - log.info( container_name + " is ready!") - else: - continue - return ready - except Exception as e: - log.error("Exception when calling list_namespaced_pod: %s\n" % e) - - - def main(args): - # args are a list of container names - for container_name in args: - # 5 min, TODO: make configurable - timeout = time.time() + 60 * 10 - while True: - ready = is_ready(container_name) - if ready is True: - break - elif time.time() > timeout: - log.warning( "timed out waiting for '" + container_name + "' to be ready") - exit(1) - else: - time.sleep(5) - - - if __name__ == "__main__": - parser = argparse.ArgumentParser(description='Process some names.') - parser.add_argument('--container-name', action='append', required=True, help='A container name') - args = parser.parse_args() - arg_dict = vars(args) - - for arg in arg_dict.itervalues(): - main(arg) - - - diff --git a/kubernetes/vid/templates/configmap.yaml b/kubernetes/vid/templates/configmap.yaml index f7dbf07645..cae46b4050 100644 --- a/kubernetes/vid/templates/configmap.yaml +++ b/kubernetes/vid/templates/configmap.yaml @@ -27,3 +27,16 @@ metadata: namespace: {{ include "common.namespace" . }} data: {{ tpl (.Files.Glob "resources/config/log/filebeat/*").AsConfig . | indent 2 }} +--- +apiVersion: v1 +kind: ConfigMap +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 }} +data: +{{ tpl (.Files.Glob "resources/config/*").AsConfig . | indent 2 }} \ No newline at end of file diff --git a/kubernetes/vid/templates/dbcmd-configmap.yaml b/kubernetes/vid/templates/dbcmd-configmap.yaml deleted file mode 100644 index aa088011ea..0000000000 --- a/kubernetes/vid/templates/dbcmd-configmap.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright © 2018 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. - -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "common.fullname" . }}-dbcmd-configmap - namespace: {{ include "common.namespace" . }} -data: - db_cmd.sh : |- - #!/bin/sh - #mysql -uroot -p${MYSQL_ROOT_PASSWORD} -h${MYSQL_HOST} -P3306 < /db-config/vid-pre-init.sql - mysql -uvidadmin -p${MYSQL_PASSWORD} -h${MYSQL_HOST} -P3306 < /db-config/vid-pre-init.sql - diff --git a/kubernetes/vid/templates/deployment.yaml b/kubernetes/vid/templates/deployment.yaml index c8545df689..c20ba10a87 100644 --- a/kubernetes/vid/templates/deployment.yaml +++ b/kubernetes/vid/templates/deployment.yaml @@ -31,16 +31,9 @@ spec: release: {{ .Release.Name }} spec: initContainers: -#dd775k: This container checks if the job that wait for all db instances to be up and initializes the db had finished. -# - command: -# - /bin/sh -# args: -# - "-c" -# - "sleep 1000000000m" - command: - - python + - /root/job_complete.py args: - - /tmp/vid-check-job-completion/vid_check_job_completion.py - --job-name - vid-config-galera env: @@ -52,9 +45,6 @@ spec: image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} name: {{ include "common.name" . }}-readiness - volumeMounts: - - mountPath: /tmp/vid-check-job-completion - name: vid-check-job-completion containers: - name: {{ include "common.name" . }} image: "{{ include "common.repository" . }}/{{ .Values.image }}" @@ -167,10 +157,6 @@ spec: - name: vid-logback configMap: name: {{ include "common.fullname" . }}-log-configmap - - name: vid-check-job-completion - configMap: - name: {{ include "common.fullname" . }}-check-job-completion imagePullSecrets: - name: "{{ include "common.namespace" . }}-docker-registry-key" - diff --git a/kubernetes/vid/templates/galera-sql-configmap.yaml b/kubernetes/vid/templates/galera-sql-configmap.yaml deleted file mode 100644 index 7f05af56a9..0000000000 --- a/kubernetes/vid/templates/galera-sql-configmap.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright © 2018 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. - -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "common.fullname" . }}-galera-sql-configmap - namespace: "{{ include "common.namespace" . }}" -data: - vid-pre-init.sql: |- - CREATE TABLE IF NOT EXISTS `vid_openecomp_epsdk`.`schema_info` ( - `SCHEMA_ID` VARCHAR(25) NOT NULL, - `SCHEMA_DESC` VARCHAR(75) NOT NULL, - `DATASOURCE_TYPE` VARCHAR(100) NULL DEFAULT NULL, - `CONNECTION_URL` VARCHAR(200) NOT NULL, - `USER_NAME` VARCHAR(45) NOT NULL, - `PASSWORD` VARCHAR(45) NULL DEFAULT NULL, - `DRIVER_CLASS` VARCHAR(100) NOT NULL, - `MIN_POOL_SIZE` INT(11) NOT NULL, - `MAX_POOL_SIZE` INT(11) NOT NULL, - `IDLE_CONNECTION_TEST_PERIOD` INT(11) NOT NULL) - ENGINE = InnoDB - DEFAULT CHARACTER SET = utf8; - diff --git a/kubernetes/vid/templates/vid-galera-config-job.yaml b/kubernetes/vid/templates/vid-galera-config-job.yaml index b893dbf617..2bcf64749d 100644 --- a/kubernetes/vid/templates/vid-galera-config-job.yaml +++ b/kubernetes/vid/templates/vid-galera-config-job.yaml @@ -28,35 +28,34 @@ spec: name: vid-galera-init spec: initContainers: -#dd775k: This container checks that all galera instances are up before initializing it. +#This container checks that all galera instances are up before initializing it. - name: vid-init-galera-readiness image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} -# - /bin/sh -# args: -# - "-c" -# - "sleep 1000000000m" command: - - python - args: - - /root/vid_ready.py + - /root/ready.py +{{- $fullname := include "common.fullname" . -}} +{{- range $i,$t := until (int .Values.vid_mariadb_galera.replicaCount)}} - --container-name - - {{ include "common.fullname" . }}-mariadb-galera-0 + - {{ $fullname }}-mariadb-galera-{{$i}} +{{- end }} env: - name: NAMESPACE - value: {{ include "common.namespace" . }} - volumeMounts: - - name: init-config - mountPath: /root/ + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace containers: - name: vid-config-galeradb image: {{ .Values.mariadb_image }} imagePullPolicy: "{{ .Values.pullPolicy }}" volumeMounts: - - name: vid-db-config - mountPath: /db-config - - name: dbcmd-config - mountPath: /dbcmd-config + - mountPath: /dbcmd-config/db_cmd.sh + name: {{ include "common.fullname" . }}-config + subPath: db_cmd.sh + - mountPath: /db-config/vid-pre-init.sql + name: {{ include "common.fullname" . }}-config + subPath: vid-pre-init.sql command: - /bin/sh args: @@ -65,22 +64,20 @@ spec: env: - name: MYSQL_PASSWORD value: "{{ .Values.config.vidmysqlpassword }}" -# valueFrom: -# secretKeyRef: -# name: {{ template "common.fullname" . }} -# key: vid-password - name: MYSQL_HOST value: "{{ .Values.config.vidmysqlhost }}" + - name: MYSQL_USER + value: "{{ .Values.config.vidmysqluser }}" + - name: MYSQL_PORT + value: "{{ .Values.config.vidmysqlport }}" + restartPolicy: Never volumes: - - name: vid-db-config - configMap: - name: {{ include "common.fullname" . }}-galera-sql-configmap - - name: dbcmd-config + - name: {{ include "common.fullname" . }}-config configMap: - name: {{ include "common.fullname" . }}-dbcmd-configmap - - name: init-config - configMap: - name: {{ include "common.fullname" . }}-cluster-ready-configmap - restartPolicy: Never - + name: {{ include "common.fullname" . }} + items: + - key: db_cmd.sh + path: db_cmd.sh + - key: vid-pre-init.sql + path: vid-pre-init.sql diff --git a/kubernetes/vid/values.yaml b/kubernetes/vid/values.yaml index 8487743177..63726df07a 100644 --- a/kubernetes/vid/values.yaml +++ b/kubernetes/vid/values.yaml @@ -17,9 +17,8 @@ # Declare variables to be passed into your templates. global: nodePortPrefix: 302 - repositorySecret: eyJuZXh1czMub25hcC5vcmc6MTAwMDEiOnsidXNlcm5hbWUiOiJkb2NrZXIiLCJwYXNzd29yZCI6ImRvY2tlciIsImVtYWlsIjoiQCIsImF1dGgiOiJaRzlqYTJWeU9tUnZZMnRsY2c9PSJ9fQ== readinessRepository: oomk8s - readinessImage: readiness-check:1.0.0 + readinessImage: readiness-check:2.0.1 loggingRepository: docker.elastic.co loggingImage: beats/filebeat:5.5.0 @@ -54,8 +53,9 @@ config: logstashPort: 5044 # subchart configuration -mariadb-galera: - nameOverride: vid-mariadb-galera +vid_mariadb_galera: +# nameOverride: vid-mariadb-galera + replicaCount: 1 # default number of instances replicaCount: 1 -- cgit 1.2.3-korg