Skip to content

Commit

Permalink
Merge branch 'master' into fix_job
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-sun-star committed Jan 14, 2025
2 parents 47f3cd1 + 96be8d7 commit d44bf1d
Show file tree
Hide file tree
Showing 25 changed files with 403 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: generate bindata
run: make dashboard-bindata-gen dashboard-doc-gen cli-bindata-gen
run: make dashboard-bindata-gen dashboard-doc-gen

- name: go mod vendor
run: go mod vendor
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ jobs:
go-version: ${{ env.GO_VERSION }}

- name: generate bindata
run: make dashboard-bindata-gen cli-bindata-gen dashboard-doc-gen
run: make dashboard-bindata-gen dashboard-doc-gen

- name: go mod vendor
run: go mod vendor

- name: install tools
run: make tools

- name: test webhooks
run: make test-webhooks
- name: run test
run: make test

4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
cache: true

- name: generate bindata
run: make dashboard-bindata-gen dashboard-doc-gen cli-bindata-gen
run: make dashboard-bindata-gen dashboard-doc-gen

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --verbose --timeout=10m --max-same-issues=30
only-new-issues: true
skip-cache: true
skip-cache: true
2 changes: 1 addition & 1 deletion .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
go-version: ${{ env.GO_VERSION }} # The Go version to download (if necessary) and use.

- name: generate bindata
run: make dashboard-bindata-gen dashboard-doc-gen cli-bindata-gen
run: make dashboard-bindata-gen dashboard-doc-gen

- name: go mod vendor
run: go mod vendor
Expand Down
26 changes: 26 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,32 @@ terraform init
terraform apply
```

#### 使用命令行工具 (okctl)

您还可以使用命令行工具 okctl 来部署 ob-operator,okctl 是可以用来部署 ob-operator 和管理 OceanBase 集群的方便的工具。

你可以通过 releases 页面下载 CLI 工具,或者通过以下命令下载:

```shell
# 使用代理
curl -sL https://gh.wewell.org/https://github.com/oceanbase/ob-operator/blob/master/scripts/install-okctl.sh | bash -s -- --proxy

# 不使用代理
curl -sL https://raw.githubusercontent.com/oceanbase/ob-operator/master/scripts/install-okctl.sh | bash
```

下载完成之后,可以通过以下命令来部署 ob-operator,

```shell
./okctl install
```

另外,我们推荐将 CLI 工具添加到 PATH 环境变量中,

```shell
mv ./okctl /usr/local/bin
```

#### 验证部署结果

安装完成之后,可以使用以下命令验证 ob-operator 是否部署成功:
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ terraform init
terraform apply
```

#### Using CLI tool (okctl)

You can also use the CLI tool, okctl, to deploy ob-operator, it is a convenient way to deploy ob-operator and manage OceanBase clusters.

You can download okctl from the releases page or through the following command:

```shell
curl -sL https://raw.githubusercontent.com/oceanbase/ob-operator/master/scripts/install-okctl.sh | bash
```

After downloading okctl, you can deploy ob-operator by executing the following command:

```shell
./okctl install
```

By the way, we recommend you to add okctl to your PATH environment variable like this:

```shell
mv ./okctl /usr/local/bin
```

#### Verify deployment

After deployment/installation is complete, you can use the following command to verify if ob-operator is deployed successfully:
Expand Down
5 changes: 4 additions & 1 deletion api/v1alpha1/obcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (r *OBCluster) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-oceanbase-oceanbase-com-v1alpha1-obcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=oceanbase.oceanbase.com,resources=obclusters,verbs=create;update,versions=v1alpha1,name=vobcluster.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/validate-oceanbase-oceanbase-com-v1alpha1-obcluster,mutating=false,failurePolicy=fail,sideEffects=None,groups=oceanbase.oceanbase.com,resources=obclusters,verbs=create;update;delete,versions=v1alpha1,name=vobcluster.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &OBCluster{}

Expand Down Expand Up @@ -267,6 +267,9 @@ func (r *OBCluster) ValidateUpdate(old runtime.Object) (admission.Warnings, erro

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *OBCluster) ValidateDelete() (admission.Warnings, error) {
if r.Annotations[oceanbaseconst.AnnotationsIgnoreDeletion] == "true" {
return nil, apierrors.NewBadRequest("OBCluster " + r.Name + " is protected from deletion by annotation " + oceanbaseconst.AnnotationsIgnoreDeletion)
}
return nil, nil
}

Expand Down
6 changes: 4 additions & 2 deletions api/v1alpha1/obtenant_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (r *OBTenant) Default() {
}

// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
//+kubebuilder:webhook:path=/validate-oceanbase-oceanbase-com-v1alpha1-obtenant,mutating=false,failurePolicy=fail,sideEffects=None,groups=oceanbase.oceanbase.com,resources=obtenants,verbs=create;update,versions=v1alpha1,name=vobtenant.kb.io,admissionReviewVersions=v1
//+kubebuilder:webhook:path=/validate-oceanbase-oceanbase-com-v1alpha1-obtenant,mutating=false,failurePolicy=fail,sideEffects=None,groups=oceanbase.oceanbase.com,resources=obtenants,verbs=create;update;delete,versions=v1alpha1,name=vobtenant.kb.io,admissionReviewVersions=v1

var _ webhook.Validator = &OBTenant{}

Expand Down Expand Up @@ -311,7 +311,9 @@ func (r *OBTenant) validateMutation() error {

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
func (r *OBTenant) ValidateDelete() (admission.Warnings, error) {
// TODO(user): fill in your validation logic upon object deletion.
if r.Annotations[oceanbaseconst.AnnotationsIgnoreDeletion] == "true" {
return nil, apierrors.NewBadRequest("OBTenant " + r.Name + " is protected from deletion by annotation " + oceanbaseconst.AnnotationsIgnoreDeletion)
}
return nil, nil
}

Expand Down
18 changes: 18 additions & 0 deletions api/v1alpha1/obtenant_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

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

var _ = Describe("Test OBTenant Webhook", Label("webhook"), Serial, func() {
Expand Down Expand Up @@ -165,4 +166,21 @@ var _ = Describe("Test OBTenant Webhook", Label("webhook"), Serial, func() {

Expect(k8sClient.Create(ctx, t2)).ShouldNot(Succeed())
})

It("Check validating delete webhook", func() {
clusterName := clusterName + "-test-deletion-validate"
cluster := newOBCluster(clusterName, 1, 1)
cluster.Annotations = map[string]string{
oceanbaseconst.AnnotationsIgnoreDeletion: "true",
}
Expect(k8sClient.Create(ctx, cluster)).Should(Succeed())
Expect(k8sClient.Delete(ctx, cluster)).ShouldNot(Succeed())
tenantName := tenantName + "-test-deletion-validate"
t := newOBTenant(tenantName, clusterName)
t.Annotations = map[string]string{
oceanbaseconst.AnnotationsIgnoreDeletion: "true",
}
Expect(k8sClient.Create(ctx, t)).Should(Succeed())
Expect(k8sClient.Delete(ctx, t)).ShouldNot(Succeed())
})
})
2 changes: 2 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ webhooks:
operations:
- CREATE
- UPDATE
- DELETE
resources:
- obclusters
sideEffects: None
Expand Down Expand Up @@ -247,6 +248,7 @@ webhooks:
operations:
- CREATE
- UPDATE
- DELETE
resources:
- obtenants
sideEffects: None
Expand Down
26 changes: 26 additions & 0 deletions docsite/i18n/zh-Hans/docusaurus-plugin-content-pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,32 @@ terraform init
terraform apply
```

#### 使用命令行工具 (okctl)

您还可以使用命令行工具 okctl 来部署 ob-operator,okctl 是可以用来部署 ob-operator 和管理 OceanBase 集群的方便的工具。

你可以通过 releases 页面下载 CLI 工具,或者通过以下命令下载:

```shell
# 使用代理
curl -sL https://gh.wewell.org/https://github.com/oceanbase/ob-operator/blob/master/scripts/install-okctl.sh | bash -s -- --proxy

# 不使用代理
curl -sL https://raw.githubusercontent.com/oceanbase/ob-operator/master/scripts/install-okctl.sh | bash
```

下载完成之后,可以通过以下命令来部署 ob-operator,

```shell
./okctl install
```

另外,我们推荐将 CLI 工具添加到 PATH 环境变量中,

```shell
mv ./okctl /usr/local/bin
```

#### 验证部署结果

安装完成之后,可以使用以下命令验证 ob-operator 是否部署成功:
Expand Down
22 changes: 22 additions & 0 deletions docsite/src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ terraform init
terraform apply
```

#### Using CLI tool (okctl)

You can also use the CLI tool, okctl, to deploy ob-operator, it is a convenient way to deploy ob-operator and manage OceanBase clusters.

You can download okctl from the releases page or through the following command:

```shell
curl -sL https://raw.githubusercontent.com/oceanbase/ob-operator/master/scripts/install-okctl.sh | bash
```

After downloading okctl, you can deploy ob-operator by executing the following command:

```shell
./okctl install
```

By the way, we recommend you to add okctl to your PATH environment variable like this:

```shell
mv ./okctl /usr/local/bin
```

#### Verify deployment

After deployment/installation is complete, you can use the following command to verify if ob-operator is deployed successfully:
Expand Down
7 changes: 3 additions & 4 deletions internal/cli/cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package install
import (
"github.com/spf13/cobra"

"github.com/oceanbase/ob-operator/internal/cli/config"
"github.com/oceanbase/ob-operator/internal/cli/install"
"github.com/oceanbase/ob-operator/internal/cli/utils"
)

var componentList = []string{"ob-operator", "ob-dashboard", "local-path-provisioner", "cert-manager", "local-path-provisioner-dev", "ob-operator-dev"}

// NewCmd install the ob-operator and other components
func NewCmd() *cobra.Command {
o := install.NewInstallOptions()
Expand All @@ -34,12 +33,12 @@ func NewCmd() *cobra.Command {
Currently support:
- ob-operator: A Kubernetes operator that simplifies the deployment and management of OceanBase cluster and related resources on Kubernetes, support stable and develop version.
- ob-dashboard: A web application that provides resource management capabilities.
- local-path-provisioner: Provides a way for the Kubernetes users to utilize the local storage in each node, Storage of OceanBase cluster relies on it, which should be installed beforehand, support stable and develop version.
- local-path-provisioner: Provides a way for the Kubernetes users to utilize the local storage in each node, Storage of OceanBase cluster relies on it, which should be installed beforehand.
- cert-manager: Creates TLS certificates for workloads in Kubernetes and renews the certificates before they expire, ob-operator relies on it for certificate management, which should be installed beforehand.
if not specified, install ob-operator and ob-dashboard by default, and cert-manager if it is not found in cluster.`,
PreRunE: o.Parse,
ValidArgs: componentList,
ValidArgs: config.ComponentList,
Args: cobra.MatchAll(cobra.MaximumNArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
Expand Down
7 changes: 3 additions & 4 deletions internal/cli/cmd/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package update
import (
"github.com/spf13/cobra"

"github.com/oceanbase/ob-operator/internal/cli/config"
"github.com/oceanbase/ob-operator/internal/cli/update"
"github.com/oceanbase/ob-operator/internal/cli/utils"
)

var componentList = []string{"ob-operator", "ob-dashboard", "local-path-provisioner", "cert-manager"}

// NewCmd update the ob-operator and other components
func NewCmd() *cobra.Command {
o := update.NewUpdateOptions()
Expand All @@ -34,12 +33,12 @@ func NewCmd() *cobra.Command {
Currently support:
- ob-operator: A Kubernetes operator that simplifies the deployment and management of OceanBase cluster and related resources on Kubernetes, support stable and develop version.
- ob-dashboard: A web application that provides resource management capabilities.
- local-path-provisioner: Provides a way for the Kubernetes users to utilize the local storage in each node, Storage of OceanBase cluster relies on it, which should be installed beforehand, support stable and develop version.
- local-path-provisioner: Provides a way for the Kubernetes users to utilize the local storage in each node, Storage of OceanBase cluster relies on it, which should be installed beforehand.
- cert-manager: Creates TLS certificates for workloads in Kubernetes and renews the certificates before they expire, ob-operator relies on it for certificate management, which should be installed beforehand.
if not specified, update ob-operator and ob-dashboard by default`,
PreRunE: o.Parse,
ValidArgs: componentList,
ValidArgs: config.ComponentUpdateList,
DisableFlagsInUseLine: true,
Args: cobra.MatchAll(cobra.MaximumNArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
Expand Down
Loading

0 comments on commit d44bf1d

Please sign in to comment.