A tenant contains various resources. To prevent a tenant from becoming bloated and improve tenant O&M flexibility, ob-operator provides the tenant O&M resource OBTenantOperation for you to perform intra-tenant and inter-tenant O&M operations. ob-operator V2.1.0 supports three O&M operations: changing the password of the root user, activating a standby tenant, and executing a primary/standby tenant switchover. Standby tenant activation and primary/standby tenant switchover are related to the physical standby database feature. Here are sample configurations of the three O&M operations:
# Change the password.
apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBTenantOperation
metadata:
name: op-chg-pwd
namespace: oceanbase
spec:
type: "CHANGE_PASSWORD"
changePwd:
tenant: "t1"
secretRef: "t1-credential-new"
# Upgrade a standby tenant to the primary tenant.
apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBTenantOperation
metadata:
name: op-failover
namespace: oceanbase
spec:
type: "FAILOVER"
failover:
standbyTenant: "t1s"
# Perform a primary/standby tenant switchover.
apiVersion: oceanbase.oceanbase.com/v1alpha1
kind: OBTenantOperation
metadata:
name: op-switchover
namespace: oceanbase
spec:
type: "SWITCHOVER"
switchover:
primaryTenant: "t1"
standbyTenant: "t1s"
Examples
Create a standby tenant
kubectl apply -f tenant_restore.yaml
View the tenant status
kubectl get obtenants.oceanbase.oceanbase.com -n oceanbase
The command output is as follows:
NAME STATUS TENANTNAME TENANTROLE CLUSTERNAME AGE
t1 running t1 PRIMARY obcluster 3d4h
t1s running t1s STANDBY obcluster 3h30m
Perform O&M operations on the tenant
kubectl apply -f tenant_op_change_pwd.yaml
kubectl apply -f tenant_op_failover.yaml
Query the information about the tenant O&M operations
kubectl get obtenantoperations.oceanbase.oceanbase.com -n oceanbase
The command output is as follows:
NAME TYPE STATUS AGE CLUSTER PRIMARYTENANT
op-failover FAILOVER SUCCESSFUL 8s obcluster t1s
Note that in the printed status information, PRIMARYTENANT refers to the primary tenant as specified in the operation parameters, not the tenant whose TENANTROLE is PRIMARY. The corresponding secondary tenant is SECONDARYTENANT. To save space, the secondary tenant field is not printed by default. You can run kubectl get obtenantoperations.oceanbase.oceanbase.com -o wide to view it.
