From e99a3f29c508f65cc237b3edaef9704096c9d9ef Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Wed, 12 Jul 2017 10:03:00 -0500 Subject: [PATCH] Ceph: add bootstrap job to create pools. This PS adds a bootstrap job to create the default pools for OpenStack Services to consume. Change-Id: I139d7f095c600821ef5ee3b4d2c70a00b971f32b --- ceph/templates/bin/_bootstrap.sh.tpl | 18 ++++++++ ceph/templates/configmap-bin.yaml | 4 ++ ceph/templates/job-bootstrap.yaml | 63 ++++++++++++++++++++++++++++ ceph/values.yaml | 26 +++++++++++- tools/gate/basic_launch.sh | 6 +-- 5 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 ceph/templates/bin/_bootstrap.sh.tpl create mode 100644 ceph/templates/job-bootstrap.yaml diff --git a/ceph/templates/bin/_bootstrap.sh.tpl b/ceph/templates/bin/_bootstrap.sh.tpl new file mode 100644 index 0000000000..81a1391466 --- /dev/null +++ b/ceph/templates/bin/_bootstrap.sh.tpl @@ -0,0 +1,18 @@ +#!/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 +{{ .Values.bootstrap.script | default "echo 'Not Enabled'" }} diff --git a/ceph/templates/configmap-bin.yaml b/ceph/templates/configmap-bin.yaml index d8de23d0b8..e7a892123f 100644 --- a/ceph/templates/configmap-bin.yaml +++ b/ceph/templates/configmap-bin.yaml @@ -17,6 +17,10 @@ kind: ConfigMap metadata: name: ceph-bin data: +{{- if .Values.bootstrap.enabled }} + bootstrap.sh: |+ +{{ tuple "bin/_bootstrap.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- end }} {{- if .Values.manifests_enabled.storage_secrets }} ceph-key.py: |+ {{ tuple "bin/_ceph-key.py.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} diff --git a/ceph/templates/job-bootstrap.yaml b/ceph/templates/job-bootstrap.yaml new file mode 100644 index 0000000000..6aae2af70f --- /dev/null +++ b/ceph/templates/job-bootstrap.yaml @@ -0,0 +1,63 @@ +# 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. + +{{- $envAll := . }} +{{- if .Values.bootstrap.enabled }} +{{- $dependencies := .Values.dependencies.bootstrap }} +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: ceph-bootstrap +spec: + template: + spec: + restartPolicy: OnFailure + nodeSelector: + {{ .Values.labels.node_selector_key }}: {{ .Values.labels.node_selector_value }} + initContainers: +{{ tuple $envAll $dependencies "" | include "helm-toolkit.snippets.kubernetes_entrypoint_init_container" | indent 8 }} + containers: + - name: ceph-bootstrap + image: {{ .Values.images.bootstrap }} + imagePullPolicy: {{ .Values.images.pull_policy }} +{{ tuple $envAll $envAll.Values.pod.resources.jobs.bootstrap | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} + command: + - /tmp/bootstrap.sh + volumeMounts: + - name: ceph-bin + mountPath: /tmp/bootstrap.sh + subPath: bootstrap.sh + readOnly: true + - name: ceph-etc + mountPath: /etc/ceph/ceph.conf + subPath: ceph.conf + readOnly: true + - name: ceph-client-admin-keyring + mountPath: /etc/ceph/ceph.client.admin.keyring + subPath: ceph.client.admin.keyring + readOnly: true + volumes: + - name: ceph-bin + configMap: + name: ceph-bin + defaultMode: 0555 + - name: ceph-etc + configMap: + name: ceph-etc + defaultMode: 0444 + - name: ceph-client-admin-keyring + secret: + secretName: {{ .Values.secrets.keyrings.admin }} +{{- end }} diff --git a/ceph/values.yaml b/ceph/values.yaml index 61b37bedfe..c8630e6b8e 100644 --- a/ceph/values.yaml +++ b/ceph/values.yaml @@ -27,6 +27,7 @@ service: name: ceph-mon images: + bootstrap: quay.io/attcomdev/ceph-daemon:tag-build-master-jewel-ubuntu-16.04 dep_check: docker.io/kolla/ubuntu-source-kubernetes-entrypoint:4.0.0 daemon: quay.io/attcomdev/ceph-daemon:tag-build-master-jewel-ubuntu-16.04 ceph_config_helper: docker.io/port/ceph-config-helper:v1.6.7 @@ -79,6 +80,13 @@ pod: memory: "50Mi" cpu: "500m" jobs: + bootstrap: + limits: + memory: "1024Mi" + cpu: "2000m" + requests: + memory: "128Mi" + cpu: "500m" secret_provisioning: limits: memory: "1024Mi" @@ -164,7 +172,6 @@ conf: mds: mds_cache_size: 100000 - dependencies: mon: jobs: @@ -189,7 +196,11 @@ dependencies: services: - service: ceph_mon endpoint: internal - + bootstrap: + jobs: + services: + - service: ceph_mon + endpoint: internal ceph: enabled: @@ -204,6 +215,17 @@ ceph: rgw: enabled: false +bootstrap: + enabled: false + script: | + ceph -s + function ensure_pool () { + ceph osd pool stats $1 || ceph osd pool create $1 $2 + } + ensure_pool volumes 8 + ensure_pool images 8 + ensure_pool vms 8 + # if you change provision_storage_class to false # it is presumed you manage your own storage # class definition externally diff --git a/tools/gate/basic_launch.sh b/tools/gate/basic_launch.sh index 9c0827a9f7..e12644a0c1 100755 --- a/tools/gate/basic_launch.sh +++ b/tools/gate/basic_launch.sh @@ -44,7 +44,8 @@ EOF" helm install --namespace=ceph ${WORK_DIR}/ceph --name=ceph \ --set manifests_enabled.client_secrets=false \ --set network.public=$osd_public_network \ - --set network.cluster=$osd_cluster_network + --set network.cluster=$osd_cluster_network \ + --set bootstrap.enabled=true kube_wait_for_pods ceph 600 @@ -59,9 +60,6 @@ EOF" kube_wait_for_pods openstack 420 - kubectl exec -n ceph ceph-mon-0 -- ceph osd pool create volumes 8 - kubectl exec -n ceph ceph-mon-0 -- ceph osd pool create images 8 - kubectl exec -n ceph ceph-mon-0 -- ceph osd pool create vms 8 fi helm install --namespace=openstack ${WORK_DIR}/ingress --name=ingress