You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by mi...@apache.org on 2023/05/30 10:15:18 UTC
[shardingsphere-on-cloud] branch main updated: feat(helm): update operator charts support StorageNode
This is an automated email from the ASF dual-hosted git repository.
miaoliyao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git
The following commit(s) were added to refs/heads/main by this push:
new 71fa302 feat(helm): update operator charts support StorageNode
new 8d6b1dd Merge pull request #378 from Xu-Wentao/storage-node
71fa302 is described below
commit 71fa3027f19fc27c042802455d634baefcc1f777
Author: xuwentao <cu...@yahoo.com>
AuthorDate: Fri May 26 15:25:51 2023 +0800
feat(helm): update operator charts support StorageNode
---
.../shardingsphere.apache.org_storagenodes.yaml | 189 +++++++++++++++++++++
.../templates/operator_deployment.yaml | 8 +-
.../templates/operator_rbac.yaml | 125 +++++++++++---
.../values.yaml | 19 ++-
docs/shardingsphere-operator.md | 2 +-
...ngsphereproxy-storagenode-aws-rds-instance.yaml | 2 +
shardingsphere-operator/build/Dockerfile | 8 +-
.../cmd/shardingsphere-operator/manager/manager.go | 2 +-
.../cmd/shardingsphere-operator/manager/option.go | 2 +-
shardingsphere-operator/go.mod | 2 +-
shardingsphere-operator/go.sum | 2 +
.../pkg/controllers/compute_node_controller.go | 7 +
.../pkg/controllers/proxy_controller.go | 20 ++-
.../pkg/controllers/proxyconfig_controller.go | 8 +-
.../controllers/shardingsphere_chaos_controller.go | 4 +
.../pkg/controllers/storage_node_controller.go | 5 +
shardingsphere-operator/pkg/metrics/metrics.go | 2 +-
17 files changed, 362 insertions(+), 45 deletions(-)
diff --git a/charts/apache-shardingsphere-operator-charts/crds/shardingsphere.apache.org_storagenodes.yaml b/charts/apache-shardingsphere-operator-charts/crds/shardingsphere.apache.org_storagenodes.yaml
new file mode 100644
index 0000000..e1209a8
--- /dev/null
+++ b/charts/apache-shardingsphere-operator-charts/crds/shardingsphere.apache.org_storagenodes.yaml
@@ -0,0 +1,189 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+---
+apiVersion: apiextensions.k8s.io/v1
+kind: CustomResourceDefinition
+metadata:
+ annotations:
+ controller-gen.kubebuilder.io/version: v0.9.0
+ creationTimestamp: null
+ name: storagenodes.shardingsphere.apache.org
+spec:
+ group: shardingsphere.apache.org
+ names:
+ kind: StorageNode
+ listKind: StorageNodeList
+ plural: storagenodes
+ singular: storagenode
+ scope: Namespaced
+ versions:
+ - additionalPrinterColumns:
+ - jsonPath: .metadata.creationTimestamp
+ name: Age
+ type: date
+ - jsonPath: .status.phase
+ name: Phase
+ type: string
+ - jsonPath: .status.Cluster.Status
+ name: ClusterStatus
+ type: string
+ - jsonPath: .status.Registered
+ name: Registered
+ priority: 1
+ type: boolean
+ name: v1alpha1
+ schema:
+ openAPIV3Schema:
+ description: StorageNode is the Schema for the ShardingSphere storage unit
+ properties:
+ apiVersion:
+ description: 'APIVersion defines the versioned schema of this representation
+ of an object. Servers should convert recognized schemas to the latest
+ internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
+ type: string
+ kind:
+ description: 'Kind is a string value representing the REST resource this
+ object represents. Servers may infer this from the endpoint the client
+ submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
+ type: string
+ metadata:
+ type: object
+ spec:
+ description: StorageNodeSpec defines the desired state of a set of storage
+ units
+ properties:
+ databaseClassName:
+ type: string
+ schema:
+ type: string
+ required:
+ - databaseClassName
+ type: object
+ status:
+ description: StorageNodeStatus defines the actual state of a set of storage
+ units
+ properties:
+ cluster:
+ description: Cluster contains the current status of the StorageNode
+ cluster
+ properties:
+ primaryEndpoint:
+ properties:
+ address:
+ type: string
+ port:
+ format: int32
+ type: integer
+ required:
+ - address
+ - port
+ type: object
+ properties:
+ additionalProperties:
+ type: string
+ type: object
+ readerEndpoints:
+ items:
+ properties:
+ address:
+ type: string
+ port:
+ format: int32
+ type: integer
+ required:
+ - address
+ - port
+ type: object
+ type: array
+ status:
+ type: string
+ required:
+ - primaryEndpoint
+ - status
+ type: object
+ conditions:
+ description: Conditions The conditions array, the reason and message
+ fields
+ items:
+ description: StorageNodeCondition contains details for the current
+ condition of this StorageNode.
+ properties:
+ lastUpdateTime:
+ format: date-time
+ type: string
+ message:
+ type: string
+ reason:
+ type: string
+ status:
+ type: string
+ type:
+ type: string
+ required:
+ - message
+ - reason
+ - status
+ - type
+ type: object
+ type: array
+ instances:
+ description: Instances contains the current status of the StorageNode
+ instance
+ items:
+ properties:
+ primaryEndpoint:
+ properties:
+ address:
+ type: string
+ port:
+ format: int32
+ type: integer
+ required:
+ - address
+ - port
+ type: object
+ properties:
+ additionalProperties:
+ type: string
+ type: object
+ status:
+ type: string
+ required:
+ - primaryEndpoint
+ - status
+ type: object
+ type: array
+ observedGeneration:
+ description: The generation observed by the StorageNode controller.
+ format: int64
+ type: integer
+ phase:
+ description: 'Phase is a brief summary of the StorageNode life cycle
+ There are two possible phase values: Ready: StorageNode can already
+ provide external services NotReady: StorageNode cannot provide external
+ services'
+ type: string
+ registered:
+ description: Registered indicates whether the StorageNode has been
+ registered to shardingsphere
+ type: boolean
+ type: object
+ type: object
+ served: true
+ storage: true
+ subresources:
+ status: {}
diff --git a/charts/apache-shardingsphere-operator-charts/templates/operator_deployment.yaml b/charts/apache-shardingsphere-operator-charts/templates/operator_deployment.yaml
index 439c3dc..f4d4f96 100644
--- a/charts/apache-shardingsphere-operator-charts/templates/operator_deployment.yaml
+++ b/charts/apache-shardingsphere-operator-charts/templates/operator_deployment.yaml
@@ -40,11 +40,17 @@ spec:
spec:
containers:
- args:
+ - --metrics-bind-address=:{{ .Values.operator.metrics.metricsBindAddress }}
- --health-probe-bind-address=:{{ .Values.operator.health.healthProbePort }}
- --leader-elect
{{- if eq .Values.operator.featureGates.computeNode true }}
- - --feature-gates=ComputeNode={{ .Values.operator.featureGates.computeNode }}
+ - --feature-gates=ComputeNode=true{{- if eq .Values.operator.featureGates.storageNode true }},StorageNode=true{{- end }}
{{- end }}
+ {{- if eq .Values.operator.storageNodeProviders.aws.enabled true }}
+ - --aws-region={{ .Values.operator.storageNodeProviders.aws.region }}
+ - --aws-access-key-id={{ .Values.operator.storageNodeProviders.aws.accessKeyId }}
+ - --aws-secret-access-key={{ .Values.operator.storageNodeProviders.aws.secretAccessKey }}
+ {{- end }}
ports:
- name: healthcheck
containerPort: {{ .Values.operator.health.healthProbePort }}
diff --git a/charts/apache-shardingsphere-operator-charts/templates/operator_rbac.yaml b/charts/apache-shardingsphere-operator-charts/templates/operator_rbac.yaml
index c792fcd..c631733 100644
--- a/charts/apache-shardingsphere-operator-charts/templates/operator_rbac.yaml
+++ b/charts/apache-shardingsphere-operator-charts/templates/operator_rbac.yaml
@@ -69,7 +69,54 @@ rules:
- ""
resources:
- configmaps
- - services
+ verbs:
+ - create
+ - delete
+ - get
+ - list
+ - patch
+ - update
+ - watch
+ - apiGroups:
+ - apps
+ resources:
+ - deployments
+ verbs:
+ - create
+ - delete
+ - get
+ - list
+ - patch
+ - update
+ - watch
+ - apiGroups:
+ - apps
+ resources:
+ - deployments/status
+ verbs:
+ - get
+ - apiGroups:
+ - autoscaling
+ resources:
+ - horizontalpodautoscalers
+ verbs:
+ - create
+ - delete
+ - get
+ - list
+ - patch
+ - update
+ - watch
+ - apiGroups:
+ - autoscaling
+ resources:
+ - horizontalpodautoscalers/status
+ verbs:
+ - get
+ - apiGroups:
+ - ""
+ resources:
+ - configmaps
verbs:
- create
- delete
@@ -85,6 +132,7 @@ rules:
verbs:
- create
- delete
+ - deletecollection
- get
- list
- patch
@@ -96,19 +144,36 @@ rules:
- pods/status
verbs:
- get
+ - apiGroups:
+ - ""
+ resources:
+ - services
+ verbs:
+ - create
+ - delete
+ - get
- list
+ - patch
+ - update
- watch
- apiGroups:
- - apps
+ - ""
resources:
- - deployment/status
+ - services/status
+ verbs:
+ - get
+ - apiGroups:
+ - core.database-mesh.io
+ resources:
+ - databaseclasses
verbs:
- get
- list
+ - watch
- apiGroups:
- - apps
+ - shardingsphere.apache.org
resources:
- - deployments
+ - computenodes
verbs:
- create
- delete
@@ -120,7 +185,15 @@ rules:
- apiGroups:
- shardingsphere.apache.org
resources:
- - shardingsphereproxies
+ - computenodes/status
+ verbs:
+ - get
+ - patch
+ - update
+ - apiGroups:
+ - shardingsphere.apache.org
+ resources:
+ - shardingspherechaos
verbs:
- create
- delete
@@ -132,27 +205,35 @@ rules:
- apiGroups:
- shardingsphere.apache.org
resources:
- - shardingsphereproxies/finalizers
+ - shardingspherechaos/finalizers
verbs:
- update
- apiGroups:
- shardingsphere.apache.org
resources:
- - computenodes
+ - shardingspherechaos/status
verbs:
- - "*"
+ - get
+ - patch
+ - update
- apiGroups:
- shardingsphere.apache.org
resources:
- - computenodes/finalizers
+ - shardingsphereproxies
verbs:
- - "*"
+ - create
+ - delete
+ - get
+ - list
+ - patch
+ - update
+ - watch
- apiGroups:
- shardingsphere.apache.org
resources:
- - computenodes/status
+ - shardingsphereproxies/finalizers
verbs:
- - "*"
+ - update
- apiGroups:
- shardingsphere.apache.org
resources:
@@ -188,9 +269,9 @@ rules:
- patch
- update
- apiGroups:
- - autoscaling
+ - shardingsphere.apache.org
resources:
- - horizontalpodautoscalers
+ - storagenodes
verbs:
- create
- delete
@@ -200,17 +281,19 @@ rules:
- update
- watch
- apiGroups:
- - authentication.k8s.io
+ - shardingsphere.apache.org
resources:
- - tokenreviews
+ - storagenodes/finalizers
verbs:
- - create
+ - update
- apiGroups:
- - authorization.k8s.io
+ - shardingsphere.apache.org
resources:
- - subjectaccessreviews
+ - storagenodes/status
verbs:
- - create
+ - get
+ - patch
+ - update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
diff --git a/charts/apache-shardingsphere-operator-charts/values.yaml b/charts/apache-shardingsphere-operator-charts/values.yaml
index 04a810e..1ae4cfd 100644
--- a/charts/apache-shardingsphere-operator-charts/values.yaml
+++ b/charts/apache-shardingsphere-operator-charts/values.yaml
@@ -40,7 +40,7 @@ operator:
## imagePullSecrets:
## - name: mysecret
##
- imagePullSecrets: { }
+ imagePullSecrets: [ ]
## @param resources operator Resources required by the operator
## e.g:
## resources:
@@ -54,11 +54,28 @@ operator:
##
health:
healthProbePort: 8081
+ ## @param metrics.metricsBindAddress operator metrics port
+ ##
+ metrics:
+ metricsBindAddress: 8080
## @param featureGates.computeNode operator health check port
+ ## @param featureGates.storageNode operator health check port
##
featureGates:
computeNode: false
+ storageNode: false
+ storageNodeProviders:
+ aws:
+ ## @param storageNodeProviders.aws.enabled Whether to enable aws storage node
+ ## @param storageNodeProviders.aws.region aws region
+ ## @param storageNodeProviders.aws.accessKeyId aws access key id
+ ## @param storageNodeProviders.aws.secretAccessKey aws secret access key
+ ##
+ enabled: false
+ region: ""
+ accessKeyId: ""
+ secretAccessKey: ""
## @section ShardingSphere-Proxy cluster parameters
proxyCluster:
diff --git a/docs/shardingsphere-operator.md b/docs/shardingsphere-operator.md
index f18f916..450a173 100644
--- a/docs/shardingsphere-operator.md
+++ b/docs/shardingsphere-operator.md
@@ -64,7 +64,7 @@ helm install shardingsphere shardingsphere/apache-shardingsphere-operator-cluste
|--------------------------|-----------------------------------------------------------------------------------------------------------|----------------------------------|
| `nameOverride` | nameOverride String to partially override common.names.fullname template (will maintain the release name) | `apache-shardingsphere-operator` |
| `replicaCount` | operator replica count | `2` |
-| `image.repository` | operator image name | `sahrdingsphere-operator` |
+| `image.repository` | operator image name | `shardingsphere-operator` |
| `image.pullPolicy` | image pull policy | `IfNotPresent` |
| `image.tag` | image tag | `0.0.1` |
| `imagePullSecrets` | image pull secret of private repository | `[]` |
diff --git a/examples/operator/shardingsphereproxy-storagenode-aws-rds-instance.yaml b/examples/operator/shardingsphereproxy-storagenode-aws-rds-instance.yaml
index 97b3b41..fcc94f2 100644
--- a/examples/operator/shardingsphereproxy-storagenode-aws-rds-instance.yaml
+++ b/examples/operator/shardingsphereproxy-storagenode-aws-rds-instance.yaml
@@ -45,6 +45,8 @@ metadata:
shardingsphere.apache.org/logic-database-name: "sharding_db"
"shardingsphere.apache.org/compute-node-namespace": "default"
"shardingsphere.apache.org/compute-node-name": "shardingsphere-operator-shardingsphere-proxy"
+ "databaseclass.database-mesh.io/master-username": "root"
+ "databaseclass.database-mesh.io/master-user-password": "root123456"
spec:
databaseClassName: "aws-rds-instance-mysql-5.7"
diff --git a/shardingsphere-operator/build/Dockerfile b/shardingsphere-operator/build/Dockerfile
index ffb48bc..fff550a 100644
--- a/shardingsphere-operator/build/Dockerfile
+++ b/shardingsphere-operator/build/Dockerfile
@@ -16,7 +16,7 @@
#
-# Stage1: Build Go binary for AMD64
+# Stage1: Build Go binary for AMD64
FROM --platform=linux/amd64 golang:1.19-alpine AS builder-amd64
WORKDIR /workspace
COPY go.mod go.mod
@@ -52,9 +52,9 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "-w -s" -gcflags "-
# Step3: Build a multi-platform image
FROM alpine:3.15.4
-COPY --from=builder-amd64 /workspace/operator-bin-amd64 .
-COPY --from=builder-arm64 /workspace/operator-bin-arm64 .
+COPY --from=builder-amd64 /workspace/operator-bin-amd64 .
+COPY --from=builder-arm64 /workspace/operator-bin-arm64 .
-# Add a scripts for start
+# Add a scripts for start
COPY start.sh /start.sh
ENTRYPOINT ["/bin/sh", "/start.sh"]
diff --git a/shardingsphere-operator/cmd/shardingsphere-operator/manager/manager.go b/shardingsphere-operator/cmd/shardingsphere-operator/manager/manager.go
index 05681f0..39336f1 100644
--- a/shardingsphere-operator/cmd/shardingsphere-operator/manager/manager.go
+++ b/shardingsphere-operator/cmd/shardingsphere-operator/manager/manager.go
@@ -21,9 +21,9 @@ import (
"context"
"os"
+ "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/controllers"
"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/metrics"
- "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/controllers"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
diff --git a/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go b/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go
index 344c8cc..fe84761 100644
--- a/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go
+++ b/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go
@@ -95,7 +95,7 @@ func ParseOptionsFromCmdFlags() *Options {
flag.StringVar(&opt.FeatureGates, "feature-gates", "", "A set of key=value pairs that describe feature gates for alpha/experimental features.")
// aws client options
flag.StringVar(&AwsAccessKeyID, "aws-access-key-id", "", "The AWS access key ID.")
- flag.StringVar(&AwsSecretAccessKey, "aws-secret-key", "", "The AWS secret access key.")
+ flag.StringVar(&AwsSecretAccessKey, "aws-secret-access-key", "", "The AWS secret access key.")
flag.StringVar(&AwsRegion, "aws-region", "", "The AWS region.")
opt.ZapOptions.BindFlags(flag.CommandLine)
diff --git a/shardingsphere-operator/go.mod b/shardingsphere-operator/go.mod
index 6b14639..c88d70b 100644
--- a/shardingsphere-operator/go.mod
+++ b/shardingsphere-operator/go.mod
@@ -6,7 +6,7 @@ require (
bou.ke/monkey v1.0.2
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/antlr/antlr4 v0.0.0-20181218183524-be58ebffde8e
- github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230410023700-25a841a23cd2
+ github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230517110555-afab5b4a7813
github.com/database-mesh/golang-sdk v0.0.0-20230517034007-f86740cbb78b
github.com/go-logr/logr v1.2.4
github.com/go-sql-driver/mysql v1.7.1
diff --git a/shardingsphere-operator/go.sum b/shardingsphere-operator/go.sum
index cfdae42..4288304 100644
--- a/shardingsphere-operator/go.sum
+++ b/shardingsphere-operator/go.sum
@@ -53,6 +53,8 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230410023700-25a841a23cd2 h1:GSlVaO27tBifERXOOLjIurmyOgwb/I26AMEwvuG84IU=
github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230410023700-25a841a23cd2/go.mod h1:5qllHIhMkPEWjIimDum42JtMj0P1Tn9x91XUceuPNjY=
+github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230517110555-afab5b4a7813 h1:wkqJxUgF2logjmjM2/1orNnq8OavkQRgFhmEHqD51Jg=
+github.com/chaos-mesh/chaos-mesh/api v0.0.0-20230517110555-afab5b4a7813/go.mod h1:5qllHIhMkPEWjIimDum42JtMj0P1Tn9x91XUceuPNjY=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
diff --git a/shardingsphere-operator/pkg/controllers/compute_node_controller.go b/shardingsphere-operator/pkg/controllers/compute_node_controller.go
index 02a6f47..8365b7c 100644
--- a/shardingsphere-operator/pkg/controllers/compute_node_controller.go
+++ b/shardingsphere-operator/pkg/controllers/compute_node_controller.go
@@ -66,6 +66,13 @@ func (r *ComputeNodeReconciler) SetupWithManager(mgr ctrl.Manager) error {
Complete(r)
}
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=computenodes,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=computenodes/status,verbs=get;update;patch
+// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;patch;delete
+
// Reconcile handles main function of this controller
func (r *ComputeNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := r.Log.WithValues(computeNodeControllerName, req.NamespacedName)
diff --git a/shardingsphere-operator/pkg/controllers/proxy_controller.go b/shardingsphere-operator/pkg/controllers/proxy_controller.go
index 82fbb71..4fa3d57 100644
--- a/shardingsphere-operator/pkg/controllers/proxy_controller.go
+++ b/shardingsphere-operator/pkg/controllers/proxy_controller.go
@@ -51,18 +51,20 @@ type ProxyReconciler struct {
Log logr.Logger
}
-//+kubebuilder:rbac:groups=shardingsphere.apache.org,resources=proxies,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=shardingsphere.apache.org,resources=proxies/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=shardingsphere.apache.org,resources=proxies/finalizers,verbs=update
-//+kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=apps,resources=deployment/status,verbs=get;list
-//+kubebuilder:rbac:groups="",resources=pods,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups="",resources=pods/status,verbs=get;list;watch;
-//+kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingsphereproxies,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingsphereproxies/status,verbs=get;update;patch
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingsphereproxies/finalizers,verbs=update
+// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=apps,resources=deployments/status,verbs=get
+// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=core,resources=services/status,verbs=get
+// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;create;update;patch;delete;deletecollection
+// +kubebuilder:rbac:groups=core,resources=pods/status,verbs=get
+// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers/status,verbs=get
// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
-
func (r *ProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := r.Log.WithValues(proxyControllerName, req.NamespacedName)
diff --git a/shardingsphere-operator/pkg/controllers/proxyconfig_controller.go b/shardingsphere-operator/pkg/controllers/proxyconfig_controller.go
index cb960ab..d6e2b0c 100644
--- a/shardingsphere-operator/pkg/controllers/proxyconfig_controller.go
+++ b/shardingsphere-operator/pkg/controllers/proxyconfig_controller.go
@@ -45,10 +45,10 @@ type ProxyConfigReconciler struct {
Log logr.Logger
}
-//+kubebuilder:rbac:groups=shardingsphere.apache.org,resources=proxyconfigs,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=shardingsphere.apache.org,resources=proxyconfigs/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=shardingsphere.apache.org,resources=proxyconfigs/finalizers,verbs=update
-//+kubebuilder:rbac:groups="",resources=configmap,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingsphereproxyserverconfigs,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingsphereproxyserverconfigs/status,verbs=get;update;patch
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingsphereproxyserverconfigs/finalizers,verbs=update
+// +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
diff --git a/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go b/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
index c512ccf..535ec48 100644
--- a/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
+++ b/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
@@ -70,6 +70,10 @@ type ExecCtrl struct {
ctx context.Context
}
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingspherechaos,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingspherechaos/status,verbs=get;update;patch
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=shardingspherechaos/finalizers,verbs=update
+
// Reconcile handles main function of this controller
func (r *ShardingSphereChaosReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := r.Log.WithValues(ShardingSphereChaosControllerName, req.NamespacedName)
diff --git a/shardingsphere-operator/pkg/controllers/storage_node_controller.go b/shardingsphere-operator/pkg/controllers/storage_node_controller.go
index 96cf79a..3c99383 100644
--- a/shardingsphere-operator/pkg/controllers/storage_node_controller.go
+++ b/shardingsphere-operator/pkg/controllers/storage_node_controller.go
@@ -64,6 +64,11 @@ type StorageNodeReconciler struct {
Service service.Service
}
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=storagenodes,verbs=get;list;watch;create;update;patch;delete
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=storagenodes/status,verbs=get;update;patch
+// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=storagenodes/finalizers,verbs=update
+// +kubebuilder:rbac:groups=core.database-mesh.io,resources=databaseclasses,verbs=get;list;watch
+
// Reconcile handles main function of this controller
// nolint:gocognit
func (r *StorageNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
diff --git a/shardingsphere-operator/pkg/metrics/metrics.go b/shardingsphere-operator/pkg/metrics/metrics.go
index 36eda5a..c1f2655 100644
--- a/shardingsphere-operator/pkg/metrics/metrics.go
+++ b/shardingsphere-operator/pkg/metrics/metrics.go
@@ -35,7 +35,7 @@ var (
isLeader = false
)
-// LeaderElectionMetrics represents metrics about leader election
+// LeaderElectionMetric represents metrics about leader election
type LeaderElectionMetric struct {
elected <-chan struct{}
status *prometheus.GaugeVec