From a58f80599bfd07f70a2829365ddd6fc28f3f7e09 Mon Sep 17 00:00:00 2001 From: Stephen Taylor Date: Wed, 24 May 2023 14:59:10 -0600 Subject: [PATCH] [ceph] Add support for deploying and managing Ceph with Rook This change adds an openstack-support-rook zuul job to test deploying Ceph using the upstream Rook helm charts found in the https://charts.rook.io/release repository. Minor changes to the storage keyring manager job and the mon discovery service in the ceph-mon chart are also included to allow the ceph-mon chart to be used to generate auth keys and deploy the mon discovery service necessary for OpenStack. Change-Id: Iee4174dc54b6a7aac6520c448a54adb1325cccab --- ceph-mon/Chart.yaml | 2 +- .../bin/keys/_storage-keyring-manager.sh.tpl | 12 +- .../templates/job-storage-admin-keys.yaml | 3 + ceph-mon/templates/service-mon-discovery.yaml | 5 + releasenotes/notes/ceph-mon.yaml | 1 + .../000-install-packages.sh | 1 + .../openstack-support-rook/000-prepare-k8s.sh | 1 + .../openstack-support-rook/005-deploy-k8s.sh | 1 + .../007-namespace-config.sh | 24 + .../openstack-support-rook/010-ingress.sh | 45 ++ .../openstack-support-rook/020-ceph.sh | 716 ++++++++++++++++++ .../025-ceph-ns-activate.sh | 58 ++ .../openstack-support-rook/030-rabbitmq.sh | 35 + .../openstack-support-rook/040-memcached.sh | 30 + .../openstack-support-rook/050-libvirt.sh | 34 + .../openstack-support-rook/051-libvirt-ssl.sh | 76 ++ .../openstack-support-rook/060-openvswitch.sh | 25 + .../openstack-support-rook/070-mariadb.sh | 1 + .../080-setup-client.sh | 1 + .../openstack-support-rook/090-keystone.sh | 1 + .../100-ceph-radosgateway.sh | 63 ++ .../110-openstack-exporter.sh | 29 + .../openstack-support-rook/120-powerdns.sh | 28 + .../openstack-support-rook/130-cinder.sh | 63 ++ zuul.d/jobs.yaml | 27 + zuul.d/project.yaml | 2 + 26 files changed, 1282 insertions(+), 2 deletions(-) create mode 120000 tools/deployment/openstack-support-rook/000-install-packages.sh create mode 120000 tools/deployment/openstack-support-rook/000-prepare-k8s.sh create mode 120000 tools/deployment/openstack-support-rook/005-deploy-k8s.sh create mode 100755 tools/deployment/openstack-support-rook/007-namespace-config.sh create mode 100755 tools/deployment/openstack-support-rook/010-ingress.sh create mode 100755 tools/deployment/openstack-support-rook/020-ceph.sh create mode 100755 tools/deployment/openstack-support-rook/025-ceph-ns-activate.sh create mode 100755 tools/deployment/openstack-support-rook/030-rabbitmq.sh create mode 100755 tools/deployment/openstack-support-rook/040-memcached.sh create mode 100755 tools/deployment/openstack-support-rook/050-libvirt.sh create mode 100755 tools/deployment/openstack-support-rook/051-libvirt-ssl.sh create mode 100755 tools/deployment/openstack-support-rook/060-openvswitch.sh create mode 120000 tools/deployment/openstack-support-rook/070-mariadb.sh create mode 120000 tools/deployment/openstack-support-rook/080-setup-client.sh create mode 120000 tools/deployment/openstack-support-rook/090-keystone.sh create mode 100755 tools/deployment/openstack-support-rook/100-ceph-radosgateway.sh create mode 100755 tools/deployment/openstack-support-rook/110-openstack-exporter.sh create mode 100755 tools/deployment/openstack-support-rook/120-powerdns.sh create mode 100755 tools/deployment/openstack-support-rook/130-cinder.sh diff --git a/ceph-mon/Chart.yaml b/ceph-mon/Chart.yaml index 4294a495b..425783099 100644 --- a/ceph-mon/Chart.yaml +++ b/ceph-mon/Chart.yaml @@ -15,6 +15,6 @@ apiVersion: v1 appVersion: v1.0.0 description: OpenStack-Helm Ceph Mon name: ceph-mon -version: 0.1.30 +version: 0.1.31 home: https://github.com/ceph/ceph ... diff --git a/ceph-mon/templates/bin/keys/_storage-keyring-manager.sh.tpl b/ceph-mon/templates/bin/keys/_storage-keyring-manager.sh.tpl index dfa85f437..b8cb6f506 100644 --- a/ceph-mon/templates/bin/keys/_storage-keyring-manager.sh.tpl +++ b/ceph-mon/templates/bin/keys/_storage-keyring-manager.sh.tpl @@ -28,7 +28,17 @@ function kube_ceph_keyring_gen () { sed "s|{{"{{"}} key {{"}}"}}|${CEPH_KEY}|" ${CEPH_TEMPLATES_DIR}/${CEPH_KEY_TEMPLATE} | base64 -w0 | tr -d '\n' } -CEPH_CLIENT_KEY=$(ceph_gen_key) +CEPH_CLIENT_KEY="" +ROOK_CEPH_TOOLS_POD=$(kubectl -n ${DEPLOYMENT_NAMESPACE} get pods --no-headers | awk '/rook-ceph-tools/{print $1}') + +if [[ -n "${ROOK_CEPH_TOOLS_POD}" ]]; then + CEPH_AUTH_KEY_NAME=$(echo "${CEPH_KEYRING_NAME}" | awk -F. '{print $2 "." $3}') + CEPH_CLIENT_KEY=$(kubectl -n ${DEPLOYMENT_NAMESPACE} exec ${ROOK_CEPH_TOOLS_POD} -- ceph auth ls | grep -A1 "${CEPH_AUTH_KEY_NAME}" | awk '/key:/{print $2}') +fi + +if [[ -z "${CEPH_CLIENT_KEY}" ]]; then + CEPH_CLIENT_KEY=$(ceph_gen_key) +fi function create_kube_key () { CEPH_KEYRING=$1 diff --git a/ceph-mon/templates/job-storage-admin-keys.yaml b/ceph-mon/templates/job-storage-admin-keys.yaml index a8812f884..2d782d434 100644 --- a/ceph-mon/templates/job-storage-admin-keys.yaml +++ b/ceph-mon/templates/job-storage-admin-keys.yaml @@ -26,11 +26,14 @@ rules: - apiGroups: - "" resources: + - pods + - pods/exec - secrets verbs: - get - create - patch + - list --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding diff --git a/ceph-mon/templates/service-mon-discovery.yaml b/ceph-mon/templates/service-mon-discovery.yaml index 71066a5aa..04582ff7e 100644 --- a/ceph-mon/templates/service-mon-discovery.yaml +++ b/ceph-mon/templates/service-mon-discovery.yaml @@ -30,7 +30,12 @@ spec: protocol: TCP targetPort: {{ tuple "ceph_mon" "discovery" "mon_msgr2" $envAll | include "helm-toolkit.endpoints.endpoint_port_lookup" }} selector: +{{- if .Values.manifests.daemonset_mon }} {{ tuple $envAll "ceph" "mon" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{- else }} + app: rook-ceph-mon + ceph_daemon_type: mon +{{- end }} clusterIP: None publishNotReadyAddresses: true {{- end }} diff --git a/releasenotes/notes/ceph-mon.yaml b/releasenotes/notes/ceph-mon.yaml index e8d4d6699..835e2ede3 100644 --- a/releasenotes/notes/ceph-mon.yaml +++ b/releasenotes/notes/ceph-mon.yaml @@ -31,4 +31,5 @@ ceph-mon: - 0.1.28 Document the use of mon_allow_pool_size_one - 0.1.29 Update Ceph to 17.2.6 - 0.1.30 Use Helm tookkit functions for Ceph probes + - 0.1.31 Add Rook Helm charts for managing Ceph with Rook ... diff --git a/tools/deployment/openstack-support-rook/000-install-packages.sh b/tools/deployment/openstack-support-rook/000-install-packages.sh new file mode 120000 index 000000000..d702c4899 --- /dev/null +++ b/tools/deployment/openstack-support-rook/000-install-packages.sh @@ -0,0 +1 @@ +../common/000-install-packages.sh \ No newline at end of file diff --git a/tools/deployment/openstack-support-rook/000-prepare-k8s.sh b/tools/deployment/openstack-support-rook/000-prepare-k8s.sh new file mode 120000 index 000000000..aa9807064 --- /dev/null +++ b/tools/deployment/openstack-support-rook/000-prepare-k8s.sh @@ -0,0 +1 @@ +../common/prepare-k8s.sh \ No newline at end of file diff --git a/tools/deployment/openstack-support-rook/005-deploy-k8s.sh b/tools/deployment/openstack-support-rook/005-deploy-k8s.sh new file mode 120000 index 000000000..003bfbb8e --- /dev/null +++ b/tools/deployment/openstack-support-rook/005-deploy-k8s.sh @@ -0,0 +1 @@ +../../gate/deploy-k8s.sh \ No newline at end of file diff --git a/tools/deployment/openstack-support-rook/007-namespace-config.sh b/tools/deployment/openstack-support-rook/007-namespace-config.sh new file mode 100755 index 000000000..a52d77254 --- /dev/null +++ b/tools/deployment/openstack-support-rook/007-namespace-config.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +# 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 -xe + +#NOTE: Lint and package chart +make namespace-config + +#NOTE: Deploy namespace configs +for NAMESPACE in kube-system ceph openstack; do + helm upgrade --install ${NAMESPACE}-namespace-config ./namespace-config \ + --namespace=${NAMESPACE} +done diff --git a/tools/deployment/openstack-support-rook/010-ingress.sh b/tools/deployment/openstack-support-rook/010-ingress.sh new file mode 100755 index 000000000..ffe3ebc87 --- /dev/null +++ b/tools/deployment/openstack-support-rook/010-ingress.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# 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 -xe + +#NOTE: Lint and package chart +make ingress + +#NOTE: Deploy global ingress with IngressClass nginx-cluster +tee /tmp/ingress-kube-system.yaml < /tmp/ceph-fs-uuid.txt +CEPH_FS_ID="$(cat /tmp/ceph-fs-uuid.txt)" +#NOTE(portdirect): to use RBD devices with Ubuntu kernels < 4.5 this +# should be set to 'hammer' +. /etc/os-release +if [ "x${ID}" == "xcentos" ] || \ + ([ "x${ID}" == "xubuntu" ] && \ + dpkg --compare-versions "$(uname -r)" "lt" "4.5"); then + CRUSH_TUNABLES=hammer +else + CRUSH_TUNABLES=null +fi +tee /tmp/rook.yaml <