diff options
Diffstat (limited to 'kubernetes/common/mongo/templates')
-rw-r--r-- | kubernetes/common/mongo/templates/nfs-provisoner.yaml | 78 | ||||
-rw-r--r-- | kubernetes/common/mongo/templates/pv.yaml | 38 | ||||
-rw-r--r-- | kubernetes/common/mongo/templates/pvc.yaml | 39 | ||||
-rw-r--r-- | kubernetes/common/mongo/templates/service.yaml | 97 | ||||
-rw-r--r-- | kubernetes/common/mongo/templates/statefulset.yaml | 104 | ||||
-rw-r--r-- | kubernetes/common/mongo/templates/storageclass.yaml | 24 |
6 files changed, 380 insertions, 0 deletions
diff --git a/kubernetes/common/mongo/templates/nfs-provisoner.yaml b/kubernetes/common/mongo/templates/nfs-provisoner.yaml new file mode 100644 index 0000000000..355ad38235 --- /dev/null +++ b/kubernetes/common/mongo/templates/nfs-provisoner.yaml @@ -0,0 +1,78 @@ +{{/* +# 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 not .Values.disableNfsProvisioner }} +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + #replicas: {{ .Values.replicaCount }} + strategy: + type: Recreate + template: + metadata: + labels: + app: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner + image: "{{ .Values.global.nfsprovisionerRepository | default .Values.nfsprovisionerRepository }}/{{ .Values.nfsprovisionerImage }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} + ports: + - name: nfs + containerPort: {{ .Values.service.nfsPort }} + - name: mountd + containerPort: {{ .Values.service.mountdPort }} + - name: rpcbind + containerPort: {{ .Values.service.rpcbindPort }} + - name: rpcbind-udp + containerPort: {{ .Values.service.rpcbindUdpPort }} + protocol: UDP + securityContext: + capabilities: + add: + - DAC_READ_SEARCH + - SYS_RESOURCE + args: + - "-provisioner={{ include "common.fullname" . }}/nfs" + env: + - name: POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: SERVICE_NAME + value: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} + volumeMounts: + - name: export-volume + mountPath: /export + volumes: + - name: export-volume + hostPath: + path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ .Release.Name }}/{{ .Values.persistence.mountSubPath }} +{{ end }} diff --git a/kubernetes/common/mongo/templates/pv.yaml b/kubernetes/common/mongo/templates/pv.yaml new file mode 100644 index 0000000000..824dcbb87b --- /dev/null +++ b/kubernetes/common/mongo/templates/pv.yaml @@ -0,0 +1,38 @@ +{{/* +# 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 (and (.Values.persistence.enabled) (not .Values.persistence.existingClaim)) ( .Values.disableNfsProvisioner)) -}} +kind: PersistentVolume +apiVersion: v1 +metadata: + name: {{ include "common.fullname" . }}-data + 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 }} + storageClassName: "{{ include "common.fullname" . }}-data" + 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/mongo/templates/pvc.yaml b/kubernetes/common/mongo/templates/pvc.yaml new file mode 100644 index 0000000000..d1558f131f --- /dev/null +++ b/kubernetes/common/mongo/templates/pvc.yaml @@ -0,0 +1,39 @@ +{{/* +# 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" . }}-data + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +{{- if .Values.persistence.annotations }} + annotations: +{{ toYaml .Values.persistence.annotations | indent 4 }} +{{- end }} +spec: + accessModes: + - {{ .Values.persistence.accessMode }} + resources: + requests: + storage: {{ .Values.persistence.size }} + storageClassName: "{{ include "common.fullname" . }}-data" +{{- end -}} diff --git a/kubernetes/common/mongo/templates/service.yaml b/kubernetes/common/mongo/templates/service.yaml new file mode 100644 index 0000000000..df55854ee5 --- /dev/null +++ b/kubernetes/common/mongo/templates/service.yaml @@ -0,0 +1,97 @@ +{{/* +# Copyright © 2018 Orange +# +# 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: + name: {{ include "common.servicename" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + ports: + - port: {{ .Values.service.internalPort }} + name: {{ .Values.service.portName }} + selector: + app: {{ include "common.name" . }} + release: {{ .Release.Name }} + clusterIP: None +#{{ if not .Values.disableNfsProvisioner }} +--- +kind: Service +apiVersion: v1 +metadata: + name: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner + namespace: {{ include "common.namespace" . }} + labels: + app: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner +spec: + ports: + - name: nfs + port: {{ .Values.service.nfsPort }} + - name: mountd + port: {{ .Values.service.mountdPort }} + - name: rpcbind + port: {{ .Values.service.rpcbindPort }} + - name: rpcbind-udp + port: {{ .Values.service.rpcbindUdpPort }} + protocol: UDP + selector: + app: {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner +#{{ end }} +--- +# Client service for connecting to any Mongo instance for reads. +apiVersion: v1 +kind: Service +metadata: + name: {{ include "common.servicename" . }}-read + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} +spec: + ports: + - port: {{ .Values.service.internalPort }} + name: {{ .Values.service.portName }} + selector: + app: {{ include "common.name" . }} + release: {{ .Release.Name }} +--- +{{ if .Values.geoEnabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "common.servicename" . }}-nodeport + namespace: {{ include "common.namespace" . }} + labels: + statefulset.kubernetes.io/pod-name: {{ include "common.fullname" . }}-0 +spec: + ports: + - name: {{ .Values.service.internalPort }} + port: {{ .Values.service.internalPort }} + targetPort: {{ .Values.service.internalPort }} + nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.externalPort1 }} + - name: {{ .Values.xtrabackup.internalPort }} + port: {{ .Values.xtrabackup.internalPort }} + targetPort: {{ .Values.xtrabackup.internalPort }} + nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.externalPort2 }} + type: NodePort + selector: + statefulset.kubernetes.io/pod-name: {{ include "common.fullname" . }}-0 + release: {{ .Release.Name }} +{{ end }} diff --git a/kubernetes/common/mongo/templates/statefulset.yaml b/kubernetes/common/mongo/templates/statefulset.yaml new file mode 100644 index 0000000000..8b33f611b9 --- /dev/null +++ b/kubernetes/common/mongo/templates/statefulset.yaml @@ -0,0 +1,104 @@ +{{/* +# Copyright © 2018 Orange +# +# 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.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + serviceName: {{ .Values.service.name }} + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ include "common.name" . }} + release: {{ .Release.Name }} + spec: + initContainers: +#{{ if not .Values.disableNfsProvisioner }} + - name: {{ include "common.name" . }}-readiness + command: + - /root/ready.py + args: + - --container-name + - {{ .Values.nfsprovisionerPrefix }}-nfs-provisioner + env: + - name: NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} +#{{ end }} + + containers: + - name: {{ include "common.name" . }} + image: "{{ .Values.dockerHubRepository }}/{{ .Values.image }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} + env: + - name: MONGO_INITDB_DATABASE + value: "{{ .Values.config.dbName }}" + ports: + - containerPort: {{ .Values.service.internalPort }} + # disable liveness probe when breakpoints set in debugger + # so K8s doesn't restart unresponsive container + {{- if eq .Values.liveness.enabled true }} + livenessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} + periodSeconds: {{ .Values.liveness.periodSeconds }} + timeoutSeconds: {{ .Values.liveness.timeoutSeconds }} + {{end -}} + readinessProbe: + tcpSocket: + port: {{ .Values.service.internalPort }} + initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} + periodSeconds: {{ .Values.readiness.periodSeconds }} + volumeMounts: + - mountPath: /var/lib/mongo + name: {{ include "common.fullname" . }}-data + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 10 }} + {{- end -}} + {{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 10 }} + {{- end }} + volumes: + - name: localtime + hostPath: + path: /etc/localtime + - name: {{ include "common.fullname" . }}-data +#{{ if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "common.fullname" . }}-data +#{{ else }} + emptyDir: {} +#{{ end }} diff --git a/kubernetes/common/mongo/templates/storageclass.yaml b/kubernetes/common/mongo/templates/storageclass.yaml new file mode 100644 index 0000000000..3cd502ea30 --- /dev/null +++ b/kubernetes/common/mongo/templates/storageclass.yaml @@ -0,0 +1,24 @@ +{{/* +# 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 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 }} |