diff --git a/mongodb/Chart.yaml b/mongodb/Chart.yaml new file mode 100644 index 0000000000..acaaf7f415 --- /dev/null +++ b/mongodb/Chart.yaml @@ -0,0 +1,24 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# 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: OpenStack-Helm MongoDB +name: mongodb +version: 0.1.0 +home: https://www.mongodb.com +sources: + - https://github.com/mongodb/mongo + - https://git.openstack.org/cgit/openstack/openstack-helm +maintainers: + - name: OpenStack-Helm Authors diff --git a/mongodb/requirements.yaml b/mongodb/requirements.yaml new file mode 100644 index 0000000000..00a045b4e4 --- /dev/null +++ b/mongodb/requirements.yaml @@ -0,0 +1,19 @@ + +# Copyright 2017 The Openstack-Helm Authors. +# +# 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. + +dependencies: + - name: helm-toolkit + repository: http://localhost:8879/charts + version: 0.1.0 diff --git a/mongodb/templates/bin/_setup_admin_user.sh.tpl b/mongodb/templates/bin/_setup_admin_user.sh.tpl new file mode 100644 index 0000000000..7a7b7ded86 --- /dev/null +++ b/mongodb/templates/bin/_setup_admin_user.sh.tpl @@ -0,0 +1,28 @@ +#!/bin/bash + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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. +*/}} + +set -ex +mongo admin \ + --username "${ADMIN_USER}" \ + --password "${ADMIN_PASS}" \ + --eval "db.changeUserPassword(\"${ADMIN_USER}\", \"${ADMIN_PASS}\")" || \ + mongo admin \ + --eval "db.createUser({ user: \"${ADMIN_USER}\", \ + pwd: \"${ADMIN_PASS}\", \ + roles: [ { role: \"userAdminAnyDatabase\", \ + db: \"admin\" } ] });" diff --git a/mongodb/templates/bin/_start.sh.tpl b/mongodb/templates/bin/_start.sh.tpl new file mode 100644 index 0000000000..25abe5acf1 --- /dev/null +++ b/mongodb/templates/bin/_start.sh.tpl @@ -0,0 +1,20 @@ +#!/bin/bash + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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. +*/}} + +set -ex +exec mongod --auth diff --git a/mongodb/templates/configmap-bin.yaml b/mongodb/templates/configmap-bin.yaml new file mode 100644 index 0000000000..b98186f9d5 --- /dev/null +++ b/mongodb/templates/configmap-bin.yaml @@ -0,0 +1,29 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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 .Values.manifests.configmap_bin }} +{{- $envAll := . }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: mongodb-bin +data: + start.sh: | +{{ tuple "bin/_start.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + setup_admin_user.sh: | +{{ tuple "bin/_setup_admin_user.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- end }} diff --git a/mongodb/templates/secret-db-root-password.yaml b/mongodb/templates/secret-db-root-password.yaml new file mode 100644 index 0000000000..cdec2712eb --- /dev/null +++ b/mongodb/templates/secret-db-root-password.yaml @@ -0,0 +1,28 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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 .Values.manifests.secret_db_root_creds }} +{{- $envAll := . }} +--- +apiVersion: v1 +kind: Secret +metadata: + name: mongodb-root-creds +type: Opaque +data: + MONGODB_ROOT_PASSWORD: {{ .Values.endpoints.mongodb.auth.admin.password | b64enc }} + MONGODB_ROOT_USERNAME: {{ .Values.endpoints.mongodb.auth.admin.username | b64enc }} +{{- end }} diff --git a/mongodb/templates/service.yaml b/mongodb/templates/service.yaml new file mode 100644 index 0000000000..cc30790900 --- /dev/null +++ b/mongodb/templates/service.yaml @@ -0,0 +1,30 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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 .Values.manifests.service }} +{{- $envAll := . }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ tuple "mongodb" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} +spec: + ports: + - name: db + port: {{ tuple "mongodb" "internal" "mongodb" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + selector: +{{ tuple $envAll "mongodb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} +{{- end }} diff --git a/mongodb/templates/statefulset.yaml b/mongodb/templates/statefulset.yaml new file mode 100644 index 0000000000..a2be50d9a6 --- /dev/null +++ b/mongodb/templates/statefulset.yaml @@ -0,0 +1,109 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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 .Values.manifests.statefulset }} +{{- $envAll := . }} +--- +apiVersion: apps/v1beta1 +kind: StatefulSet +metadata: + name: mongodb +spec: + serviceName: {{ tuple "mongodb" "internal" . | include "helm-toolkit.endpoints.hostname_short_endpoint_lookup" }} + replicas: {{ .Values.pod.replicas.server }} + template: + metadata: + labels: +{{ tuple $envAll "mongodb" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 8 }} + spec: + affinity: +{{ tuple $envAll "mongodb" "server" | include "helm-toolkit.snippets.kubernetes_pod_anti_affinity" | indent 8 }} + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + containers: + - name: mongodb + image: {{ .Values.images.mongodb }} + imagePullPolicy: {{ .Values.images.pull_policy }} + ports: + - containerPort: {{ tuple "mongodb" "internal" "mongodb" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + env: + - name: ADMIN_PASS + valueFrom: + secretKeyRef: + name: mongodb-root-creds + key: MONGODB_ROOT_PASSWORD + - name: ADMIN_USER + valueFrom: + secretKeyRef: + name: mongodb-root-creds + key: MONGODB_ROOT_USERNAME + command: + - /tmp/start.sh + lifecycle: + postStart: + exec: + command: + - /tmp/setup_admin_user.sh + livenessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: 20 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - mongo + - --eval + - "db.adminCommand('ping')" + initialDelaySeconds: 20 + timeoutSeconds: 5 +{{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + volumeMounts: + - name: mongodb-bin + mountPath: /tmp/start.sh + subPath: start.sh + readOnly: true + - name: mongodb-bin + mountPath: /tmp/setup_admin_user.sh + subPath: setup_admin_user.sh + readOnly: true + - name: mongodb-data + mountPath: /data/db + volumes: + - name: mongodb-bin + configMap: + name: mongodb-bin + defaultMode: 0555 +{{- if not .Values.storage.pvc.enabled }} + - name: mongodb-data + hostPath: + path: {{ .Values.storage.host.host_path }} +{{- else }} + volumeClaimTemplates: + - metadata: + name: mongodb-data + annotations: + {{ .Values.storage.pvc.class_path }}: {{ .Values.storage.pvc.class_name }} + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: {{ .Values.storage.pvc.size }} +{{- end }} +{{- end }} diff --git a/mongodb/values.yaml b/mongodb/values.yaml new file mode 100644 index 0000000000..9075102135 --- /dev/null +++ b/mongodb/values.yaml @@ -0,0 +1,78 @@ +# Copyright 2017 The Openstack-Helm Authors. +# +# 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. + +# Default values for mongodb. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +pod: + affinity: + anti: + type: + default: preferredDuringSchedulingIgnoredDuringExecution + topologyKey: + default: kubernetes.io/hostname + replicas: + #only 1 replica currently supported + server: 1 + resources: + enabled: false + server: + requests: + memory: "128Mi" + cpu: "100m" + limits: + memory: "1024Mi" + cpu: "2000m" + +# using dockerhub mongodb: https://hub.docker.com/r/library/mongo/tags/ +images: + mongodb: docker.io/mongo:3.4.9-jessie + pull_policy: IfNotPresent + +storage: + pvc: + enabled: false + size: 5Gi + class_name: general + class_path: volume.beta.kubernetes.io/storage-class + host: + host_path: /var/lib/openstack-helm/mongodb + +labels: + node_selector_key: openstack-control-plane + node_selector_value: enabled + +endpoints: + cluster_domain_suffix: cluster.local + mongodb: + auth: + admin: + username: root + password: password + hosts: + default: mongodb + host_fqdn_override: + default: null + path: null + scheme: mongodb + port: + mongodb: + default: 27017 + +manifests: + configmap_bin: true + secret_db_root_creds: true + service: true + statefulset: true diff --git a/tools/gate/launch-osh/basic.sh b/tools/gate/launch-osh/basic.sh index cdc3048b82..c933c499ed 100755 --- a/tools/gate/launch-osh/basic.sh +++ b/tools/gate/launch-osh/basic.sh @@ -130,7 +130,6 @@ if [ "x$INTEGRATION" == "xmulti" ]; then helm install --namespace=openstack ${WORK_DIR}/postgresql --name=postgresql helm install --namespace=openstack ${WORK_DIR}/gnocchi --name=gnocchi helm install --namespace=openstack ${WORK_DIR}/mongodb --name=mongodb - helm install --namespace=openstack ${WORK_DIR}/ceilometer --name=ceilometer fi kube_wait_for_pods openstack ${POD_START_TIMEOUT_OPENSTACK} fi