Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
yang1666204 committed Apr 28, 2024
2 parents 11a17fd + f8690b7 commit 1b9776e
Show file tree
Hide file tree
Showing 60 changed files with 1,591 additions and 841 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ jobs:
git config user.email "[email protected]"
- name: Run chart-releaser
uses: powerfooI/[email protected].1
uses: powerfooI/[email protected].2
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
mark_as_latest: false
skip_existing: true
pages_branch: master
pages_index_path: docsite/static/index.yaml
pages_index_path: docsite/static/index.yaml
pr: true
2 changes: 1 addition & 1 deletion .github/workflows/release-obproxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
platforms: linux/amd64,linux/arm64
file: ./distribution/obproxy/Dockerfile
push: true
tags: ${{ vars.DOCKER_PUSH_BASE }}/obproxy:${{ steps.set_version_vars.outputs.version }}
tags: ${{ vars.DOCKER_PUSH_BASE }}/obproxy-ce:${{ steps.set_version_vars.outputs.version }}
build-args: |
VERSION=${{ steps.set_version_vars.outputs.version }}
3 changes: 2 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ mysql -h{POD_IP} -P2881 -uroot -proot_password oceanbase -A -c
```
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm repo update ob-operator
helm install oceanbase-dashboard ob-operator/oceanbase-dashboard --version=0.2.0
helm install oceanbase-dashboard ob-operator/oceanbase-dashboard
```

![oceanbase-dashboard-install](./docsite/static/img/oceanbase-dashboard-install.jpg)
Expand All @@ -147,6 +147,7 @@ kubectl get svc oceanbase-dashboard-oceanbase-dashboard

使用 admin 账号和查看到的密码登录。
![oceanbase-dashboard-overview](./docsite/static/img/oceanbase-dashboard-overview.jpg)
![oceanbase-dashboard-topology](./docsite/static/img/oceanbase-dashboard-topology.jpg)

## 项目架构

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Deploy OceanBase Dashboard is pretty simple, just run the following commands
```
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm repo update ob-operator
helm install oceanbase-dashboard ob-operator/oceanbase-dashboard --version=0.2.0
helm install oceanbase-dashboard ob-operator/oceanbase-dashboard
```

![oceanbase-dashboard-install](./docsite/static/img/oceanbase-dashboard-install.jpg)
Expand All @@ -146,6 +146,7 @@ kubectl get svc oceanbase-dashboard-oceanbase-dashboard

Login with admin user and password
![oceanbase-dashboard-overview](./docsite/static/img/oceanbase-dashboard-overview.jpg)
![oceanbase-dashboard-topology](./docsite/static/img/oceanbase-dashboard-topology.jpg)

## Project Architecture

Expand Down
18 changes: 9 additions & 9 deletions api/v1alpha1/obcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"

apitypes "github.com/oceanbase/ob-operator/api/types"
obcfg "github.com/oceanbase/ob-operator/internal/config/operator"
oceanbaseconst "github.com/oceanbase/ob-operator/internal/const/oceanbase"
)

Expand All @@ -61,7 +62,7 @@ func (r *OBCluster) Default() {
parameterMap := make(map[string]apitypes.Parameter, 0)
memorySize, ok := r.Spec.OBServerTemplate.Resource.Memory.AsInt64()
if ok {
memoryLimit := fmt.Sprintf("%dM", memorySize*oceanbaseconst.DefaultMemoryLimitPercent/100/oceanbaseconst.MegaConverter)
memoryLimit := fmt.Sprintf("%dM", memorySize*int64(obcfg.GetConfig().Resource.DefaultMemoryLimitPercent)/100/oceanbaseconst.MegaConverter)
parameterMap["memory_limit"] = apitypes.Parameter{
Name: "memory_limit",
Value: memoryLimit,
Expand All @@ -71,12 +72,12 @@ func (r *OBCluster) Default() {
}
datafileDiskSize, ok := r.Spec.OBServerTemplate.Storage.DataStorage.Size.AsInt64()
if ok {
datafileMaxSize := fmt.Sprintf("%dG", datafileDiskSize*oceanbaseconst.DefaultDiskUsePercent/oceanbaseconst.GigaConverter/100)
datafileMaxSize := fmt.Sprintf("%dG", datafileDiskSize*int64(obcfg.GetConfig().Resource.DefaultDiskUsePercent)/oceanbaseconst.GigaConverter/100)
parameterMap["datafile_maxsize"] = apitypes.Parameter{
Name: "datafile_maxsize",
Value: datafileMaxSize,
}
datafileNextSize := fmt.Sprintf("%dG", datafileDiskSize*oceanbaseconst.DefaultDiskExpandPercent/oceanbaseconst.GigaConverter/100)
datafileNextSize := fmt.Sprintf("%dG", datafileDiskSize*int64(obcfg.GetConfig().Resource.DefaultDiskExpandPercent)/oceanbaseconst.GigaConverter/100)
parameterMap["datafile_next"] = apitypes.Parameter{
Name: "datafile_next",
Value: datafileNextSize,
Expand All @@ -92,7 +93,7 @@ func (r *OBCluster) Default() {
logSize, ok := r.Spec.OBServerTemplate.Storage.LogStorage.Size.AsInt64()
if ok {
// observer has 4 types of log and one logfile limits at 256M considering about wf, maximum of 2G will be occupied for 1 syslog count
maxSysLogFileCount = logSize * oceanbaseconst.DefaultLogPercent / oceanbaseconst.GigaConverter / 100 / 2
maxSysLogFileCount = logSize * int64(obcfg.GetConfig().Resource.DefaultLogPercent) / oceanbaseconst.GigaConverter / 100 / 2
}
parameterMap["max_syslog_file_count"] = apitypes.Parameter{
Name: "max_syslog_file_count",
Expand Down Expand Up @@ -275,18 +276,17 @@ func (r *OBCluster) validateMutation() error {
}

// Validate disk size
if r.Spec.OBServerTemplate.Storage.DataStorage.Size.AsApproximateFloat64() < oceanbaseconst.MinDataDiskSize.AsApproximateFloat64() {
if r.Spec.OBServerTemplate.Storage.DataStorage.Size.Cmp(resource.MustParse(obcfg.GetConfig().Resource.MinDataDiskSize)) < 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("observer").Child("storage").Child("dataStorage").Child("size"), r.Spec.OBServerTemplate.Storage.DataStorage.Size.String(), "The minimum data storage size of OBCluster is "+oceanbaseconst.MinDataDiskSize.String()))
}
if r.Spec.OBServerTemplate.Storage.RedoLogStorage.Size.AsApproximateFloat64() < oceanbaseconst.MinRedoLogDiskSize.AsApproximateFloat64() {
if r.Spec.OBServerTemplate.Storage.RedoLogStorage.Size.Cmp(resource.MustParse(obcfg.GetConfig().Resource.MinRedoLogDiskSize)) < 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("observer").Child("storage").Child("redoLogStorage").Child("size"), r.Spec.OBServerTemplate.Storage.RedoLogStorage.Size.String(), "The minimum redo log storage size of OBCluster is "+oceanbaseconst.MinRedoLogDiskSize.String()))
}
if r.Spec.OBServerTemplate.Storage.LogStorage.Size.AsApproximateFloat64() < oceanbaseconst.MinLogDiskSize.AsApproximateFloat64() {
if r.Spec.OBServerTemplate.Storage.LogStorage.Size.Cmp(resource.MustParse(obcfg.GetConfig().Resource.MinLogDiskSize)) < 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("observer").Child("storage").Child("logStorage").Child("size"), r.Spec.OBServerTemplate.Storage.LogStorage.Size.String(), "The minimum log storage size of OBCluster is "+oceanbaseconst.MinLogDiskSize.String()))
}

// Validate memory size
if r.Spec.OBServerTemplate.Resource.Memory.AsApproximateFloat64() < oceanbaseconst.MinMemorySize.AsApproximateFloat64() {
if r.Spec.OBServerTemplate.Resource.Memory.Cmp(resource.MustParse(obcfg.GetConfig().Resource.MinMemorySize)) < 0 {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("observer").Child("resource").Child("memory"), r.Spec.OBServerTemplate.Resource.Memory.String(), "The minimum memory size of OBCluster is "+oceanbaseconst.MinMemorySize.String()))
}

Expand Down
33 changes: 33 additions & 0 deletions charts/ob-operator/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
_ _
___ | |__ ___ _ __ ___ _ __ __ _| |_ ___ _ __
/ _ \| '_ \ _____ / _ \| '_ \ / _ \ '__/ _` | __/ _ \| '__|
| (_) | |_) |_____| (_) | |_) | __/ | | (_| | || (_) | |
\___/|_.__/ \___/| .__/ \___|_| \__,_|\__\___/|_|
|_|

Welcome to ob-operator! We are so happy to see you here! Once ob-operator is installed, you can explore OceanBase database on your Kubernetes cluster with ease.

The following steps will guide you through the OceanBase database deployment:

1. Quick Start - Deploy a single-node OceanBase database for testing

https://oceanbase.github.io/ob-operator/docs/manual/quick-start-of-ob-operator

2. Advanced - Create an OceanBase database with customized configurations

https://oceanbase.github.io/ob-operator/docs/manual/ob-operator-user-guide/cluster-management-of-ob-operator/create-cluster

3. Tenants - Create and manage tenants in OceanBase database

https://oceanbase.github.io/ob-operator/docs/manual/ob-operator-user-guide/tenant-management-of-ob-operator/tenant-management-intro

4. High availability - Enable high availability for OceanBase on K8s

https://oceanbase.github.io/ob-operator/docs/manual/ob-operator-user-guide/high-availability/high-availability-intro

5. Get help from the community

Feel free to ask questions or report issues on GitHub: https://github.com/oceanbase/ob-operator/issues
Other ways to get help: https://oceanbase.github.io/ob-operator/#getting-help

For more information, please visit our website: https://oceanbase.github.io/ob-operator
6 changes: 6 additions & 0 deletions charts/oceanbase-cluster/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
___ ____ ____ _ _
/ _ \ ___ ___ __ _ _ __ | __ ) __ _ ___ ___ / ___| |_ _ ___| |_ ___ _ __
| | | |/ __/ _ \/ _` | '_ \| _ \ / _` / __|/ _ \ | | | | | | / __| __/ _ \ '__|
| |_| | (_| __/ (_| | | | | |_) | (_| \__ \ __/ | |___| | |_| \__ \ || __/ |
\___/ \___\___|\__,_|_| |_|____/ \__,_|___/\___| \____|_|\__,_|___/\__\___|_|

Welcome to OceanBase Cluster!

After installing OBCluster chart, you need to wait for the cluster bootstrapped. Bootstrap progress will cost approximately 2~3 minutes which may vary depends on the machine.
Expand Down
4 changes: 2 additions & 2 deletions charts/oceanbase-dashboard/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.2.0
version: 0.2.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.2.0"
appVersion: "0.2.1"
14 changes: 13 additions & 1 deletion charts/oceanbase-dashboard/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
Welcome to OceanBase dashboard
___ ____
/ _ \ ___ ___ __ _ _ __ | __ ) __ _ ___ ___
| | | |/ __/ _ \/ _` | '_ \| _ \ / _` / __|/ _ \
| |_| | (_| __/ (_| | | | | |_) | (_| \__ \ __/
\___/ \___\___|\__,_|_| |_|____/ \__,_|___/\___|

____ _ _ _
| _ \ __ _ ___| |__ | |__ ___ __ _ _ __ __| |
| | | |/ _` / __| '_ \| '_ \ / _ \ / _` | '__/ _` |
| |_| | (_| \__ \ | | | |_) | (_) | (_| | | | (_| |
|____/ \__,_|___/_| |_|_.__/ \___/ \__,_|_| \__,_|

Welcome to OceanBase dashboard!

1. After installing the dashboard chart, you can use `port-forward` to expose the dashboard outside like:

Expand Down
22 changes: 14 additions & 8 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ package main

import (
"context"
"flag"
"os"

//+kubebuilder:scaffold:imports

"github.com/spf13/pflag"
"go.uber.org/zap/zapcore"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand All @@ -33,9 +33,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log/zap"

v1alpha1 "github.com/oceanbase/ob-operator/api/v1alpha1"
obcfg "github.com/oceanbase/ob-operator/internal/config/operator"
"github.com/oceanbase/ob-operator/internal/controller"
"github.com/oceanbase/ob-operator/internal/controller/config"
"github.com/oceanbase/ob-operator/internal/telemetry"
"github.com/oceanbase/ob-operator/pkg/coordinator"
)

var (
Expand Down Expand Up @@ -66,15 +68,15 @@ func main() {
var enableLeaderElection bool
var probeAddr string
var logVerbosity int
flag.StringVar(&namespace, "namespace", "", "The namespace to run oceanbase, default value is empty means all.")
flag.StringVar(&managerNamespace, "manager-namespace", "oceanbase-system", "The namespace to run manager tools.")
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
pflag.StringVar(&namespace, "namespace", "", "The namespace to run oceanbase, default value is empty means all.")
pflag.StringVar(&managerNamespace, "manager-namespace", "oceanbase-system", "The namespace to run manager tools.")
pflag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
pflag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
pflag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
flag.IntVar(&logVerbosity, "log-verbosity", 0, "Log verbosity level, 0 is info, 1 is debug, 2 is trace")
flag.Parse()
pflag.IntVar(&logVerbosity, "log-verbosity", 0, "Log verbosity level, 0 is info, 1 is debug, 2 is trace")
pflag.Parse()

opts := zap.Options{
Development: logVerbosity > 0,
Expand All @@ -86,6 +88,10 @@ func main() {
},
}

cfg := obcfg.GetConfig()
coordinator.SetMaxRetryTimes(cfg.Time.TaskMaxRetryTimes)
coordinator.SetRetryBackoffThreshold(cfg.Time.TaskRetryBackoffThreshold)

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Expand Down
4 changes: 2 additions & 2 deletions docsite/docs/developer/deploy-locally.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ Tips: Perform `minikube dashboard` to open kubernetes dashboard, everything in t
ob-operator depends on `cert-manager` to enable TLS functionalities, so we should install it first.

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.1_release/deploy/cert-manager.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_release/deploy/cert-manager.yaml
```

### 4. Install ob-operator

For robustness, default memory limit of ob-operator container is set to `1Gi` which is too large for us developing locally. We recommend fetching the manifests to local and configure it. wget tool could be useful here, while opening the URL and copying the contents to local file is more straight.

https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.1_release/deploy/operator.yaml
https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_release/deploy/operator.yaml

Search the pattern `/manager`, find the target container, configure the memory limit to `400Mi` and cpu limit to `400m`.

Expand Down
4 changes: 2 additions & 2 deletions docsite/docs/manual/200.quick-start-of-ob-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Run the following command to deploy ob-operator in the Kubernetes cluster:
- Deploy the stable version of ob-operator

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_release/deploy/operator.yaml
```

- Deploy the developing version of ob-operator
Expand Down Expand Up @@ -61,7 +61,7 @@ Perform the following steps to deploy an OceanBase cluster in the Kubernetes clu
Run the following command to deploy an OceanBase cluster in the Kubernetes cluster:

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/example/quickstart/obcluster.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_release/example/quickstart/obcluster.yaml
```

In general, it takes about 2 minutes to create a cluster. Run the following command to check the cluster status:
Expand Down
2 changes: 1 addition & 1 deletion docsite/docs/manual/300.deploy-ob-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ You can deploy ob-operator by using the configuration file for the stable or dev
* Deploy the stable version of ob-operator

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_release/deploy/operator.yaml
```

* Deploy the developing version of ob-operator
Expand Down
2 changes: 1 addition & 1 deletion docsite/docs/manual/400.ob-operator-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you upgrade ob-operator by using configuration files, you only need to reappl
- Deploy the stable version of ob-operator

```shell
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.1.0_release/deploy/operator.yaml
kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_release/deploy/operator.yaml
```

- Deploy the developing version of ob-operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Before you create a tenant, make sure the following conditions are met:

## Create a tenant by using the configuration file

You can create a tenant by using the configuration file of the tenant. For more information about the configuration file, visit [GitHub](https://github.com/oceanbase/ob-operator/blob/2.1.0_release/deploy/tenant.yaml).
You can create a tenant by using the configuration file of the tenant. For more information about the configuration file, visit [GitHub](https://github.com/oceanbase/ob-operator/blob/2.2.0_release/deploy/tenant.yaml).

Run the following command to create a tenant. This command creates an OceanBase Database tenant with custom resources in the current Kubernetes cluster.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This topic describes how to use ob-operator to delete a tenant from a Kubernetes

## Procedure

You can delete the specified tenant resources from the cluster by using the configuration file `tenant.yaml`. For more information about the configuration file, visit [GitHub](https://github.com/oceanbase/ob-operator/blob/2.1.0_release/deploy/tenant.yaml).
You can delete the specified tenant resources from the cluster by using the configuration file `tenant.yaml`. For more information about the configuration file, visit [GitHub](https://github.com/oceanbase/ob-operator/blob/2.2.0_release/deploy/tenant.yaml).

Run the following command to delete a tenant. This command deletes an OceanBase Database tenant with custom resources in the current Kubernetes cluster.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ sidebar_position: 1

ob-operator ensures the high availability of data by using the following features of OceanBase Database.

* Node fault recovery. The distributed architecture of OceanBase Database allows you to restore the service when a minority of nodes fail. By relying on certain network plugins, you can even restore the service from majority nodes failure. For more information, see [Restore service from faults](300.disaster-recovery-of-ob-operator.md).
* Node fault recovery. The distributed architecture of OceanBase Database allows you to restore the service when a minority of nodes fail. By relying on certain network plugins, you can even restore the service from majority nodes failure. For more information, see [Recover from node failure](300.disaster-recovery-of-ob-operator.md).
* Backup and restore of tenant data. The backup and restore feature of OceanBase Database allows you to back up tenant data to different storage media to ensure data safety. For more information, see [Back up a tenant](400.tenant-backup-of-ob-operator.md).
* Primary and standby tenants. OceanBase Database allows you to create a standby tenant for the primary tenant. When a fault occurs to the primary tenant, you can quickly switch your business to the standby tenant to reduce the business interruption. For more information, see [Physical standby database](600.standby-tenant-of-ob-operator.md).
Loading

0 comments on commit 1b9776e

Please sign in to comment.