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 May 20, 2024
2 parents 8830801 + 09e0526 commit 0844c59
Show file tree
Hide file tree
Showing 130 changed files with 7,440 additions and 748 deletions.
1 change: 1 addition & 0 deletions .github/workflows/addlicense.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- master
- "*_release"
paths:
- '**/*.go'

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ on:
pull_request:
branches:
- master
- "*_release"
paths:
- '**/*.go'
push:
branches:
- master
- "*_release"
paths:
- '**/*.go'

env:
GO_VERSION: "1.20"
GO_VERSION: "1.22"

jobs:
build-images:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- master
- "*_release"
paths:
- "ui/**/*"

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- master
- "*_release"
paths:
- '**/*.go'

Expand All @@ -18,13 +19,13 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.22'
check-latest: true
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
version: v1.54
args: --verbose --timeout=10m --max-same-issues=30
only-new-issues: true
skip-cache: true
3 changes: 3 additions & 0 deletions .github/workflows/release-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- 'chart-2.[0-9]+.[0-9]+'
- 'oceanbase-[0-9]+.[0-9]+.[0-9]+.[0-9]+'
- "dashboard-[0-9]+.[0-9]+.[0-9]+"
branches:
- master
- "*_release"

jobs:
release-chart:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include make/*

VERSION ?= 2.2.0
VERSION ?= 2.2.1
# Image URL to use all building/pushing image targets
IMG ?= oceanbase/ob-operator:${VERSION}
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down
10 changes: 5 additions & 5 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ob-operator 是满足 Kubernetes Operator 扩展范式的自动化工具,可
ob-operator 依赖 [cert-manager](https://cert-manager.io/docs/), cert-manager 的安装可以参考对应的[安装文档](https://cert-manager.io/docs/installation/),如果您无法访问官方制品托管在 `quay.io` 镜像站的镜像,可通过下面的指令安装我们转托在 `docker.io` 中的制品:

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

本例子中的 OceanBase 集群存储依赖 [local-path-provisioner](https://github.com/rancher/local-path-provisioner) 提供, 需要提前进行安装并确保其存储目的地有足够大的磁盘空间。如果您计划在生产环境部署,推荐使用其他的存储解决方案。我们在[存储兼容性](#存储兼容性)一节提供了我们测试过的存储兼容性结果。
Expand All @@ -29,7 +29,7 @@ kubectl apply -f https://raw.githubusercontent.com/oceanbase/ob-operator/2.2.0_r
- 稳定版本

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

- 开发版本
Expand All @@ -45,7 +45,7 @@ Helm Chart 将 ob-operator 部署的命名空间进行了参数化,可在安
```shell
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm repo update
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.0
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.1
```

#### 使用 terraform
Expand Down Expand Up @@ -97,7 +97,7 @@ kubectl create secret generic root-password --from-literal=password='root_passwo
通过以下命令即可在 K8s 集群中部署 OceanBase:

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

一般初始化集群需要 2 分钟左右的时间,执行以下命令,查询集群状态,当集群状态变成 running 之后表示集群创建和初始化成功:
Expand Down Expand Up @@ -126,7 +126,7 @@ mysql -h{POD_IP} -P2881 -uroot -proot_password oceanbase -A -c

### OceanBase Dashboard

我们很高兴向用户推出创新的 OceanBase Kubernetes Dashboard,这是一款旨在改善用户在 Kubernetes 上管理和监控 OceanBase 集群体验的先进工具。欢迎各位用户使用和反馈,同时我们也在积极开发新功能以增强未来的更新。
我们很高兴向用户推出创新的 OceanBase Kubernetes Dashboard,这是一款旨在改善用户在 Kubernetes 上管理和监控 OceanBase 集群体验的先进工具。欢迎各位用户使用和反馈,同时我们也在积极开发新功能以增强未来的更新。[快速上手](https://oceanbase.github.io/ob-operator/zh-Hans/docs/dashboard/quickstart)文档能帮助您快速了解 OceanBase 的功能和使用方法。

安装 OceanBase Dashboard 非常简单, 只需要执行如下命令。

Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ob-operator relies on [cert-manager](https://cert-manager.io/docs/) for certific
If you have trouble accessing `quay.io` image registry, our mirrored cert-manager manifests can be applied through following command:

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

Storage of OceanBase cluster in this example relies on [local-path-provisioner](https://github.com/rancher/local-path-provisioner), which should be installed beforehand. You should confirm that there is enough disk space in storage destination of local-path-provisioner. If you decide to deploy OceanBase cluster in production environment, it is recommended to use other storage solutions. We have provided a compatible table for storage solutions that we tested in section [Storage Compatibility](#storage-compatibility).
Expand All @@ -30,7 +30,7 @@ You can deploy ob-operator in a Kubernetes cluster by executing the following co
- Stable

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

- Development
Expand All @@ -46,7 +46,7 @@ Helm Chart parameterizes the namespace in which ob-operator is deployed, allowin
```shell
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
helm repo update
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.0
helm install ob-operator ob-operator/ob-operator --namespace=oceanbase-system --create-namespace --version=2.2.1
```

#### Using terraform
Expand Down Expand Up @@ -98,7 +98,7 @@ kubectl create secret generic root-password --from-literal=password='root_passwo
You can deploy OceanBase in a Kubernetes cluster by executing the following command:

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

It generally takes around 2 minutes to bootstrap a cluster. Execute the following command to check the status of the cluster. Once the cluster status changes to "running," it indicates that the cluster has been successfully created and bootstrapped:
Expand Down Expand Up @@ -127,9 +127,9 @@ mysql -h{POD_IP} -P2881 -uroot -proot_password oceanbase -A -c

### OceanBase Dashboard

We are excited to unveil our innovative OceanBase Kubernetes Dashboard, a pioneering tool designed to enhance your experience with managing and monitoring OceanBase clusters on Kubernetes. We are proud to offer this amazing tool to our users and will actively work on new features and enhancements for future updates.
We are excited to unveil our innovative OceanBase Kubernetes Dashboard, a pioneering tool designed to enhance your experience with managing and monitoring OceanBase clusters on Kubernetes. We are proud to offer this amazing tool to our users and will actively work on new features and enhancements for future updates. [Quick Start](https://oceanbase.github.io/ob-operator/docs/dashboard/quickstart) guide is available to help you get started with OceanBase Dashboard.

Deploy OceanBase Dashboard is pretty simple, just run the following commands
Deploy OceanBase Dashboard is pretty simple, just run the following commands:

```
helm repo add ob-operator https://oceanbase.github.io/ob-operator/
Expand All @@ -145,15 +145,16 @@ After OceanBase Dashboard is successfully installed, a default user admin is cre
echo $(kubectl get -n default secret oceanbase-dashboard-user-credentials -o jsonpath='{.data.admin}' | base64 -d)
```

A service of type NodePort is created by default, you can check the address and port and open it in browser
A service of type NodePort is created by default, you can check the address and port and open it in browser:

```
kubectl get svc oceanbase-dashboard-oceanbase-dashboard
```

![oceanbase-dashboard-service](./docsite/static/img/oceanbase-dashboard-service.jpg)

Login with admin user and password
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)

Expand Down
4 changes: 2 additions & 2 deletions charts/ob-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
appVersion: 2.2.0
appVersion: 2.2.1
description: A Helm chart for OB-Operator
name: ob-operator
type: application
version: 2.2.0
version: 2.2.1
2 changes: 1 addition & 1 deletion charts/ob-operator/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12720,7 +12720,7 @@ spec:
- --log-verbosity=0
command:
- /manager
image: oceanbase/ob-operator:2.2.0
image: oceanbase/ob-operator:2.2.1
livenessProbe:
httpGet:
path: /healthz
Expand Down
4 changes: 2 additions & 2 deletions charts/oceanbase-cluster/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: 4.3.0-sp.1-100000242024032211
version: 4.2.1-sp.6-106000012024042515

# 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: "4.3.0.1-100000242024032211"
appVersion: "4.2.1.6-106000012024042515"
8 changes: 8 additions & 0 deletions charts/oceanbase-dashboard/templates/prom-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ data:
- source_labels: [__meta_kubernetes_pod_container_name, __meta_kubernetes_pod_container_port_name, __meta_kubernetes_pod_container_port_number, __meta_kubernetes_pod_container_port_protocol]
regex: obagent;http;8088;TCP
action: keep
- job_name: 'obproxy'
kubernetes_sd_configs:
- role: endpoints
metrics_path: '/metrics'
relabel_configs:
- source_labels: [__meta_kubernetes_pod_container_name, __meta_kubernetes_pod_container_port_name, __meta_kubernetes_pod_container_port_number, __meta_kubernetes_pod_container_port_protocol]
regex: obproxy;prometheus;2884;TCP
action: keep
6 changes: 5 additions & 1 deletion cmd/dashboard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ func init() {
if logLevel == "" {
logLevel = "info"
}
logFile := os.Getenv("LOG_FILE")
if logFile == "" {
logFile = "log/oceanbase-dashboard.log"
}
log.InitLogger(
log.LoggerConfig{
Level: logLevel,
Filename: "log/oceanbase-dashboard.log",
Filename: logFile,
MaxSize: 256,
MaxAge: 7,
MaxBackups: 5,
Expand Down
3 changes: 3 additions & 0 deletions cmd/operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

v1alpha1 "github.com/oceanbase/ob-operator/api/v1alpha1"
obcfg "github.com/oceanbase/ob-operator/internal/config/operator"
oceanbaseconst "github.com/oceanbase/ob-operator/internal/const/oceanbase"
"github.com/oceanbase/ob-operator/internal/controller"
"github.com/oceanbase/ob-operator/internal/controller/config"
"github.com/oceanbase/ob-operator/internal/telemetry"
Expand Down Expand Up @@ -91,6 +92,8 @@ func main() {
cfg := obcfg.GetConfig()
coordinator.SetMaxRetryTimes(cfg.Time.TaskMaxRetryTimes)
coordinator.SetRetryBackoffThreshold(cfg.Time.TaskRetryBackoffThreshold)
coordinator.SetIgnoreDeletionAnnotation(oceanbaseconst.AnnotationsIgnoreDeletion)
coordinator.SetPausedAnnotation(oceanbaseconst.AnnotationsPauseReconciling)

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

Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: oceanbase/ob-operator
newTag: 2.2.0
newTag: 2.2.1
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12733,7 +12733,7 @@ spec:
- --log-verbosity=0
command:
- /manager
image: oceanbase/ob-operator:2.2.0
image: oceanbase/ob-operator:2.2.1
livenessProbe:
httpGet:
path: /healthz
Expand Down
41 changes: 37 additions & 4 deletions distribution/obproxy/start.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
#!/bin/bash


if [ -z $APP_NAME ]; then
echo "env variable APP_NAME is required"
exit 1
fi

if [ -z $PROXYRO_PASSWORD_HASH ]; then
PROXYRO_PASSWORD_HASH=`echo -n "$PROXYRO_PASSWORD" | sha1sum | awk '{print $1}'`
PROXYRO_PASSWORD_HASH=$(echo -n "$PROXYRO_PASSWORD" | sha1sum | awk '{print $1}')
fi

if [ -z $PROSYSYS_PASSWORD_HASH ]; then
PROXYSYS_PASSWORD_HASH=$(echo -n "$PROXYSYS_PASSWORD" | sha1sum | awk '{print $1}')
fi

opts="obproxy_sys_password=$PROXYSYS_PASSWORD_HASH"

function concat_opts {
if [ -z "$1" ]; then
echo $2
elif [ -z "$2" ]; then
echo $1
else
echo "$1,$2"
fi
}

[ -z "$ODP_PROMETHEUS_SYNC_INTERVAL" ] && opts=$(concat_opts $opts "prometheus_sync_interval=1s")
[ -z "$ODP_ENABLE_METADB_USED" ] && opts=$(concat_opts $opts "enable_metadb_used=false")
[ -z "$ODP_SKIP_PROXY_SYS_PRIVATE_CHECK" ] && opts=$(concat_opts $opts "skip_proxy_sys_private_check=true")
[ -z "$ODP_LOG_DIR_SIZE_THRESHOLD" ] && opts=$(concat_opts $opts "log_dir_size_threshold=10G")
[ -z "$ODP_ENABLE_PROXY_SCRAMBLE" ] && opts=$(concat_opts $opts "enable_proxy_scramble=true")
[ -z "$ODP_ENABLE_STRICT_KERNEL_RELEASE" ] && opts=$(concat_opts $opts "enable_strict_kernel_release=false")

while IFS='=' read -r key value; do
# If the key has prefix "ODP_" then add it to the opts
if [[ $key == ODP_* ]]; then
# Remove the prefix "ODP_" from the key and transform to lower case
key=$(echo $key | sed 's/^ODP_//g' | tr '[:upper:]' '[:lower:]')
opts=$(concat_opts $opts "$(printf "%s=\"%s\"" "$key" "$value")")
fi
done < <(env)

echo "$opts"

if [ ! -z $CONFIG_URL ]; then
echo "use config server"
cd /home/admin/obproxy && /home/admin/obproxy/bin/obproxy -p 2883 -l 2884 -n ${APP_NAME} -o observer_sys_password=${PROXYRO_PASSWORD_HASH},obproxy_config_server_url="${CONFIG_URL}",prometheus_sync_interval=1,enable_metadb_used=false,skip_proxy_sys_private_check=true,log_dir_size_threshold=10G,enable_proxy_scramble=true,enable_strict_kernel_release=false --nodaemon
cd /home/admin/obproxy && /home/admin/obproxy/bin/obproxy -p 2883 -l 2884 -n ${APP_NAME} -o observer_sys_password=${PROXYRO_PASSWORD_HASH},obproxy_config_server_url="${CONFIG_URL}",$opts --nodaemon
elif [ ! -z $RS_LIST ]; then
echo "use rslist"
cd /home/admin/obproxy && /home/admin/obproxy/bin/obproxy -p 2883 -l 2884 -n ${APP_NAME} -c ${OB_CLUSTER} -r "${RS_LIST}" -o observer_sys_password=${PROXYRO_PASSWORD_HASH},prometheus_sync_interval=1,enable_metadb_used=false,skip_proxy_sys_private_check=true,log_dir_size_threshold=10G,enable_proxy_scramble=true,enable_strict_kernel_release=false --nodaemon
cd /home/admin/obproxy && /home/admin/obproxy/bin/obproxy -p 2883 -l 2884 -n ${APP_NAME} -c ${OB_CLUSTER} -r "${RS_LIST}" -o observer_sys_password=${PROXYRO_PASSWORD_HASH},$opts --nodaemon
else
echo "no config server or rs list"
exit 1
Expand Down
24 changes: 24 additions & 0 deletions distribution/oceanbase-todo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM node:18-alpine as builder-fe
WORKDIR /workspace
COPY ./ui .
ENV NODE_OPTIONS=--max_old_space_size=5120
RUN yarn
RUN yarn build

FROM golang:1.21.5 as builder-be
ARG GOPROXY=https://goproxy.io,direct
ARG GOSUMDB=sum.golang.org
ARG COMMIT_HASH=unknown
WORKDIR /workspace
COPY . .
RUN CGO_ENABLED=0 go build -o bin/todo ./main.go

# start build docker image
FROM alpine:3.17
WORKDIR /bin
COPY --from=builder-be /workspace/bin/todo /bin/todo
COPY --from=builder-fe /workspace/dist /bin/ui/dist
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
USER root

ENTRYPOINT ["/bin/todo"]
30 changes: 30 additions & 0 deletions distribution/oceanbase-todo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# OceanBase Todo List

OceanBase Todo List, an extremely simple web application that shows how to use OceanBase as backend database. Initially, it was created for learning about ob-operator referenced in [a real-world example](https://oceanbase.github.io/ob-operator/docs/manual/appendix/example).

## Features

- Connect the database and execute the database migration (Create tables)
- Create initial todo list data in the database (Steps for learning about ob-operator)
- Provide RESTful API for frontend app to interact with the database
- Provide a simple frontend app to show the todo list
- Show all todo list
- Add a new todo item
- Update a todo item (title and description)
- Done/Undone a todo item
- Delete a todo item

## How to use

```bash
# Build frontend app first
cd ui
yarn # or npm install
yarn build # or npm run build

# Run backend app
cd ..
go mod tidy
go build -o oceanbase-todo main.go
DB_HOST=xxx DB_PORT=xxx DB_USER=xxx DB_PASSWORD=xxx DB_DATABASE=xxx ./oceanbase-todo
```
Loading

0 comments on commit 0844c59

Please sign in to comment.