From 120fcfe214c394321d0ff2999403f91173557aae Mon Sep 17 00:00:00 2001 From: Chris Sun <85611200+chris-sun-star@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:34:12 +0800 Subject: [PATCH] optimize the deployment for oceanbase used as openstack's metadb (#636) --- example/openstack/README.md | 60 +---- example/openstack/oceanbase.sh | 277 +++++++++++++++++++++ example/openstack/oceanbase/obcluster.yaml | 45 ---- example/openstack/oceanbase/obtenant.yaml | 40 --- 4 files changed, 280 insertions(+), 142 deletions(-) create mode 100644 example/openstack/oceanbase.sh delete mode 100644 example/openstack/oceanbase/obcluster.yaml delete mode 100644 example/openstack/oceanbase/obtenant.yaml diff --git a/example/openstack/README.md b/example/openstack/README.md index 644e98b5e..0faea24a9 100644 --- a/example/openstack/README.md +++ b/example/openstack/README.md @@ -2,70 +2,16 @@ ## Overview This folder contains configuration files to deploy OceanBase and OpenStack on Kubernetes. -* OceanBase configuration files are located in the oceanbase directory. +* A script for setting up OceanBase cluster and create tenant and deploy obproxy and finally provide a connection to use. * OpenStack configuration files are located in the openstack directory. ## Deploy steps ### Deploy OceanBase -1. Deploy cert-manager -Deploy the cert-manager using the following command. Ensure all pods are running before proceeding to the next step: +The script oceanbase.sh provides a simple way to deploy OceanBase ready for use as OpenStack's metadb, it requires the storage class `general` already created in the K8s cluster, to deploy OceanBase you can simply run the following command ``` -kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.3.0_release/deploy/cert-manager.yaml - -``` -2. deploy ob-operator -Deploy the ob-operator using the command below. Wait until all pods are running: -``` -kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.3.0_release/deploy/cert-manager.yaml -``` -3. create secret -Create secret using the following command -``` -kubectl create secret generic root-password --from-literal=password='password' -n openstack -``` - -4. deploy obcluster -Deploy the obcluster using the following command: -``` -kubectl apply -f oceanbase/obcluster.yaml -``` -Wait until the obcluster status changes to `running`. You can check the status using: -``` -kubectl get obcluster openstack -n openstack -o wide -``` - -5. deploy obtenant -Deploy the obtenant using the command below: -``` -kubectl apply -f oceanbase/obtenant.yaml +bash oceanbase.sh ``` -Wait until the obtenant status changes to `running`. You can verify this using: -``` -kubectl get obtenant openstack -n openstack -o wide -``` - -6. deploy obproxy -A script is provided to set up obproxy. Download the script with the following command: -``` -wget https://raw.githubusercontent.com/oceanbase/ob-operator/master/scripts/setup-obproxy.sh -``` -Run the script to set up obproxy: -``` -bash setup-obproxy.sh -n openstack --proxy-version 4.2.3.0-3 --env ODP_MYSQL_VERSION=8.0.30 --env ODP_PROXY_TENANT_NAME=openstack -d openstack openstack -``` - -7. Configure Tenant Variables -Connect to the openstack tenant using the command below (${ip} need to be replaced with the obproxy ip, root@openstack is the root user of openstack tenant, and the default password is password): -``` -mysql -h${ip} -P2883 -uroot@openstack -p -``` -Set the necessary variables -``` -set global version='8.0.30'; -set global autocommit=0; -``` - ### Deploy OpenStack Once OceanBase is set up, deploying OpenStack is straightforward. Override the necessary variables using the files under the openstack directory. The files are based on OpenStack version 2024.1. diff --git a/example/openstack/oceanbase.sh b/example/openstack/oceanbase.sh new file mode 100644 index 000000000..b4d779765 --- /dev/null +++ b/example/openstack/oceanbase.sh @@ -0,0 +1,277 @@ +#!/bin/bash + +set -xe + +CLUSTER_NAME=openstack +TENANT_NAME=openstack +OCEANBASE_NAMESPACE=openstack +STORAGE_CLASS=general +OCEANBASE_CLUSTER_IMAGE=oceanbase/oceanbase-cloud-native:4.3.3.1-101000012024102216 +OBPROXY_IMAGE=oceanbase/obproxy-ce:4.3.2.0-26 +ROOT_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 | base64 -w 0) +PROXYRO_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16 | base64 -w 0) + +# check and install cert-manager +if kubectl get crds -o name | grep 'certificates.cert-manager.io' +then + echo "cert-manager is already installed" +else + echo "cert-manager is not installed, install it now" + kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/refs/heads/master/deploy/cert-manager.yaml +fi + +# install ob-operator, always apply the newest version +echo "install or update ob-operator" +kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/refs/heads/2.3.0_release/deploy/operator.yaml +kubectl wait --for=condition=Ready pod -l "control-plane=controller-manager" -n oceanbase-system --timeout=300s + +tee /tmp/namespace.yaml <