diff --git a/ceph/templates/templates/_admin.keyring.tpl b/ceph/templates/templates/_admin.keyring.tpl index 7c5de607b6..e012ebe858 100644 --- a/ceph/templates/templates/_admin.keyring.tpl +++ b/ceph/templates/templates/_admin.keyring.tpl @@ -4,3 +4,4 @@ caps mds = "allow" caps mon = "allow *" caps osd = "allow *" + caps mgr = "allow *" diff --git a/cinder/templates/_funcs.tpl b/cinder/templates/_funcs.tpl index 0d9b52f779..785ee25427 100644 --- a/cinder/templates/_funcs.tpl +++ b/cinder/templates/_funcs.tpl @@ -24,9 +24,12 @@ true {{- end -}} {{- end -}} -{{- define "cinder.is_ceph_backup_configured" -}} -{{- $values := .Values.conf.cinder.DEFAULT -}} -{{- if eq $values.backup_driver "cinder.backup.drivers.ceph" -}} -true +{{- define "cinder.ceph_volume_section_name" -}} +{{- range $section, $values := .Values.conf.backends -}} +{{- if kindIs "map" $values -}} +{{- if eq $values.volume_driver "cinder.volume.drivers.rbd.RBDDriver" -}} +{{ $section }} +{{- end -}} +{{- end -}} {{- end -}} {{- end -}} diff --git a/cinder/templates/bin/_backup-storage-init.sh.tpl b/cinder/templates/bin/_backup-storage-init.sh.tpl new file mode 100644 index 0000000000..c5db2ed9cb --- /dev/null +++ b/cinder/templates/bin/_backup-storage-init.sh.tpl @@ -0,0 +1,65 @@ +#!/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 -x +if [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then + SECRET=$(mktemp --suffix .yaml) + KEYRING=$(mktemp --suffix .keyring) + function cleanup { + rm -f ${SECRET} ${KEYRING} + } + trap cleanup EXIT +fi + +set -ex +if [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.swift" ] || \ + [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.posix" ]; then + echo "INFO: no action required to use $STORAGE_BACKEND" +elif [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then + ceph -s + function ensure_pool () { + ceph osd pool stats $1 || ceph osd pool create $1 $2 + ceph osd pool application enable $1 $3 + } + ensure_pool ${RBD_POOL_NAME} ${RBD_POOL_CHUNK_SIZE} "cinder-backup" + + if USERINFO=$(ceph auth get client.${RBD_POOL_USER}); then + KEYSTR=$(echo $USERINFO | sed 's/.*\( key = .*\) caps mon.*/\1/') + echo $KEYSTR > ${KEYRING} + else + #NOTE(Portdirect): Determine proper privs to assign keyring + ceph auth get-or-create client.${RBD_POOL_USER} \ + mon "allow *" \ + osd "allow *" \ + mgr "allow *" \ + -o ${KEYRING} + fi + + ENCODED_KEYRING=$(sed -n 's/^[[:blank:]]*key[[:blank:]]\+=[[:blank:]]\(.*\)/\1/p' ${KEYRING} | base64 -w0) + cat > ${SECRET} < /etc/ceph/ceph.client.{{ .Values.conf.backends.rbd1.rbd_user }}.keyring -[client.{{ .Values.conf.backends.rbd1.rbd_user }}] +cat < /etc/ceph/ceph.client.${RBD_USER}.keyring +[client.${RBD_USER}] {{- if .Values.conf.ceph.cinder_keyring }} key = {{ .Values.conf.ceph.cinder_keyring }} {{- else }} @@ -28,4 +28,4 @@ cat < /etc/ceph/ceph.client.{{ .Values.conf.backends.rbd1.rbd_user }}.keyr {{- end }} EOF -exit 0 \ No newline at end of file +exit 0 diff --git a/cinder/templates/bin/_clean-secrets.sh.tpl b/cinder/templates/bin/_clean-secrets.sh.tpl new file mode 100644 index 0000000000..d133adb517 --- /dev/null +++ b/cinder/templates/bin/_clean-secrets.sh.tpl @@ -0,0 +1,24 @@ +#!/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 kubectl delete secret \ + --namespace ${NAMESPACE} \ + --ignore-not-found=true \ + ${RBD_POOL_SECRET} diff --git a/cinder/templates/bin/_storage-init.sh.tpl b/cinder/templates/bin/_storage-init.sh.tpl new file mode 100644 index 0000000000..2d32249f6c --- /dev/null +++ b/cinder/templates/bin/_storage-init.sh.tpl @@ -0,0 +1,62 @@ +#!/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 -x +if [ "x$STORAGE_BACKEND" == "xcinder.volume.drivers.rbd.RBDDriver" ]; then + SECRET=$(mktemp --suffix .yaml) + KEYRING=$(mktemp --suffix .keyring) + function cleanup { + rm -f ${SECRET} ${KEYRING} + } + trap cleanup EXIT +fi + +set -ex +if [ "x$STORAGE_BACKEND" == "xcinder.volume.drivers.rbd.RBDDriver" ]; then + ceph -s + function ensure_pool () { + ceph osd pool stats $1 || ceph osd pool create $1 $2 + ceph osd pool application enable $1 $3 + } + ensure_pool ${RBD_POOL_NAME} ${RBD_POOL_CHUNK_SIZE} "cinder-volume" + + if USERINFO=$(ceph auth get client.${RBD_POOL_USER}); then + KEYSTR=$(echo $USERINFO | sed 's/.*\( key = .*\) caps mon.*/\1/') + echo $KEYSTR > ${KEYRING} + else + #NOTE(Portdirect): Determine proper privs to assign keyring + ceph auth get-or-create client.${RBD_POOL_USER} \ + mon "allow *" \ + osd "allow *" \ + mgr "allow *" \ + -o ${KEYRING} + fi + + ENCODED_KEYRING=$(sed -n 's/^[[:blank:]]*key[[:blank:]]\+=[[:blank:]]\(.*\)/\1/p' ${KEYRING} | base64 -w0) + cat > ${SECRET} <