From bb73f0eeb3adfc71a07d8db39878eb7a0039c99d Mon Sep 17 00:00:00 2001 From: Waynerv Date: Wed, 6 Dec 2023 20:29:34 +0800 Subject: [PATCH] chore: rename crd group and name and add release charts workflow (#33) * chore: remove unused permissions from chart Signed-off-by: Xie Wei * chore: rename crd group and name Signed-off-by: Xie Wei * ci: add release charts workflow Signed-off-by: Xie Wei --------- Signed-off-by: Xie Wei --- .github/workflows/release_charts.yml | 34 +++ Makefile.kube | 2 +- api/v1/constants.go | 2 +- api/v1/groupversion_info.go | 6 +- ...er_types.go => opengeminicluster_types.go} | 40 ++-- api/v1/zz_generated.deepcopy.go | 222 +++++++++--------- chart/templates/metrics-reader-rbac.yaml | 14 -- chart/templates/metrics-service.yaml | 20 -- chart/templates/proxy-rbac.yaml | 40 ---- {chart => charts/operator}/.helmignore | 0 {chart => charts/operator}/Chart.yaml | 2 +- .../operator/crds/opengeminicluster-crd.yaml | 183 +++++++-------- .../operator}/templates/_helpers.tpl | 20 +- .../operator}/templates/deployment.yaml | 10 +- .../templates/leader-election-rbac.yaml | 12 +- .../operator}/templates/manager-rbac.yaml | 34 +-- .../operator}/templates/serviceaccount.yaml | 4 +- {chart => charts/operator}/values.yaml | 0 ...=> opengemini.org_opengeminiclusters.yaml} | 20 +- config/crd/kustomization.yaml | 6 +- ...=> cainjection_in_opengeminiclusters.yaml} | 2 +- ...aml => webhook_in_opengeminiclusters.yaml} | 2 +- config/default/kustomization.yaml | 4 +- ...aml => opengeminicluster_editor_role.yaml} | 14 +- ...aml => opengeminicluster_viewer_role.yaml} | 14 +- config/rbac/role.yaml | 12 +- ...luster.yaml => _v1_opengeminicluster.yaml} | 4 +- controllers/apply.go | 4 +- controllers/instance.go | 14 +- ...ler.go => opengeminicluster_controller.go} | 60 ++--- ...o => opengeminicluster_controller_test.go} | 6 +- main.go | 8 +- pkg/configfile/configfile.go | 2 +- pkg/naming/names.go | 10 +- pkg/opengemini/meta/meta.go | 2 +- pkg/opengemini/sql/sql.go | 2 +- pkg/opengemini/store/store.go | 2 +- pkg/specs/service.go | 8 +- 38 files changed, 394 insertions(+), 447 deletions(-) create mode 100644 .github/workflows/release_charts.yml rename api/v1/{geminicluster_types.go => opengeminicluster_types.go} (85%) delete mode 100644 chart/templates/metrics-reader-rbac.yaml delete mode 100644 chart/templates/metrics-service.yaml delete mode 100644 chart/templates/proxy-rbac.yaml rename {chart => charts/operator}/.helmignore (100%) rename {chart => charts/operator}/Chart.yaml (98%) rename chart/templates/geminicluster-crd.yaml => charts/operator/crds/opengeminicluster-crd.yaml (85%) rename {chart => charts/operator}/templates/_helpers.tpl (75%) rename {chart => charts/operator}/templates/deployment.yaml (83%) rename {chart => charts/operator}/templates/leader-election-rbac.yaml (71%) rename {chart => charts/operator}/templates/manager-rbac.yaml (65%) rename {chart => charts/operator}/templates/serviceaccount.yaml (72%) rename {chart => charts/operator}/values.yaml (100%) rename config/crd/bases/{opengemini-operator.opengemini.org_geminiclusters.yaml => opengemini.org_opengeminiclusters.yaml} (98%) rename config/crd/patches/{cainjection_in_geminiclusters.yaml => cainjection_in_opengeminiclusters.yaml} (81%) rename config/crd/patches/{webhook_in_geminiclusters.yaml => webhook_in_opengeminiclusters.yaml} (86%) rename config/rbac/{geminicluster_editor_role.yaml => opengeminicluster_editor_role.yaml} (63%) rename config/rbac/{geminicluster_viewer_role.yaml => opengeminicluster_viewer_role.yaml} (61%) rename config/samples/{opengemini-operator_v1_geminicluster.yaml => _v1_opengeminicluster.yaml} (93%) rename controllers/{geminicluster_controller.go => opengeminicluster_controller.go} (87%) rename controllers/{geminicluster_controller_test.go => opengeminicluster_controller_test.go} (94%) diff --git a/.github/workflows/release_charts.yml b/.github/workflows/release_charts.yml new file mode 100644 index 0000000..3d06674 --- /dev/null +++ b/.github/workflows/release_charts.yml @@ -0,0 +1,34 @@ +name: Release Charts + +on: + push: + branches: + - main + tags: + - "v*.*.*" + +jobs: + release: + # depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions + # see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v3 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.6.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/Makefile.kube b/Makefile.kube index 3ccfe81..a46946a 100644 --- a/Makefile.kube +++ b/Makefile.kube @@ -164,4 +164,4 @@ $(HELMIFY): $(LOCALBIN) test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@latest helm: manifests kustomize helmify - $(KUSTOMIZE) build config/default | $(HELMIFY) chart + $(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir charts/operator diff --git a/api/v1/constants.go b/api/v1/constants.go index 272d4e1..2e5d5d2 100644 --- a/api/v1/constants.go +++ b/api/v1/constants.go @@ -6,7 +6,7 @@ const ( ServiceMaintainSuffix = "-mt" ServiceReadWriteSuffix = "-rw" - labelPrefix = "opengemini-operator.opengemini.org/" + labelPrefix = "opengemini.org/" LabelCluster = labelPrefix + "cluster" LabelInstance = labelPrefix + "instance" LabelInstanceSet = labelPrefix + "instance-set" diff --git a/api/v1/groupversion_info.go b/api/v1/groupversion_info.go index 2c3abd5..8c91b97 100644 --- a/api/v1/groupversion_info.go +++ b/api/v1/groupversion_info.go @@ -14,9 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1 contains API Schema definitions for the opengemini-operator v1 API group +// Package v1 contains API Schema definitions for the v1 API group // +kubebuilder:object:generate=true -// +groupName=opengemini-operator.opengemini.org +// +groupName=opengemini.org package v1 import ( @@ -26,7 +26,7 @@ import ( var ( // GroupVersion is group version used to register these objects - GroupVersion = schema.GroupVersion{Group: "opengemini-operator.opengemini.org", Version: "v1"} + GroupVersion = schema.GroupVersion{Group: "opengemini.org", Version: "v1"} // SchemeBuilder is used to add go types to the GroupVersionKind scheme SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} diff --git a/api/v1/geminicluster_types.go b/api/v1/opengeminicluster_types.go similarity index 85% rename from api/v1/geminicluster_types.go rename to api/v1/opengeminicluster_types.go index 73ff223..66d9a3c 100644 --- a/api/v1/geminicluster_types.go +++ b/api/v1/opengeminicluster_types.go @@ -28,8 +28,8 @@ import ( // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. -// GeminiClusterSpec defines the desired state of GeminiCluster -type GeminiClusterSpec struct { +// OpenGeminiClusterSpec defines the desired state of OpenGeminiCluster +type OpenGeminiClusterSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -153,8 +153,8 @@ type InstanceSetStatus struct { UpdatedReplicas int32 `json:"updatedReplicas,omitempty"` } -// GeminiClusterStatus defines the observed state of GeminiCluster -type GeminiClusterStatus struct { +// OpenGeminiClusterStatus defines the observed state of OpenGeminiCluster +type OpenGeminiClusterStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -187,27 +187,27 @@ type GeminiClusterStatus struct { } //+kubebuilder:object:root=true -//+kubebuilder:resource:shortName=ogi +//+kubebuilder:resource:shortName=ogc //+kubebuilder:subresource:status -// GeminiCluster is the Schema for the geminiclusters API -type GeminiCluster struct { +// OpenGeminiCluster is the Schema for the opengeminiclusters API +type OpenGeminiCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec GeminiClusterSpec `json:"spec,omitempty"` - Status GeminiClusterStatus `json:"status,omitempty"` + Spec OpenGeminiClusterSpec `json:"spec,omitempty"` + Status OpenGeminiClusterStatus `json:"status,omitempty"` } -func (cluster *GeminiCluster) GetServiceMaintainName() string { +func (cluster *OpenGeminiCluster) GetServiceMaintainName() string { return fmt.Sprintf("%v%v", cluster.Name, ServiceMaintainSuffix) } -func (cluster *GeminiCluster) GetServiceReadWriteName() string { +func (cluster *OpenGeminiCluster) GetServiceReadWriteName() string { return fmt.Sprintf("%v%v", cluster.Name, ServiceReadWriteSuffix) } -func (cluster *GeminiCluster) GetEnableHttpAuth() bool { +func (cluster *OpenGeminiCluster) GetEnableHttpAuth() bool { if cluster.Spec.EnableHttpAuth != nil { return *cluster.Spec.EnableHttpAuth } @@ -215,15 +215,15 @@ func (cluster *GeminiCluster) GetEnableHttpAuth() bool { return false } -func (cluster *GeminiCluster) GetEnableAffinity() bool { +func (cluster *OpenGeminiCluster) GetEnableAffinity() bool { return cluster.Spec.Affinity.EnablePodAntiAffinity } -func (cluster *GeminiCluster) GetAdminUserSecretName() string { +func (cluster *OpenGeminiCluster) GetAdminUserSecretName() string { return fmt.Sprintf("%v%v", cluster.Name, AdminUserSecretSuffix) } -func (cluster *GeminiCluster) SetInheritedMetadata(obj *metav1.ObjectMeta) { +func (cluster *OpenGeminiCluster) SetInheritedMetadata(obj *metav1.ObjectMeta) { obj.Annotations = utils.MergeLabels(cluster.Spec.Metadata.GetAnnotationsOrNil()) obj.Labels = utils.MergeLabels(cluster.Spec.Metadata.GetLabelsOrNil(), map[string]string{ @@ -231,7 +231,7 @@ func (cluster *GeminiCluster) SetInheritedMetadata(obj *metav1.ObjectMeta) { }) } -func (cluster *GeminiCluster) IsSqlReady() bool { +func (cluster *OpenGeminiCluster) IsSqlReady() bool { for _, status := range cluster.Status.InstanceSets { if status.Name == "sql" { if status.Replicas != 0 && status.ReadyReplicas == status.Replicas { @@ -244,13 +244,13 @@ func (cluster *GeminiCluster) IsSqlReady() bool { //+kubebuilder:object:root=true -// GeminiClusterList contains a list of GeminiCluster -type GeminiClusterList struct { +// OpenGeminiClusterList contains a list of OpenGeminiCluster +type OpenGeminiClusterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []GeminiCluster `json:"items"` + Items []OpenGeminiCluster `json:"items"` } func init() { - SchemeBuilder.Register(&GeminiCluster{}, &GeminiClusterList{}) + SchemeBuilder.Register(&OpenGeminiCluster{}, &OpenGeminiClusterList{}) } diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index 65414d4..8de7af0 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -42,219 +42,219 @@ func (in *AffinitySpec) DeepCopy() *AffinitySpec { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GeminiCluster) DeepCopyInto(out *GeminiCluster) { +func (in *InstanceSetStatus) DeepCopyInto(out *InstanceSetStatus) { *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GeminiCluster. -func (in *GeminiCluster) DeepCopy() *GeminiCluster { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSetStatus. +func (in *InstanceSetStatus) DeepCopy() *InstanceSetStatus { if in == nil { return nil } - out := new(GeminiCluster) + out := new(InstanceSetStatus) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *GeminiCluster) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GeminiClusterList) DeepCopyInto(out *GeminiClusterList) { +func (in *MetaParamsSpec) DeepCopyInto(out *MetaParamsSpec) { *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]GeminiCluster, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GeminiClusterList. -func (in *GeminiClusterList) DeepCopy() *GeminiClusterList { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaParamsSpec. +func (in *MetaParamsSpec) DeepCopy() *MetaParamsSpec { if in == nil { return nil } - out := new(GeminiClusterList) + out := new(MetaParamsSpec) in.DeepCopyInto(out) return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *GeminiClusterList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GeminiClusterSpec) DeepCopyInto(out *GeminiClusterSpec) { +func (in *MetaSpec) DeepCopyInto(out *MetaSpec) { *out = *in - if in.Paused != nil { - in, out := &in.Paused, &out.Paused - *out = new(bool) - **out = **in - } - if in.Metadata != nil { - in, out := &in.Metadata, &out.Metadata - *out = new(Metadata) - (*in).DeepCopyInto(*out) - } - in.SQL.DeepCopyInto(&out.SQL) - in.Meta.DeepCopyInto(&out.Meta) - in.Store.DeepCopyInto(&out.Store) - out.Monitoring = in.Monitoring - out.Affinity = in.Affinity - if in.EnableHttpAuth != nil { - in, out := &in.EnableHttpAuth, &out.EnableHttpAuth - *out = new(bool) + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) **out = **in } + in.DataVolumeClaimSpec.DeepCopyInto(&out.DataVolumeClaimSpec) + in.Resources.DeepCopyInto(&out.Resources) + out.Parameters = in.Parameters } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GeminiClusterSpec. -func (in *GeminiClusterSpec) DeepCopy() *GeminiClusterSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaSpec. +func (in *MetaSpec) DeepCopy() *MetaSpec { if in == nil { return nil } - out := new(GeminiClusterSpec) + out := new(MetaSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *GeminiClusterStatus) DeepCopyInto(out *GeminiClusterStatus) { +func (in *Metadata) DeepCopyInto(out *Metadata) { *out = *in - if in.InstanceSets != nil { - in, out := &in.InstanceSets, &out.InstanceSets - *out = make([]InstanceSetStatus, len(*in)) - copy(*out, *in) + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } } - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]metav1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val } } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GeminiClusterStatus. -func (in *GeminiClusterStatus) DeepCopy() *GeminiClusterStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metadata. +func (in *Metadata) DeepCopy() *Metadata { if in == nil { return nil } - out := new(GeminiClusterStatus) + out := new(Metadata) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *InstanceSetStatus) DeepCopyInto(out *InstanceSetStatus) { +func (in *MonitoringSpec) DeepCopyInto(out *MonitoringSpec) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceSetStatus. -func (in *InstanceSetStatus) DeepCopy() *InstanceSetStatus { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitoringSpec. +func (in *MonitoringSpec) DeepCopy() *MonitoringSpec { if in == nil { return nil } - out := new(InstanceSetStatus) + out := new(MonitoringSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MetaParamsSpec) DeepCopyInto(out *MetaParamsSpec) { +func (in *OpenGeminiCluster) DeepCopyInto(out *OpenGeminiCluster) { *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaParamsSpec. -func (in *MetaParamsSpec) DeepCopy() *MetaParamsSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenGeminiCluster. +func (in *OpenGeminiCluster) DeepCopy() *OpenGeminiCluster { if in == nil { return nil } - out := new(MetaParamsSpec) + out := new(OpenGeminiCluster) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OpenGeminiCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MetaSpec) DeepCopyInto(out *MetaSpec) { +func (in *OpenGeminiClusterList) DeepCopyInto(out *OpenGeminiClusterList) { *out = *in - if in.Replicas != nil { - in, out := &in.Replicas, &out.Replicas - *out = new(int32) - **out = **in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]OpenGeminiCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } - in.DataVolumeClaimSpec.DeepCopyInto(&out.DataVolumeClaimSpec) - in.Resources.DeepCopyInto(&out.Resources) - out.Parameters = in.Parameters } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetaSpec. -func (in *MetaSpec) DeepCopy() *MetaSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenGeminiClusterList. +func (in *OpenGeminiClusterList) DeepCopy() *OpenGeminiClusterList { if in == nil { return nil } - out := new(MetaSpec) + out := new(OpenGeminiClusterList) in.DeepCopyInto(out) return out } +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *OpenGeminiClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *Metadata) DeepCopyInto(out *Metadata) { +func (in *OpenGeminiClusterSpec) DeepCopyInto(out *OpenGeminiClusterSpec) { *out = *in - if in.Labels != nil { - in, out := &in.Labels, &out.Labels - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + if in.Paused != nil { + in, out := &in.Paused, &out.Paused + *out = new(bool) + **out = **in } - if in.Annotations != nil { - in, out := &in.Annotations, &out.Annotations - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } + if in.Metadata != nil { + in, out := &in.Metadata, &out.Metadata + *out = new(Metadata) + (*in).DeepCopyInto(*out) + } + in.SQL.DeepCopyInto(&out.SQL) + in.Meta.DeepCopyInto(&out.Meta) + in.Store.DeepCopyInto(&out.Store) + out.Monitoring = in.Monitoring + out.Affinity = in.Affinity + if in.EnableHttpAuth != nil { + in, out := &in.EnableHttpAuth, &out.EnableHttpAuth + *out = new(bool) + **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Metadata. -func (in *Metadata) DeepCopy() *Metadata { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenGeminiClusterSpec. +func (in *OpenGeminiClusterSpec) DeepCopy() *OpenGeminiClusterSpec { if in == nil { return nil } - out := new(Metadata) + out := new(OpenGeminiClusterSpec) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MonitoringSpec) DeepCopyInto(out *MonitoringSpec) { +func (in *OpenGeminiClusterStatus) DeepCopyInto(out *OpenGeminiClusterStatus) { *out = *in + if in.InstanceSets != nil { + in, out := &in.InstanceSets, &out.InstanceSets + *out = make([]InstanceSetStatus, len(*in)) + copy(*out, *in) + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MonitoringSpec. -func (in *MonitoringSpec) DeepCopy() *MonitoringSpec { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenGeminiClusterStatus. +func (in *OpenGeminiClusterStatus) DeepCopy() *OpenGeminiClusterStatus { if in == nil { return nil } - out := new(MonitoringSpec) + out := new(OpenGeminiClusterStatus) in.DeepCopyInto(out) return out } diff --git a/chart/templates/metrics-reader-rbac.yaml b/chart/templates/metrics-reader-rbac.yaml deleted file mode 100644 index e8a7c1c..0000000 --- a/chart/templates/metrics-reader-rbac.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "chart.fullname" . }}-metrics-reader - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: opengemini-operator - app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} -rules: -- nonResourceURLs: - - /metrics - verbs: - - get \ No newline at end of file diff --git a/chart/templates/metrics-service.yaml b/chart/templates/metrics-service.yaml deleted file mode 100644 index b3d3fe4..0000000 --- a/chart/templates/metrics-service.yaml +++ /dev/null @@ -1,20 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "chart.fullname" . }}-controller-manager-metrics-service - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: opengemini-operator - app.kubernetes.io/part-of: opengemini-operator - control-plane: controller-manager - {{- include "chart.labels" . | nindent 4 }} -spec: - type: ClusterIP - selector: - control-plane: controller-manager - {{- include "chart.selectorLabels" . | nindent 4 }} - ports: - - name: https - port: 8443 - protocol: TCP - targetPort: https diff --git a/chart/templates/proxy-rbac.yaml b/chart/templates/proxy-rbac.yaml deleted file mode 100644 index 723fc6d..0000000 --- a/chart/templates/proxy-rbac.yaml +++ /dev/null @@ -1,40 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ include "chart.fullname" . }}-proxy-role - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: opengemini-operator - app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} -rules: -- apiGroups: - - authentication.k8s.io - resources: - - tokenreviews - verbs: - - create -- apiGroups: - - authorization.k8s.io - resources: - - subjectaccessreviews - verbs: - - create ---- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: {{ include "chart.fullname" . }}-proxy-rolebinding - labels: - app.kubernetes.io/component: kube-rbac-proxy - app.kubernetes.io/created-by: opengemini-operator - app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: '{{ include "chart.fullname" . }}-proxy-role' -subjects: -- kind: ServiceAccount - name: '{{ include "chart.fullname" . }}-controller-manager' - namespace: '{{ .Release.Namespace }}' \ No newline at end of file diff --git a/chart/.helmignore b/charts/operator/.helmignore similarity index 100% rename from chart/.helmignore rename to charts/operator/.helmignore diff --git a/chart/Chart.yaml b/charts/operator/Chart.yaml similarity index 98% rename from chart/Chart.yaml rename to charts/operator/Chart.yaml index 200d973..355db26 100644 --- a/chart/Chart.yaml +++ b/charts/operator/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 -name: chart +name: operator description: A Helm chart for Kubernetes # A chart can be either an 'application' or a 'library' chart. # diff --git a/chart/templates/geminicluster-crd.yaml b/charts/operator/crds/opengeminicluster-crd.yaml similarity index 85% rename from chart/templates/geminicluster-crd.yaml rename to charts/operator/crds/opengeminicluster-crd.yaml index e5a950e..c83c3d7 100644 --- a/chart/templates/geminicluster-crd.yaml +++ b/charts/operator/crds/opengeminicluster-crd.yaml @@ -1,26 +1,25 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: geminiclusters.opengemini-operator.opengemini.org annotations: controller-gen.kubebuilder.io/version: v0.10.0 - labels: - {{- include "chart.labels" . | nindent 4 }} + creationTimestamp: null + name: opengeminiclusters.opengemini.org spec: - group: opengemini-operator.opengemini.org + group: opengemini.org names: - kind: GeminiCluster - listKind: GeminiClusterList - plural: geminiclusters + kind: OpenGeminiCluster + listKind: OpenGeminiClusterList + plural: opengeminiclusters shortNames: - - ogi - singular: geminicluster + - ogc + singular: opengeminicluster scope: Namespaced versions: - name: v1 schema: openAPIV3Schema: - description: GeminiCluster is the Schema for the geminiclusters API + description: OpenGeminiCluster is the Schema for the opengeminiclusters API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -35,7 +34,7 @@ spec: metadata: type: object spec: - description: GeminiClusterSpec defines the desired state of GeminiCluster + description: OpenGeminiClusterSpec defines the desired state of OpenGeminiCluster properties: affinity: properties: @@ -56,7 +55,8 @@ spec: properties: dataVolumeClaimSpec: description: PersistentVolumeClaimSpec describes the common attributes - of storage devices and allows a Source for provider-specific attributes + of storage devices and allows a Source for provider-specific + attributes properties: accessModes: description: 'accessModes contains the desired access modes @@ -68,11 +68,11 @@ spec: description: 'dataSource field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner - or an external controller can support the specified data source, - it will create a new volume based on the contents of the specified - data source. If the AnyVolumeDataSource feature gate is enabled, - this field will always have the same contents as the DataSourceRef - field.' + or an external controller can support the specified data + source, it will create a new volume based on the contents + of the specified data source. If the AnyVolumeDataSource + feature gate is enabled, this field will always have the + same contents as the DataSourceRef field.' properties: apiGroup: description: APIGroup is the group for the resource being @@ -93,25 +93,25 @@ spec: x-kubernetes-map-type: atomic dataSourceRef: description: 'dataSourceRef specifies the object from which - to populate the volume with data, if a non-empty volume is - desired. This may be any local object from a non-empty API - group (non core object) or a PersistentVolumeClaim object. + to populate the volume with data, if a non-empty volume + is desired. This may be any local object from a non-empty + API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed - volume populator or dynamic provisioner. This field will replace - the functionality of the DataSource field and as such if both - fields are non-empty, they must have the same value. For backwards - compatibility, both fields (DataSource and DataSourceRef) - will be set to the same value automatically if one of them - is empty and the other is non-empty. There are two important - differences between DataSource and DataSourceRef: * While - DataSource only allows two specific types of objects, DataSourceRef - allows any non-core object, as well as PersistentVolumeClaim + volume populator or dynamic provisioner. This field will + replace the functionality of the DataSource field and as + such if both fields are non-empty, they must have the same + value. For backwards compatibility, both fields (DataSource + and DataSourceRef) will be set to the same value automatically + if one of them is empty and the other is non-empty. There + are two important differences between DataSource and DataSourceRef: + * While DataSource only allows two specific types of objects, + DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. * While DataSource ignores disallowed values (dropping - them), DataSourceRef preserves all values, and generates an - error if a disallowed value is specified. (Beta) Using this - field requires the AnyVolumeDataSource feature gate to be - enabled.' + them), DataSourceRef preserves all values, and generates + an error if a disallowed value is specified. (Beta) Using + this field requires the AnyVolumeDataSource feature gate + to be enabled.' properties: apiGroup: description: APIGroup is the group for the resource being @@ -135,8 +135,8 @@ spec: volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher - than capacity recorded in the status field of the claim. More - info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' + than capacity recorded in the status field of the claim. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' properties: limits: additionalProperties: @@ -155,11 +155,11 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. More info: - https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + description: 'Requests describes the minimum amount of + compute resources required. If Requests is omitted for + a container, it defaults to Limits if that is explicitly + specified, otherwise to an implementation-defined value. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object selector: @@ -171,8 +171,8 @@ spec: requirements. The requirements are ANDed. items: description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. + that contains values, a key, and an operator that + relates the key and values. properties: key: description: key is the label key that the selector @@ -187,8 +187,9 @@ spec: description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or - DoesNotExist, the values array must be empty. This - array is replaced during a strategic merge patch. + DoesNotExist, the values array must be empty. + This array is replaced during a strategic merge + patch. items: type: string type: array @@ -346,7 +347,8 @@ spec: properties: dataVolumeClaimSpec: description: PersistentVolumeClaimSpec describes the common attributes - of storage devices and allows a Source for provider-specific attributes + of storage devices and allows a Source for provider-specific + attributes properties: accessModes: description: 'accessModes contains the desired access modes @@ -358,11 +360,11 @@ spec: description: 'dataSource field can be used to specify either: * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) * An existing PVC (PersistentVolumeClaim) If the provisioner - or an external controller can support the specified data source, - it will create a new volume based on the contents of the specified - data source. If the AnyVolumeDataSource feature gate is enabled, - this field will always have the same contents as the DataSourceRef - field.' + or an external controller can support the specified data + source, it will create a new volume based on the contents + of the specified data source. If the AnyVolumeDataSource + feature gate is enabled, this field will always have the + same contents as the DataSourceRef field.' properties: apiGroup: description: APIGroup is the group for the resource being @@ -383,25 +385,25 @@ spec: x-kubernetes-map-type: atomic dataSourceRef: description: 'dataSourceRef specifies the object from which - to populate the volume with data, if a non-empty volume is - desired. This may be any local object from a non-empty API - group (non core object) or a PersistentVolumeClaim object. + to populate the volume with data, if a non-empty volume + is desired. This may be any local object from a non-empty + API group (non core object) or a PersistentVolumeClaim object. When this field is specified, volume binding will only succeed if the type of the specified object matches some installed - volume populator or dynamic provisioner. This field will replace - the functionality of the DataSource field and as such if both - fields are non-empty, they must have the same value. For backwards - compatibility, both fields (DataSource and DataSourceRef) - will be set to the same value automatically if one of them - is empty and the other is non-empty. There are two important - differences between DataSource and DataSourceRef: * While - DataSource only allows two specific types of objects, DataSourceRef - allows any non-core object, as well as PersistentVolumeClaim + volume populator or dynamic provisioner. This field will + replace the functionality of the DataSource field and as + such if both fields are non-empty, they must have the same + value. For backwards compatibility, both fields (DataSource + and DataSourceRef) will be set to the same value automatically + if one of them is empty and the other is non-empty. There + are two important differences between DataSource and DataSourceRef: + * While DataSource only allows two specific types of objects, + DataSourceRef allows any non-core object, as well as PersistentVolumeClaim objects. * While DataSource ignores disallowed values (dropping - them), DataSourceRef preserves all values, and generates an - error if a disallowed value is specified. (Beta) Using this - field requires the AnyVolumeDataSource feature gate to be - enabled.' + them), DataSourceRef preserves all values, and generates + an error if a disallowed value is specified. (Beta) Using + this field requires the AnyVolumeDataSource feature gate + to be enabled.' properties: apiGroup: description: APIGroup is the group for the resource being @@ -425,8 +427,8 @@ spec: volume should have. If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements that are lower than previous value but must still be higher - than capacity recorded in the status field of the claim. More - info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' + than capacity recorded in the status field of the claim. + More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' properties: limits: additionalProperties: @@ -445,11 +447,11 @@ spec: - type: string pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, - otherwise to an implementation-defined value. More info: - https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + description: 'Requests describes the minimum amount of + compute resources required. If Requests is omitted for + a container, it defaults to Limits if that is explicitly + specified, otherwise to an implementation-defined value. + More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' type: object type: object selector: @@ -461,8 +463,8 @@ spec: requirements. The requirements are ANDed. items: description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. + that contains values, a key, and an operator that + relates the key and values. properties: key: description: key is the label key that the selector @@ -477,8 +479,9 @@ spec: description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or - DoesNotExist, the values array must be empty. This - array is replaced during a strategic merge patch. + DoesNotExist, the values array must be empty. + This array is replaced during a strategic merge + patch. items: type: string type: array @@ -572,7 +575,7 @@ spec: - version type: object status: - description: GeminiClusterStatus defines the observed state of GeminiCluster + description: OpenGeminiClusterStatus defines the observed state of OpenGeminiCluster properties: adminUserInitialized: default: false @@ -588,8 +591,8 @@ spec: description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, - \n type FooStatus struct{ // Represents the observations of a foo's - current state. // Known .status.conditions.type are: \"Available\", + \n type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" @@ -603,8 +606,8 @@ spec: format: date-time type: string message: - description: message is a human readable message indicating details - about the transition. This may be an empty string. + description: message is a human readable message indicating + details about the transition. This may be an empty string. maxLength: 32768 type: string observedGeneration: @@ -618,11 +621,11 @@ spec: type: integer reason: description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers of - specific condition types may define expected values and meanings - for this field, and whether the values are considered a guaranteed - API. The value should be a CamelCase string. This field may - not be empty. + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. maxLength: 1024 minLength: 1 pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ @@ -698,9 +701,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] \ No newline at end of file diff --git a/chart/templates/_helpers.tpl b/charts/operator/templates/_helpers.tpl similarity index 75% rename from chart/templates/_helpers.tpl rename to charts/operator/templates/_helpers.tpl index 7ba5edc..c57b744 100644 --- a/chart/templates/_helpers.tpl +++ b/charts/operator/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "chart.name" -}} +{{- define "operator.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "chart.fullname" -}} +{{- define "operator.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "chart.chart" -}} +{{- define "operator.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "chart.labels" -}} -helm.sh/chart: {{ include "chart.chart" . }} -{{ include "chart.selectorLabels" . }} +{{- define "operator.labels" -}} +helm.sh/chart: {{ include "operator.chart" . }} +{{ include "operator.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "chart.selectorLabels" -}} -app.kubernetes.io/name: {{ include "chart.name" . }} +{{- define "operator.selectorLabels" -}} +app.kubernetes.io/name: {{ include "operator.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "chart.serviceAccountName" -}} +{{- define "operator.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "chart.fullname" .) .Values.serviceAccount.name }} +{{- default (include "operator.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} diff --git a/chart/templates/deployment.yaml b/charts/operator/templates/deployment.yaml similarity index 83% rename from chart/templates/deployment.yaml rename to charts/operator/templates/deployment.yaml index 1c262ca..69443ac 100644 --- a/chart/templates/deployment.yaml +++ b/charts/operator/templates/deployment.yaml @@ -1,24 +1,24 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "chart.fullname" . }}-controller-manager + name: {{ include "operator.fullname" . }}-controller-manager labels: app.kubernetes.io/component: manager app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator control-plane: controller-manager - {{- include "chart.labels" . | nindent 4 }} + {{- include "operator.labels" . | nindent 4 }} spec: replicas: {{ .Values.controllerManager.replicas }} selector: matchLabels: control-plane: controller-manager - {{- include "chart.selectorLabels" . | nindent 6 }} + {{- include "operator.selectorLabels" . | nindent 6 }} template: metadata: labels: control-plane: controller-manager - {{- include "chart.selectorLabels" . | nindent 8 }} + {{- include "operator.selectorLabels" . | nindent 8 }} annotations: kubectl.kubernetes.io/default-container: manager spec: @@ -50,5 +50,5 @@ spec: | nindent 10 }} securityContext: runAsNonRoot: true - serviceAccountName: {{ include "chart.fullname" . }}-controller-manager + serviceAccountName: {{ include "operator.fullname" . }}-controller-manager terminationGracePeriodSeconds: 10 \ No newline at end of file diff --git a/chart/templates/leader-election-rbac.yaml b/charts/operator/templates/leader-election-rbac.yaml similarity index 71% rename from chart/templates/leader-election-rbac.yaml rename to charts/operator/templates/leader-election-rbac.yaml index 6494caa..810437a 100644 --- a/chart/templates/leader-election-rbac.yaml +++ b/charts/operator/templates/leader-election-rbac.yaml @@ -1,12 +1,12 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: {{ include "chart.fullname" . }}-leader-election-role + name: {{ include "operator.fullname" . }}-leader-election-role labels: app.kubernetes.io/component: rbac app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "operator.labels" . | nindent 4 }} rules: - apiGroups: - "" @@ -43,17 +43,17 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ include "chart.fullname" . }}-leader-election-rolebinding + name: {{ include "operator.fullname" . }}-leader-election-rolebinding labels: app.kubernetes.io/component: rbac app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "operator.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role - name: '{{ include "chart.fullname" . }}-leader-election-role' + name: '{{ include "operator.fullname" . }}-leader-election-role' subjects: - kind: ServiceAccount - name: '{{ include "chart.fullname" . }}-controller-manager' + name: '{{ include "operator.fullname" . }}-controller-manager' namespace: '{{ .Release.Namespace }}' \ No newline at end of file diff --git a/chart/templates/manager-rbac.yaml b/charts/operator/templates/manager-rbac.yaml similarity index 65% rename from chart/templates/manager-rbac.yaml rename to charts/operator/templates/manager-rbac.yaml index f99a473..d83a52e 100644 --- a/chart/templates/manager-rbac.yaml +++ b/charts/operator/templates/manager-rbac.yaml @@ -1,9 +1,9 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: {{ include "chart.fullname" . }}-manager-role + name: {{ include "operator.fullname" . }}-manager-role labels: - {{- include "chart.labels" . | nindent 4 }} + {{- include "operator.labels" . | nindent 4 }} rules: - apiGroups: - "" @@ -44,16 +44,6 @@ rules: - get - list - watch -- apiGroups: - - apps - resources: - - deployments - verbs: - - create - - get - - list - - patch - - watch - apiGroups: - apps resources: @@ -65,9 +55,9 @@ rules: - patch - watch - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters + - opengeminiclusters verbs: - create - delete @@ -77,15 +67,15 @@ rules: - update - watch - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters/finalizers + - opengeminiclusters/finalizers verbs: - update - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters/status + - opengeminiclusters/status verbs: - get - patch @@ -94,17 +84,17 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: {{ include "chart.fullname" . }}-manager-rolebinding + name: {{ include "operator.fullname" . }}-manager-rolebinding labels: app.kubernetes.io/component: rbac app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "operator.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: '{{ include "chart.fullname" . }}-manager-role' + name: '{{ include "operator.fullname" . }}-manager-role' subjects: - kind: ServiceAccount - name: '{{ include "chart.fullname" . }}-controller-manager' + name: '{{ include "operator.fullname" . }}-controller-manager' namespace: '{{ .Release.Namespace }}' \ No newline at end of file diff --git a/chart/templates/serviceaccount.yaml b/charts/operator/templates/serviceaccount.yaml similarity index 72% rename from chart/templates/serviceaccount.yaml rename to charts/operator/templates/serviceaccount.yaml index 9a56fe3..2908558 100644 --- a/chart/templates/serviceaccount.yaml +++ b/charts/operator/templates/serviceaccount.yaml @@ -1,11 +1,11 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ include "chart.fullname" . }}-controller-manager + name: {{ include "operator.fullname" . }}-controller-manager labels: app.kubernetes.io/component: rbac app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator - {{- include "chart.labels" . | nindent 4 }} + {{- include "operator.labels" . | nindent 4 }} annotations: {{- toYaml .Values.controllerManager.serviceAccount.annotations | nindent 4 }} \ No newline at end of file diff --git a/chart/values.yaml b/charts/operator/values.yaml similarity index 100% rename from chart/values.yaml rename to charts/operator/values.yaml diff --git a/config/crd/bases/opengemini-operator.opengemini.org_geminiclusters.yaml b/config/crd/bases/opengemini.org_opengeminiclusters.yaml similarity index 98% rename from config/crd/bases/opengemini-operator.opengemini.org_geminiclusters.yaml rename to config/crd/bases/opengemini.org_opengeminiclusters.yaml index 492d73f..1924d27 100644 --- a/config/crd/bases/opengemini-operator.opengemini.org_geminiclusters.yaml +++ b/config/crd/bases/opengemini.org_opengeminiclusters.yaml @@ -5,22 +5,22 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.10.0 creationTimestamp: null - name: geminiclusters.opengemini-operator.opengemini.org + name: opengeminiclusters.opengemini.org spec: - group: opengemini-operator.opengemini.org + group: opengemini.org names: - kind: GeminiCluster - listKind: GeminiClusterList - plural: geminiclusters + kind: OpenGeminiCluster + listKind: OpenGeminiClusterList + plural: opengeminiclusters shortNames: - - ogi - singular: geminicluster + - ogc + singular: opengeminicluster scope: Namespaced versions: - name: v1 schema: openAPIV3Schema: - description: GeminiCluster is the Schema for the geminiclusters API + description: OpenGeminiCluster is the Schema for the opengeminiclusters API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -35,7 +35,7 @@ spec: metadata: type: object spec: - description: GeminiClusterSpec defines the desired state of GeminiCluster + description: OpenGeminiClusterSpec defines the desired state of OpenGeminiCluster properties: affinity: properties: @@ -576,7 +576,7 @@ spec: - version type: object status: - description: GeminiClusterStatus defines the observed state of GeminiCluster + description: OpenGeminiClusterStatus defines the observed state of OpenGeminiCluster properties: adminUserInitialized: default: false diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index d6d686b..9dd2ba7 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -2,18 +2,18 @@ # since it depends on service name and namespace that are out of this kustomize package. # It should be run by config/default resources: -- bases/opengemini-operator.opengemini.org_geminiclusters.yaml +- bases/opengemini.org_opengeminiclusters.yaml #+kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix. # patches here are for enabling the conversion webhook for each CRD -#- patches/webhook_in_geminiclusters.yaml +#- patches/webhook_in_opengeminiclusters.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. # patches here are for enabling the CA injection for each CRD -#- patches/cainjection_in_geminiclusters.yaml +#- patches/cainjection_in_opengeminiclusters.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # the following config is for teaching kustomize how to do kustomization for CRDs. diff --git a/config/crd/patches/cainjection_in_geminiclusters.yaml b/config/crd/patches/cainjection_in_opengeminiclusters.yaml similarity index 81% rename from config/crd/patches/cainjection_in_geminiclusters.yaml rename to config/crd/patches/cainjection_in_opengeminiclusters.yaml index 7b89c64..8479f59 100644 --- a/config/crd/patches/cainjection_in_geminiclusters.yaml +++ b/config/crd/patches/cainjection_in_opengeminiclusters.yaml @@ -4,4 +4,4 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - name: geminiclusters.opengemini-operator.opengemini.org + name: opengeminiclusters.opengemini.org diff --git a/config/crd/patches/webhook_in_geminiclusters.yaml b/config/crd/patches/webhook_in_opengeminiclusters.yaml similarity index 86% rename from config/crd/patches/webhook_in_geminiclusters.yaml rename to config/crd/patches/webhook_in_opengeminiclusters.yaml index 036ce39..e0943de 100644 --- a/config/crd/patches/webhook_in_geminiclusters.yaml +++ b/config/crd/patches/webhook_in_opengeminiclusters.yaml @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: geminiclusters.opengemini-operator.opengemini.org + name: opengeminiclusters.opengemini.org spec: conversion: strategy: Webhook diff --git a/config/default/kustomization.yaml b/config/default/kustomization.yaml index a0bdf83..0821624 100644 --- a/config/default/kustomization.yaml +++ b/config/default/kustomization.yaml @@ -1,12 +1,12 @@ # Adds namespace to all resources. -namespace: opengemini-operator-system +namespace: opengemini-system # Value of this field is prepended to the # names of all resources, e.g. a deployment named # "wordpress" becomes "alices-wordpress". # Note that it should also match with the prefix (text before '-') of the namespace # field above. -namePrefix: opengemini-operator- +namePrefix: opengemini- # Labels to add to all resources and selectors. #commonLabels: diff --git a/config/rbac/geminicluster_editor_role.yaml b/config/rbac/opengeminicluster_editor_role.yaml similarity index 63% rename from config/rbac/geminicluster_editor_role.yaml rename to config/rbac/opengeminicluster_editor_role.yaml index 8e4b2b5..3aea5db 100644 --- a/config/rbac/geminicluster_editor_role.yaml +++ b/config/rbac/opengeminicluster_editor_role.yaml @@ -1,20 +1,20 @@ -# permissions for end users to edit geminiclusters. +# permissions for end users to edit opengeminiclusters. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: geminicluster-editor-role + app.kubernetes.io/instance: opengeminicluster-editor-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator app.kubernetes.io/managed-by: kustomize - name: geminicluster-editor-role + name: opengeminicluster-editor-role rules: - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters + - opengeminiclusters verbs: - create - delete @@ -24,8 +24,8 @@ rules: - update - watch - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters/status + - opengeminiclusters/status verbs: - get diff --git a/config/rbac/geminicluster_viewer_role.yaml b/config/rbac/opengeminicluster_viewer_role.yaml similarity index 61% rename from config/rbac/geminicluster_viewer_role.yaml rename to config/rbac/opengeminicluster_viewer_role.yaml index 0f7268c..c67272e 100644 --- a/config/rbac/geminicluster_viewer_role.yaml +++ b/config/rbac/opengeminicluster_viewer_role.yaml @@ -1,27 +1,27 @@ -# permissions for end users to view geminiclusters. +# permissions for end users to view opengeminiclusters. apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: labels: app.kubernetes.io/name: clusterrole - app.kubernetes.io/instance: geminicluster-viewer-role + app.kubernetes.io/instance: opengeminicluster-viewer-role app.kubernetes.io/component: rbac app.kubernetes.io/created-by: opengemini-operator app.kubernetes.io/part-of: opengemini-operator app.kubernetes.io/managed-by: kustomize - name: geminicluster-viewer-role + name: opengeminicluster-viewer-role rules: - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters + - opengeminiclusters verbs: - get - list - watch - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters/status + - opengeminiclusters/status verbs: - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 6d4589c..1430f25 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -55,9 +55,9 @@ rules: - patch - watch - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters + - opengeminiclusters verbs: - create - delete @@ -67,15 +67,15 @@ rules: - update - watch - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters/finalizers + - opengeminiclusters/finalizers verbs: - update - apiGroups: - - opengemini-operator.opengemini.org + - opengemini.org resources: - - geminiclusters/status + - opengeminiclusters/status verbs: - get - patch diff --git a/config/samples/opengemini-operator_v1_geminicluster.yaml b/config/samples/_v1_opengeminicluster.yaml similarity index 93% rename from config/samples/opengemini-operator_v1_geminicluster.yaml rename to config/samples/_v1_opengeminicluster.yaml index 37d6a68..fe06e4f 100644 --- a/config/samples/opengemini-operator_v1_geminicluster.yaml +++ b/config/samples/_v1_opengeminicluster.yaml @@ -1,5 +1,5 @@ -apiVersion: opengemini-operator.opengemini.org/v1 -kind: GeminiCluster +apiVersion: opengemini.org/v1 +kind: OpenGeminiCluster metadata: name: test-cluster namespace: opengemini diff --git a/controllers/apply.go b/controllers/apply.go index c844177..8ccaf42 100644 --- a/controllers/apply.go +++ b/controllers/apply.go @@ -8,7 +8,7 @@ import ( ) // Use Server Side Apply -func (r *GeminiClusterReconciler) apply(ctx context.Context, object client.Object) error { +func (r *OpenGeminiClusterReconciler) apply(ctx context.Context, object client.Object) error { // Generate an apply-patch by comparing the object to its zero value. zero := reflect.New(reflect.TypeOf(object).Elem()).Interface() data, err := client.MergeFrom(zero.(client.Object)).Data(object) @@ -22,7 +22,7 @@ func (r *GeminiClusterReconciler) apply(ctx context.Context, object client.Objec return err } -func (r *GeminiClusterReconciler) patch( +func (r *OpenGeminiClusterReconciler) patch( ctx context.Context, object client.Object, patch client.Patch, diff --git a/controllers/instance.go b/controllers/instance.go index 7ae2d42..c57fa5f 100644 --- a/controllers/instance.go +++ b/controllers/instance.go @@ -19,9 +19,9 @@ import ( // +kubebuilder:rbac:groups="apps",resources="statefulsets",verbs={get,create,patch} // +kubebuilder:rbac:groups="",resources="persistentvolumeclaims",verbs={get,create,patch} -func (r *GeminiClusterReconciler) reconcileMetaInstance( +func (r *OpenGeminiClusterReconciler) reconcileMetaInstance( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, index int, ) error { instance := &appsv1.StatefulSet{} @@ -53,9 +53,9 @@ func (r *GeminiClusterReconciler) reconcileMetaInstance( // +kubebuilder:rbac:groups="apps",resources="statefulsets",verbs={get,create,patch} // +kubebuilder:rbac:groups="",resources="persistentvolumeclaims",verbs={get,create,patch} -func (r *GeminiClusterReconciler) reconcileStoreInstance( +func (r *OpenGeminiClusterReconciler) reconcileStoreInstance( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, index int, ) error { instance := &appsv1.StatefulSet{} @@ -85,9 +85,9 @@ func (r *GeminiClusterReconciler) reconcileStoreInstance( // +kubebuilder:rbac:groups="apps",resources="statefulsets",verbs={get,create,patch} -func (r *GeminiClusterReconciler) reconcileSqlInstance( +func (r *OpenGeminiClusterReconciler) reconcileSqlInstance( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, index int, ) error { instance := &appsv1.StatefulSet{} @@ -109,7 +109,7 @@ func (r *GeminiClusterReconciler) reconcileSqlInstance( func generateInstanceStatefulSetIntent( _ context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, setName string, sts *appsv1.StatefulSet, ) { diff --git a/controllers/geminicluster_controller.go b/controllers/opengeminicluster_controller.go similarity index 87% rename from controllers/geminicluster_controller.go rename to controllers/opengeminicluster_controller.go index 3bbc343..2187498 100644 --- a/controllers/geminicluster_controller.go +++ b/controllers/opengeminicluster_controller.go @@ -43,15 +43,15 @@ import ( ) const ( - ControllerManagerName = "openminicluster-controller" + ControllerManagerName = "opengeminicluster-controller" ) type K8sController interface { SetControllerReference(owner, controlled metav1.Object, scheme *runtime.Scheme) error } -// GeminiClusterReconciler reconciles a GeminiCluster object -type GeminiClusterReconciler struct { +// OpenGeminiClusterReconciler reconciles a OpenGeminiCluster object +type OpenGeminiClusterReconciler struct { client.Client Owner client.FieldOwner Scheme *runtime.Scheme @@ -59,28 +59,28 @@ type GeminiClusterReconciler struct { Controller K8sController } -//+kubebuilder:rbac:groups=opengemini-operator.opengemini.org,resources=geminiclusters,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=opengemini-operator.opengemini.org,resources=geminiclusters/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=opengemini-operator.opengemini.org,resources=geminiclusters/finalizers,verbs=update +//+kubebuilder:rbac:groups=opengemini.org,resources=opengeminiclusters,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=opengemini.org,resources=opengeminiclusters/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=opengemini.org,resources=opengeminiclusters/finalizers,verbs=update // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. // TODO(user): Modify the Reconcile function to compare the state specified by -// the GeminiCluster object against the actual cluster state, and then +// the OpenGeminiCluster object against the actual cluster state, and then // perform operations to make the cluster state reflect the state specified by // the user. // // For more details, check Reconcile and its Result here: // - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.13.1/pkg/reconcile -func (r *GeminiClusterReconciler) Reconcile( +func (r *OpenGeminiClusterReconciler) Reconcile( ctx context.Context, req ctrl.Request, ) (result ctrl.Result, err error) { log := log.FromContext(ctx) - cluster := &opengeminiv1.GeminiCluster{} + cluster := &opengeminiv1.OpenGeminiCluster{} if err = r.Get(ctx, req.NamespacedName, cluster); err != nil { - log.Error(err, "unable to fetch GeminiCluster") + log.Error(err, "unable to fetch OpenGeminiCluster") return ctrl.Result{}, client.IgnoreNotFound(err) } log.Info( @@ -98,7 +98,7 @@ func (r *GeminiClusterReconciler) Reconcile( // Handle delete if !cluster.DeletionTimestamp.IsZero() { - log.Info("GeminiCluster deleted", "name", req.Name, "namespace", req.Namespace) + log.Info("OpenGeminiCluster deleted", "name", req.Name, "namespace", req.Namespace) return ctrl.Result{}, nil } @@ -162,9 +162,9 @@ func (r *GeminiClusterReconciler) Reconcile( // +kubebuilder:rbac:groups="apps",resources="statefulsets",verbs={list} -func (r *GeminiClusterReconciler) reconcileClusterStatus( +func (r *OpenGeminiClusterReconciler) reconcileClusterStatus( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, ) error { runners := &appsv1.StatefulSetList{} @@ -202,9 +202,9 @@ func (r *GeminiClusterReconciler) reconcileClusterStatus( // +kubebuilder:rbac:groups="",resources="configmaps",verbs={get,create,patch} -func (r *GeminiClusterReconciler) reconcileClusterConfigMap( +func (r *OpenGeminiClusterReconciler) reconcileClusterConfigMap( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, ) error { confdata, err := configfile.NewBaseConfiguration(cluster) if err != nil { @@ -241,7 +241,7 @@ func (r *GeminiClusterReconciler) reconcileClusterConfigMap( } // getUpdatedConfig returns the updated config items if set config map -func (r *GeminiClusterReconciler) getUpdatedConfig(ctx context.Context, cluster *opengeminiv1.GeminiCluster, tmplConf string) (string, error) { +func (r *OpenGeminiClusterReconciler) getUpdatedConfig(ctx context.Context, cluster *opengeminiv1.OpenGeminiCluster, tmplConf string) (string, error) { var customCM corev1.ConfigMap err := r.Get( ctx, @@ -265,9 +265,9 @@ func (r *GeminiClusterReconciler) getUpdatedConfig(ctx context.Context, cluster // +kubebuilder:rbac:groups="",resources="services",verbs={get,create} -func (r *GeminiClusterReconciler) reconcileClusterServices( +func (r *OpenGeminiClusterReconciler) reconcileClusterServices( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, ) error { readWriteService := specs.CreateClusterReadWriteService(cluster) cluster.SetInheritedMetadata(&readWriteService.ObjectMeta) @@ -312,9 +312,9 @@ func (r *GeminiClusterReconciler) reconcileClusterServices( // +kubebuilder:rbac:groups="",resources="secrets",verbs={get,create,delete} -func (r *GeminiClusterReconciler) reconcileAdminUserSecret( +func (r *OpenGeminiClusterReconciler) reconcileAdminUserSecret( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, ) (err error) { log := log.FromContext(ctx) if cluster.Status.AdminUserInitialized { @@ -365,9 +365,9 @@ func (r *GeminiClusterReconciler) reconcileAdminUserSecret( return nil } -func (r *GeminiClusterReconciler) reconcileAdminAccount( +func (r *OpenGeminiClusterReconciler) reconcileAdminAccount( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, ) (err error) { log := log.FromContext(ctx) if cluster.Status.AdminUserInitialized { @@ -422,9 +422,9 @@ func (r *GeminiClusterReconciler) reconcileAdminAccount( return nil } -func (r *GeminiClusterReconciler) reconcileClusterInstances( +func (r *OpenGeminiClusterReconciler) reconcileClusterInstances( ctx context.Context, - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, ) error { for i := 0; i < int(*cluster.Spec.Meta.Replicas); i++ { @@ -445,15 +445,15 @@ func (r *GeminiClusterReconciler) reconcileClusterInstances( return nil } -func (r *GeminiClusterReconciler) setControllerReference( - owner *opengeminiv1.GeminiCluster, controlled client.Object, +func (r *OpenGeminiClusterReconciler) setControllerReference( + owner *opengeminiv1.OpenGeminiCluster, controlled client.Object, ) error { return r.Controller.SetControllerReference(owner, controlled, r.Client.Scheme()) //return controllerutil.SetControllerReference(owner, controlled, r.Client.Scheme()) } -// func (r *GeminiClusterReconciler) setOwnerReference( -// owner *opengeminiv1.GeminiCluster, controlled client.Object, +// func (r *OpenGeminiClusterReconciler) setOwnerReference( +// owner *opengeminiv1.OpenGeminiCluster, controlled client.Object, // ) error { // return controllerutil.SetOwnerReference(owner, controlled, r.Client.Scheme()) // } @@ -478,9 +478,9 @@ func IsOwnedByCluster(obj client.Object) (string, bool) { // +kubebuilder:rbac:groups="apps",resources="statefulsets",verbs={get,list,watch} // SetupWithManager sets up the controller with the Manager. -func (r *GeminiClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { +func (r *OpenGeminiClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). - For(&opengeminiv1.GeminiCluster{}). + For(&opengeminiv1.OpenGeminiCluster{}). Owns(&corev1.ConfigMap{}). Owns(&corev1.Service{}). Owns(&corev1.Secret{}). diff --git a/controllers/geminicluster_controller_test.go b/controllers/opengeminicluster_controller_test.go similarity index 94% rename from controllers/geminicluster_controller_test.go rename to controllers/opengeminicluster_controller_test.go index e880368..8a41e1e 100644 --- a/controllers/geminicluster_controller_test.go +++ b/controllers/opengeminicluster_controller_test.go @@ -64,15 +64,15 @@ func (MockK8sController) SetControllerReference(owner, controlled metav1.Object, } func Test_ReconcileClusterConfigMap(t *testing.T) { - var r = &GeminiClusterReconciler{ + var r = &OpenGeminiClusterReconciler{ Client: &MockK8sClient{}, Controller: &MockK8sController{}, } var metaReplicas int32 = 3 - cluster := &opengeminiv1.GeminiCluster{ - Spec: opengeminiv1.GeminiClusterSpec{ + cluster := &opengeminiv1.OpenGeminiCluster{ + Spec: opengeminiv1.OpenGeminiClusterSpec{ Meta: opengeminiv1.MetaSpec{ Replicas: &metaReplicas, }, diff --git a/main.go b/main.go index d4e6946..066f599 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - opengeminioperatorv1 "github.com/openGemini/openGemini-operator/api/v1" + opengeminiv1 "github.com/openGemini/openGemini-operator/api/v1" "github.com/openGemini/openGemini-operator/controllers" ) @@ -42,7 +42,7 @@ var ( func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) - utilruntime.Must(opengeminioperatorv1.AddToScheme(scheme)) + utilruntime.Must(opengeminiv1.AddToScheme(scheme)) //+kubebuilder:scaffold:scheme } @@ -93,14 +93,14 @@ func main() { os.Exit(1) } - if err = (&controllers.GeminiClusterReconciler{ + if err = (&controllers.OpenGeminiClusterReconciler{ Client: mgr.GetClient(), Owner: controllers.ControllerManagerName, Scheme: mgr.GetScheme(), Controller: &k8sController{}, }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "GeminiCluster") + setupLog.Error(err, "unable to create controller", "controller", "OpenGeminiCluster") os.Exit(1) } //+kubebuilder:scaffold:builder diff --git a/pkg/configfile/configfile.go b/pkg/configfile/configfile.go index 528eca1..2d53b84 100644 --- a/pkg/configfile/configfile.go +++ b/pkg/configfile/configfile.go @@ -58,7 +58,7 @@ type GossipConfig struct { Members []string `toml:"members"` } -func NewBaseConfiguration(cluster *opengeminiv1.GeminiCluster) (string, error) { +func NewBaseConfiguration(cluster *opengeminiv1.OpenGeminiCluster) (string, error) { metaJoinAddrs := []string{} metaGossipAddrs := []string{} for i := 0; i < int(*cluster.Spec.Meta.Replicas); i++ { diff --git a/pkg/naming/names.go b/pkg/naming/names.go index da7c466..874d8f0 100644 --- a/pkg/naming/names.go +++ b/pkg/naming/names.go @@ -33,7 +33,7 @@ const ( FQDNLayout = "%s.%s.%s.svc.%s" // pod-hostname.headless-service-name.namespace.svc.cluster.local ) -func ClusterConfigMap(cluster *opengeminiv1.GeminiCluster) metav1.ObjectMeta { +func ClusterConfigMap(cluster *opengeminiv1.OpenGeminiCluster) metav1.ObjectMeta { return metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: cluster.Name + "-config", @@ -48,21 +48,21 @@ func EntrypointFilePath() string { return path.Join(ConfigMountPath, EntrypointFile) } -func GenerateMetaInstance(cluster *opengeminiv1.GeminiCluster, index int) metav1.ObjectMeta { +func GenerateMetaInstance(cluster *opengeminiv1.OpenGeminiCluster, index int) metav1.ObjectMeta { return metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: cluster.Name + "-" + "meta" + "-" + fmt.Sprintf("%d", index), } } -func GenerateStoreInstance(cluster *opengeminiv1.GeminiCluster, index int) metav1.ObjectMeta { +func GenerateStoreInstance(cluster *opengeminiv1.OpenGeminiCluster, index int) metav1.ObjectMeta { return metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: cluster.Name + "-" + "store" + "-" + fmt.Sprintf("%d", index), } } -func GenerateSqlInstance(cluster *opengeminiv1.GeminiCluster, index int) metav1.ObjectMeta { +func GenerateSqlInstance(cluster *opengeminiv1.OpenGeminiCluster, index int) metav1.ObjectMeta { return metav1.ObjectMeta{ Namespace: cluster.Namespace, Name: cluster.Name + "-" + "sql" + "-" + fmt.Sprintf("%d", index), @@ -80,7 +80,7 @@ func GenerateInstanceFQDN(instanceName, namespace string) string { } func GeneratePVC( - cluster *opengeminiv1.GeminiCluster, + cluster *opengeminiv1.OpenGeminiCluster, instance *appsv1.StatefulSet, ) metav1.ObjectMeta { return metav1.ObjectMeta{ diff --git a/pkg/opengemini/meta/meta.go b/pkg/opengemini/meta/meta.go index cc83a59..e185351 100644 --- a/pkg/opengemini/meta/meta.go +++ b/pkg/opengemini/meta/meta.go @@ -28,7 +28,7 @@ func ConfigVolumeMount() corev1.VolumeMount { func InstancePod( ctx context.Context, - inCluster *opengeminiv1.GeminiCluster, + inCluster *opengeminiv1.OpenGeminiCluster, inDataVolumeName, inInstanceName string, outInstancePod *corev1.PodSpec, ) { diff --git a/pkg/opengemini/sql/sql.go b/pkg/opengemini/sql/sql.go index 1a6f0a0..93280b5 100644 --- a/pkg/opengemini/sql/sql.go +++ b/pkg/opengemini/sql/sql.go @@ -28,7 +28,7 @@ func ConfigVolumeMount() corev1.VolumeMount { func InstancePod( ctx context.Context, - inCluster *opengeminiv1.GeminiCluster, + inCluster *opengeminiv1.OpenGeminiCluster, inInstanceName string, outInstancePod *corev1.PodSpec, ) { diff --git a/pkg/opengemini/store/store.go b/pkg/opengemini/store/store.go index 1811396..3f1d847 100644 --- a/pkg/opengemini/store/store.go +++ b/pkg/opengemini/store/store.go @@ -28,7 +28,7 @@ func ConfigVolumeMount() corev1.VolumeMount { func InstancePod( ctx context.Context, - inCluster *opengeminiv1.GeminiCluster, + inCluster *opengeminiv1.OpenGeminiCluster, inDataVolumeName, inInstanceName string, outInstancePod *corev1.PodSpec, ) { diff --git a/pkg/specs/service.go b/pkg/specs/service.go index b74e38b..269ffff 100644 --- a/pkg/specs/service.go +++ b/pkg/specs/service.go @@ -11,7 +11,7 @@ import ( "github.com/openGemini/openGemini-operator/pkg/utils" ) -func CreateClusterMaintainService(cluster *opengeminiv1.GeminiCluster) *corev1.Service { +func CreateClusterMaintainService(cluster *opengeminiv1.OpenGeminiCluster) *corev1.Service { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: cluster.GetServiceMaintainName(), @@ -34,7 +34,7 @@ func CreateClusterMaintainService(cluster *opengeminiv1.GeminiCluster) *corev1.S } } -func CreateClusterReadWriteService(cluster *opengeminiv1.GeminiCluster) *corev1.Service { +func CreateClusterReadWriteService(cluster *opengeminiv1.OpenGeminiCluster) *corev1.Service { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: cluster.GetServiceReadWriteName(), @@ -57,7 +57,7 @@ func CreateClusterReadWriteService(cluster *opengeminiv1.GeminiCluster) *corev1. } } -func instanceHeadlessService(cluster *opengeminiv1.GeminiCluster, instanceName, instanceSet string) *corev1.Service { +func instanceHeadlessService(cluster *opengeminiv1.OpenGeminiCluster, instanceName, instanceSet string) *corev1.Service { return &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: instanceName, @@ -77,7 +77,7 @@ func instanceHeadlessService(cluster *opengeminiv1.GeminiCluster, instanceName, } } -func CreateInstanceHeadlessServices(cluster *opengeminiv1.GeminiCluster) []*corev1.Service { +func CreateInstanceHeadlessServices(cluster *opengeminiv1.OpenGeminiCluster) []*corev1.Service { svcs := []*corev1.Service{} for i := 0; i < int(*cluster.Spec.Meta.Replicas); i++ { metaInstanceName := naming.GenerateMetaInstance(cluster, i).Name