From 66087615bf0a6fa93c97fe6c881475dd33875c8d Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Tue, 26 Mar 2024 15:55:05 +0800 Subject: [PATCH] Rename MeshConfig to BackendConfig --- ...l_mesh.yaml => global_backend_config.yaml} | 4 +- .../mesh-config-kube-system.yaml | 4 +- .../mesh-config.yaml | 4 +- .ci/tests/integration/e2e_with_tls.yaml | 4 +- ...config_types.go => backendconfig_types.go} | 24 +-- api/compute/v1alpha1/function_types.go | 12 +- api/compute/v1alpha1/sink_types.go | 12 +- api/compute/v1alpha1/source_types.go | 12 +- api/compute/v1alpha1/zz_generated.deepcopy.go | 192 +++++++++--------- ...mpute.functionmesh.io-backendconfigs.yaml} | 10 +- ...crd-compute.functionmesh.io-functions.yaml | 4 +- .../crd-compute.functionmesh.io-sinks.yaml | 4 +- .../crd-compute.functionmesh.io-sources.yaml | 4 +- .../controller-manager-deployment.yaml | 6 +- .../templates/controller-manager-rbac.yaml | 4 +- charts/function-mesh-operator/values.yaml | 6 +- ...mpute.functionmesh.io_backendconfigs.yaml} | 10 +- .../compute.functionmesh.io_functions.yaml | 4 +- .../bases/compute.functionmesh.io_sinks.yaml | 4 +- .../compute.functionmesh.io_sources.yaml | 4 +- config/crd/kustomization.yaml | 6 +- ...aml => cainjection_in_backendconfigs.yaml} | 2 +- ...gs.yaml => webhook_in_backendconfigs.yaml} | 2 +- config/default/manager_auth_proxy_patch.yaml | 2 +- config/manager/manager.yaml | 2 +- ...le.yaml => backendconfig_editor_role.yaml} | 6 +- ...le.yaml => backendconfig_viewer_role.yaml} | 6 +- config/rbac/role.yaml | 24 +-- controllers/function_controller.go | 8 +- controllers/sink_controller.go | 8 +- controllers/source_controller.go | 8 +- controllers/spec/common.go | 35 ++-- controllers/spec/function.go | 10 +- controllers/spec/sink.go | 10 +- controllers/spec/source.go | 10 +- hack/gen-helm-crd-templates.sh | 6 +- main.go | 24 +-- manifests/crd.yaml | 132 ++++++------ manifests/rbac.yaml | 24 +-- utils/configs.go | 6 +- 40 files changed, 329 insertions(+), 330 deletions(-) rename .ci/clusters/{global_mesh.yaml => global_backend_config.yaml} (70%) rename api/compute/v1alpha1/{meshconfig_types.go => backendconfig_types.go} (75%) rename charts/function-mesh-operator/charts/admission-webhook/templates/{crd-compute.functionmesh.io-meshconfigs.yaml => crd-compute.functionmesh.io-backendconfigs.yaml} (92%) rename config/crd/bases/{compute.functionmesh.io_meshconfigs.yaml => compute.functionmesh.io_backendconfigs.yaml} (86%) rename config/crd/patches/{cainjection_in_meshconfigs.yaml => cainjection_in_backendconfigs.yaml} (86%) rename config/crd/patches/{webhook_in_meshconfigs.yaml => webhook_in_backendconfigs.yaml} (94%) rename config/rbac/{meshconfig_editor_role.yaml => backendconfig_editor_role.yaml} (81%) rename config/rbac/{meshconfig_viewer_role.yaml => backendconfig_viewer_role.yaml} (78%) diff --git a/.ci/clusters/global_mesh.yaml b/.ci/clusters/global_backend_config.yaml similarity index 70% rename from .ci/clusters/global_mesh.yaml rename to .ci/clusters/global_backend_config.yaml index d3a771cc..f55d06dc 100644 --- a/.ci/clusters/global_mesh.yaml +++ b/.ci/clusters/global_backend_config.yaml @@ -1,7 +1,7 @@ apiVersion: compute.functionmesh.io/v1alpha1 -kind: MeshConfig +kind: BackendConfig metadata: - name: mesh-global + name: global-backend-config spec: env: global1: globalvalue1 diff --git a/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml b/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml index 298177eb..4398bd10 100644 --- a/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml +++ b/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config-kube-system.yaml @@ -1,7 +1,7 @@ apiVersion: compute.functionmesh.io/v1alpha1 -kind: MeshConfig +kind: BackendConfig metadata: - name: mesh-namespaced + name: backend-config namespace: kube-system spec: env: diff --git a/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml b/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml index 455b15c4..6ef4131a 100644 --- a/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml +++ b/.ci/tests/integration/cases/global-and-namespaced-config/mesh-config.yaml @@ -1,7 +1,7 @@ apiVersion: compute.functionmesh.io/v1alpha1 -kind: MeshConfig +kind: BackendConfig metadata: - name: mesh-namespaced + name: backend-config namespace: default spec: env: diff --git a/.ci/tests/integration/e2e_with_tls.yaml b/.ci/tests/integration/e2e_with_tls.yaml index 7896b5ec..4e470681 100644 --- a/.ci/tests/integration/e2e_with_tls.yaml +++ b/.ci/tests/integration/e2e_with_tls.yaml @@ -87,7 +87,7 @@ setup: image="function-mesh-operator:latest" IMG=${image} make docker-build-skip-test kind load docker-image ${image} - helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --set controllerManager.globalMeshConfig=mesh-global --set controllerManager.globalMeshConfigNamespace=${FUNCTION_MESH_NAMESPACE} --set controllerManager.namespacedMeshConfig=mesh-namespaced --create-namespace charts/function-mesh-operator + helm install ${FUNCTION_MESH_RELEASE_NAME} -n ${FUNCTION_MESH_NAMESPACE} --set operatorImage=${image} --set controllerManager.globalBackendConfig=global-backend-config --set controllerManager.globalBackendConfigNamespace=${FUNCTION_MESH_NAMESPACE} --set controllerManager.namespacedBackendConfig=backend-config --create-namespace charts/function-mesh-operator wait: - namespace: function-mesh resource: pod @@ -96,7 +96,7 @@ setup: - name: apply global env config map command: | - kubectl create -n ${FUNCTION_MESH_NAMESPACE} -f .ci/clusters/global_mesh.yaml + kubectl create -n ${FUNCTION_MESH_NAMESPACE} -f .ci/clusters/global_backend_config.yaml timeout: 60m diff --git a/api/compute/v1alpha1/meshconfig_types.go b/api/compute/v1alpha1/backendconfig_types.go similarity index 75% rename from api/compute/v1alpha1/meshconfig_types.go rename to api/compute/v1alpha1/backendconfig_types.go index e06268b1..a1c21d18 100644 --- a/api/compute/v1alpha1/meshconfig_types.go +++ b/api/compute/v1alpha1/backendconfig_types.go @@ -24,9 +24,9 @@ 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. -// MeshConfigSpec defines the desired state of MeshConfig +// BackendConfigSpec defines the desired state of BackendConfig // +kubebuilder:validation:Optional -type MeshConfigSpec struct { +type BackendConfigSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file Name string `json:"name,omitempty"` @@ -35,8 +35,8 @@ type MeshConfigSpec struct { Env map[string]string `json:"env,omitempty"` } -// MeshConfigStatus defines the observed state of MeshConfig -type MeshConfigStatus struct { +// BackendConfigStatus defines the observed state of BackendConfig +type BackendConfigStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file } @@ -46,25 +46,25 @@ type MeshConfigStatus struct { // +kubebuilder:subresource:status // +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector -// MeshConfig is the Schema of the global configs for all functions, sinks and sources +// BackendConfig is the Schema of the global configs for all functions, sinks and sources // +kubebuilder:pruning:PreserveUnknownFields -type MeshConfig struct { +type BackendConfig struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec MeshConfigSpec `json:"spec,omitempty"` - Status MeshConfigStatus `json:"status,omitempty"` + Spec BackendConfigSpec `json:"spec,omitempty"` + Status BackendConfigStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true -// MeshConfigList contains a list of MeshConfig -type MeshConfigList struct { +// BackendConfigList contains a list of BackendConfig +type BackendConfigList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []MeshConfig `json:"items"` + Items []BackendConfig `json:"items"` } func init() { - SchemeBuilder.Register(&MeshConfig{}, &MeshConfigList{}) + SchemeBuilder.Register(&BackendConfig{}, &BackendConfigList{}) } diff --git a/api/compute/v1alpha1/function_types.go b/api/compute/v1alpha1/function_types.go index 93fcebc9..ae4f74a5 100644 --- a/api/compute/v1alpha1/function_types.go +++ b/api/compute/v1alpha1/function_types.go @@ -119,12 +119,12 @@ type FunctionSpec struct { type FunctionStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file - Conditions map[Component]ResourceCondition `json:"conditions"` - Replicas int32 `json:"replicas"` - Selector string `json:"selector"` - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - GlobalMeshConfigRevision string `json:"globalMeshConfigRevision,omitempty"` - NamespacedMeshConfigRevision string `json:"namespacedMeshConfigRevision,omitempty"` + Conditions map[Component]ResourceCondition `json:"conditions"` + Replicas int32 `json:"replicas"` + Selector string `json:"selector"` + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + GlobalBackendConfigRevision string `json:"globalBackendConfigRevision,omitempty"` + NamespacedBackendConfigRevision string `json:"namespacedBackendConfigRevision,omitempty"` } // +genclient diff --git a/api/compute/v1alpha1/sink_types.go b/api/compute/v1alpha1/sink_types.go index a7e7d46c..91a1fa43 100644 --- a/api/compute/v1alpha1/sink_types.go +++ b/api/compute/v1alpha1/sink_types.go @@ -109,12 +109,12 @@ type SinkSpec struct { type SinkStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file - Conditions map[Component]ResourceCondition `json:"conditions"` - Replicas int32 `json:"replicas"` - Selector string `json:"selector"` - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - GlobalMeshConfigRevision string `json:"globalMeshConfigRevision,omitempty"` - NamespacedMeshConfigRevision string `json:"namespacedMeshConfigRevision,omitempty"` + Conditions map[Component]ResourceCondition `json:"conditions"` + Replicas int32 `json:"replicas"` + Selector string `json:"selector"` + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + GlobalBackendConfigRevision string `json:"globalBackendConfigRevision,omitempty"` + NamespacedBackendConfigRevision string `json:"namespacedBackendConfigRevision,omitempty"` } // +genclient diff --git a/api/compute/v1alpha1/source_types.go b/api/compute/v1alpha1/source_types.go index afab95c8..0293f442 100644 --- a/api/compute/v1alpha1/source_types.go +++ b/api/compute/v1alpha1/source_types.go @@ -114,12 +114,12 @@ type BatchSourceConfig struct { type SourceStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file - Conditions map[Component]ResourceCondition `json:"conditions"` - Replicas int32 `json:"replicas"` - Selector string `json:"selector"` - ObservedGeneration int64 `json:"observedGeneration,omitempty"` - GlobalMeshConfigRevision string `json:"globalMeshConfigRevision,omitempty"` - NamespacedMeshConfigRevision string `json:"namespacedMeshConfigRevision,omitempty"` + Conditions map[Component]ResourceCondition `json:"conditions"` + Replicas int32 `json:"replicas"` + Selector string `json:"selector"` + ObservedGeneration int64 `json:"observedGeneration,omitempty"` + GlobalBackendConfigRevision string `json:"globalBackendConfigRevision,omitempty"` + NamespacedBackendConfigRevision string `json:"namespacedBackendConfigRevision,omitempty"` } // +genclient diff --git a/api/compute/v1alpha1/zz_generated.deepcopy.go b/api/compute/v1alpha1/zz_generated.deepcopy.go index fedfd52c..c8909120 100644 --- a/api/compute/v1alpha1/zz_generated.deepcopy.go +++ b/api/compute/v1alpha1/zz_generated.deepcopy.go @@ -55,6 +55,102 @@ func (in *AuthConfig) DeepCopy() *AuthConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackendConfig) DeepCopyInto(out *BackendConfig) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendConfig. +func (in *BackendConfig) DeepCopy() *BackendConfig { + if in == nil { + return nil + } + out := new(BackendConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BackendConfig) 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 *BackendConfigList) DeepCopyInto(out *BackendConfigList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]BackendConfig, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendConfigList. +func (in *BackendConfigList) DeepCopy() *BackendConfigList { + if in == nil { + return nil + } + out := new(BackendConfigList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *BackendConfigList) 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 *BackendConfigSpec) DeepCopyInto(out *BackendConfigSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *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 BackendConfigSpec. +func (in *BackendConfigSpec) DeepCopy() *BackendConfigSpec { + if in == nil { + return nil + } + out := new(BackendConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BackendConfigStatus) DeepCopyInto(out *BackendConfigStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BackendConfigStatus. +func (in *BackendConfigStatus) DeepCopy() *BackendConfigStatus { + if in == nil { + return nil + } + out := new(BackendConfigStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BatchSourceConfig) DeepCopyInto(out *BatchSourceConfig) { *out = *in @@ -624,102 +720,6 @@ func (in *LogConfig) DeepCopy() *LogConfig { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MeshConfig) DeepCopyInto(out *MeshConfig) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshConfig. -func (in *MeshConfig) DeepCopy() *MeshConfig { - if in == nil { - return nil - } - out := new(MeshConfig) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MeshConfig) 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 *MeshConfigList) DeepCopyInto(out *MeshConfigList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]MeshConfig, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshConfigList. -func (in *MeshConfigList) DeepCopy() *MeshConfigList { - if in == nil { - return nil - } - out := new(MeshConfigList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MeshConfigList) 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 *MeshConfigSpec) DeepCopyInto(out *MeshConfigSpec) { - *out = *in - if in.Env != nil { - in, out := &in.Env, &out.Env - *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 MeshConfigSpec. -func (in *MeshConfigSpec) DeepCopy() *MeshConfigSpec { - if in == nil { - return nil - } - out := new(MeshConfigSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MeshConfigStatus) DeepCopyInto(out *MeshConfigStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshConfigStatus. -func (in *MeshConfigStatus) DeepCopy() *MeshConfigStatus { - if in == nil { - return nil - } - out := new(MeshConfigStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Messaging) DeepCopyInto(out *Messaging) { *out = *in diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-meshconfigs.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml similarity index 92% rename from charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-meshconfigs.yaml rename to charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml index 57c428c8..888cdbde 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-meshconfigs.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-backendconfigs.yaml @@ -7,7 +7,7 @@ metadata: {{- include "function-mesh-operator.certManager.annotation" . | nindent 4 -}} {{- end }} controller-gen.kubebuilder.io/version: v0.9.2 - name: meshconfigs.compute.functionmesh.io + name: backendconfigs.compute.functionmesh.io spec: conversion: strategy: Webhook @@ -30,10 +30,10 @@ spec: - v1beta1 group: compute.functionmesh.io names: - kind: MeshConfig - listKind: MeshConfigList - plural: meshconfigs - singular: meshconfig + kind: BackendConfig + listKind: BackendConfigList + plural: backendconfigs + singular: backendconfig scope: Namespaced versions: - name: v1alpha1 diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml index 60c7cd91..f8aa5cbc 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-functions.yaml @@ -3644,9 +3644,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml index c8ae2160..21294ce9 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sinks.yaml @@ -3380,9 +3380,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml index c80d1299..b050a129 100644 --- a/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml +++ b/charts/function-mesh-operator/charts/admission-webhook/templates/crd-compute.functionmesh.io-sources.yaml @@ -3361,9 +3361,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/charts/function-mesh-operator/templates/controller-manager-deployment.yaml b/charts/function-mesh-operator/templates/controller-manager-deployment.yaml index 0a1f58a6..85361789 100644 --- a/charts/function-mesh-operator/templates/controller-manager-deployment.yaml +++ b/charts/function-mesh-operator/templates/controller-manager-deployment.yaml @@ -62,9 +62,9 @@ spec: - --pprof-addr=:{{ .Values.controllerManager.pprof.port }} - --config-file={{ .Values.controllerManager.configFile }} - --enable-init-containers={{ .Values.controllerManager.enableInitContainers }} - - --global-mesh-config={{ .Values.controllerManager.globalMeshConfig }} - - --global-mesh-config-namespace={{ .Values.controllerManager.globalMeshConfigNamespace }} - - --namespaced-mesh-config={{ .Values.controllerManager.namespacedMeshConfig }} + - --global-backend-config={{ .Values.controllerManager.globalBackendConfig }} + - --global-backend-config-namespace={{ .Values.controllerManager.globalBackendConfigNamespace }} + - --namespaced-backend-config={{ .Values.controllerManager.namespacedBackendConfig }} env: - name: NAMESPACE valueFrom: diff --git a/charts/function-mesh-operator/templates/controller-manager-rbac.yaml b/charts/function-mesh-operator/templates/controller-manager-rbac.yaml index d7c0d60f..4034fcc6 100644 --- a/charts/function-mesh-operator/templates/controller-manager-rbac.yaml +++ b/charts/function-mesh-operator/templates/controller-manager-rbac.yaml @@ -143,7 +143,7 @@ rules: - apiGroups: - compute.functionmesh.io resources: - - meshconfigs + - backendconfigs verbs: - create - delete @@ -155,7 +155,7 @@ rules: - apiGroups: - compute.functionmesh.io resources: - - meshconfigs/status + - backendconfigs/status verbs: - get - patch diff --git a/charts/function-mesh-operator/values.yaml b/charts/function-mesh-operator/values.yaml index 7e91d411..bf560a2a 100644 --- a/charts/function-mesh-operator/values.yaml +++ b/charts/function-mesh-operator/values.yaml @@ -70,9 +70,9 @@ controllerManager: enable: false port: 8090 enableInitContainers: false - globalMeshConfig: global-mesh-config - globalMeshConfigNamespace: default - namespacedMeshConfig: mesh-config + globalBackendConfig: global-backend-config + globalBackendConfigNamespace: default + namespacedBackendConfig: backend-config admissionWebhook: enabled: true diff --git a/config/crd/bases/compute.functionmesh.io_meshconfigs.yaml b/config/crd/bases/compute.functionmesh.io_backendconfigs.yaml similarity index 86% rename from config/crd/bases/compute.functionmesh.io_meshconfigs.yaml rename to config/crd/bases/compute.functionmesh.io_backendconfigs.yaml index 1282f22c..68b0d271 100644 --- a/config/crd/bases/compute.functionmesh.io_meshconfigs.yaml +++ b/config/crd/bases/compute.functionmesh.io_backendconfigs.yaml @@ -5,14 +5,14 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.2 creationTimestamp: null - name: meshconfigs.compute.functionmesh.io + name: backendconfigs.compute.functionmesh.io spec: group: compute.functionmesh.io names: - kind: MeshConfig - listKind: MeshConfigList - plural: meshconfigs - singular: meshconfig + kind: BackendConfig + listKind: BackendConfigList + plural: backendconfigs + singular: backendconfig scope: Namespaced versions: - name: v1alpha1 diff --git a/config/crd/bases/compute.functionmesh.io_functions.yaml b/config/crd/bases/compute.functionmesh.io_functions.yaml index 76ec8853..07b4ca0f 100644 --- a/config/crd/bases/compute.functionmesh.io_functions.yaml +++ b/config/crd/bases/compute.functionmesh.io_functions.yaml @@ -3623,9 +3623,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/config/crd/bases/compute.functionmesh.io_sinks.yaml b/config/crd/bases/compute.functionmesh.io_sinks.yaml index 78a78eea..98482607 100644 --- a/config/crd/bases/compute.functionmesh.io_sinks.yaml +++ b/config/crd/bases/compute.functionmesh.io_sinks.yaml @@ -3359,9 +3359,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/config/crd/bases/compute.functionmesh.io_sources.yaml b/config/crd/bases/compute.functionmesh.io_sources.yaml index a42f1490..028ddf78 100644 --- a/config/crd/bases/compute.functionmesh.io_sources.yaml +++ b/config/crd/bases/compute.functionmesh.io_sources.yaml @@ -3340,9 +3340,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/config/crd/kustomization.yaml b/config/crd/kustomization.yaml index da0440ba..0af2ec9e 100644 --- a/config/crd/kustomization.yaml +++ b/config/crd/kustomization.yaml @@ -6,7 +6,7 @@ resources: - bases/compute.functionmesh.io_functions.yaml - bases/compute.functionmesh.io_sources.yaml - bases/compute.functionmesh.io_sinks.yaml -- bases/compute.functionmesh.io_meshconfigs.yaml +- bases/compute.functionmesh.io_backendconfigs.yaml # +kubebuilder:scaffold:crdkustomizeresource patchesStrategicMerge: @@ -16,7 +16,7 @@ patchesStrategicMerge: - patches/webhook_in_functions.yaml - patches/webhook_in_sources.yaml - patches/webhook_in_sinks.yaml -- patches/webhook_in_meshconfigs.yaml +- patches/webhook_in_backendconfigs.yaml # +kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix. @@ -25,7 +25,7 @@ patchesStrategicMerge: - patches/cainjection_in_functions.yaml - patches/cainjection_in_sources.yaml - patches/cainjection_in_sinks.yaml -- patches/cainjection_in_meshconfigs.yaml +- patches/cainjection_in_backendconfigs.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_meshconfigs.yaml b/config/crd/patches/cainjection_in_backendconfigs.yaml similarity index 86% rename from config/crd/patches/cainjection_in_meshconfigs.yaml rename to config/crd/patches/cainjection_in_backendconfigs.yaml index 907a344b..491d7f20 100644 --- a/config/crd/patches/cainjection_in_meshconfigs.yaml +++ b/config/crd/patches/cainjection_in_backendconfigs.yaml @@ -5,4 +5,4 @@ kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - name: meshconfigs.compute.functionmesh.io + name: backendconfigs.compute.functionmesh.io diff --git a/config/crd/patches/webhook_in_meshconfigs.yaml b/config/crd/patches/webhook_in_backendconfigs.yaml similarity index 94% rename from config/crd/patches/webhook_in_meshconfigs.yaml rename to config/crd/patches/webhook_in_backendconfigs.yaml index c4a8ee35..ad1d517a 100644 --- a/config/crd/patches/webhook_in_meshconfigs.yaml +++ b/config/crd/patches/webhook_in_backendconfigs.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: meshconfigs.compute.functionmesh.io + name: backendconfigs.compute.functionmesh.io spec: conversion: strategy: Webhook diff --git a/config/default/manager_auth_proxy_patch.yaml b/config/default/manager_auth_proxy_patch.yaml index 0e264827..99578019 100644 --- a/config/default/manager_auth_proxy_patch.yaml +++ b/config/default/manager_auth_proxy_patch.yaml @@ -30,4 +30,4 @@ spec: args: - "--metrics-addr=127.0.0.1:8080" - "--enable-leader-election" - - "--namespaced-mesh-config=mesh-config" + - "--namespaced-backend-config=backend-config" diff --git a/config/manager/manager.yaml b/config/manager/manager.yaml index 631bb8c2..d3e38b59 100644 --- a/config/manager/manager.yaml +++ b/config/manager/manager.yaml @@ -33,7 +33,7 @@ spec: - /manager args: - --enable-leader-election - - --namespaced-mesh-config=mesh-config + - --namespaced-backend-config=backend-config image: controller:latest name: manager resources: diff --git a/config/rbac/meshconfig_editor_role.yaml b/config/rbac/backendconfig_editor_role.yaml similarity index 81% rename from config/rbac/meshconfig_editor_role.yaml rename to config/rbac/backendconfig_editor_role.yaml index d7b4ee19..b30613b5 100644 --- a/config/rbac/meshconfig_editor_role.yaml +++ b/config/rbac/backendconfig_editor_role.yaml @@ -2,12 +2,12 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: meshconfig-editor-role + name: backendconfig-editor-role rules: - apiGroups: - compute.functionmesh.io resources: - - meshconfigs + - backendconfigs verbs: - create - delete @@ -19,6 +19,6 @@ rules: - apiGroups: - compute.functionmesh.io resources: - - meshconfigs/status + - backendconfigs/status verbs: - get diff --git a/config/rbac/meshconfig_viewer_role.yaml b/config/rbac/backendconfig_viewer_role.yaml similarity index 78% rename from config/rbac/meshconfig_viewer_role.yaml rename to config/rbac/backendconfig_viewer_role.yaml index 53114546..7db4c942 100644 --- a/config/rbac/meshconfig_viewer_role.yaml +++ b/config/rbac/backendconfig_viewer_role.yaml @@ -2,12 +2,12 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: meshconfig-viewer-role + name: backendconfig-viewer-role rules: - apiGroups: - compute.functionmesh.io resources: - - meshconfigs + - backendconfigs verbs: - get - list @@ -15,6 +15,6 @@ rules: - apiGroups: - compute.functionmesh.io resources: - - meshconfigs/status + - backendconfigs/status verbs: - get diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 03a1b896..7ba2a273 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -52,6 +52,18 @@ rules: - list - update - watch +- apiGroups: + - compute.functionmesh.io + resources: + - backendconfigs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - compute.functionmesh.io resources: @@ -99,18 +111,6 @@ rules: - get - patch - update -- apiGroups: - - compute.functionmesh.io - resources: - - meshconfigs - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - compute.functionmesh.io resources: diff --git a/controllers/function_controller.go b/controllers/function_controller.go index 5eb6fd42..f3a6e5ea 100644 --- a/controllers/function_controller.go +++ b/controllers/function_controller.go @@ -58,7 +58,7 @@ type FunctionReconciler struct { // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=functions,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=functions/status,verbs=get;update;patch // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=functions/finalizers,verbs=get;update -// +kubebuilder:rbac:groups=compute.functionmesh.io,resources=meshconfigs,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=compute.functionmesh.io,resources=backendconfigs,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete // +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete @@ -188,9 +188,9 @@ func (r *FunctionReconciler) SetupWithManager(mgr ctrl.Manager) error { Owns(&corev1.Secret{}). Owns(&v1.Job{}) - manager.Watches(&source.Kind{Type: &v1alpha1.MeshConfig{}}, handler.EnqueueRequestsFromMapFunc( + manager.Watches(&source.Kind{Type: &v1alpha1.BackendConfig{}}, handler.EnqueueRequestsFromMapFunc( func(object client.Object) []reconcile.Request { - if object.GetName() == utils.GlobalMeshConfig && object.GetNamespace() == utils.GlobalMeshConfigNamespace { + if object.GetName() == utils.GlobalBackendConfig && object.GetNamespace() == utils.GlobalBackendConfigNamespace { ctx := context.Background() functions := &v1alpha1.FunctionList{} err := mgr.GetClient().List(ctx, functions) @@ -204,7 +204,7 @@ func (r *FunctionReconciler) SetupWithManager(mgr ctrl.Manager) error { }) } return requests - } else if object.GetName() == utils.NamespacedMeshConfig { + } else if object.GetName() == utils.NamespacedBackendConfig { ctx := context.Background() functions := &v1alpha1.FunctionList{} err := mgr.GetClient().List(ctx, functions, client.InNamespace(object.GetNamespace())) diff --git a/controllers/sink_controller.go b/controllers/sink_controller.go index 2944c5e6..1c30f9f7 100644 --- a/controllers/sink_controller.go +++ b/controllers/sink_controller.go @@ -58,7 +58,7 @@ type SinkReconciler struct { // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=sinks,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=sinks/status,verbs=get;update;patch // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=sinks/finalizers,verbs=get;update -// +kubebuilder:rbac:groups=compute.functionmesh.io,resources=meshconfigs,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=compute.functionmesh.io,resources=backendconfigs,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete // +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete @@ -193,9 +193,9 @@ func (r *SinkReconciler) SetupWithManager(mgr ctrl.Manager) error { AddControllerBuilderOwn(manager, r.GroupVersionFlags.APIAutoscalingGroupVersion) } - manager.Watches(&source.Kind{Type: &v1alpha1.MeshConfig{}}, handler.EnqueueRequestsFromMapFunc( + manager.Watches(&source.Kind{Type: &v1alpha1.BackendConfig{}}, handler.EnqueueRequestsFromMapFunc( func(object client.Object) []reconcile.Request { - if object.GetName() == utils.GlobalMeshConfig && object.GetNamespace() == utils.GlobalMeshConfigNamespace { + if object.GetName() == utils.GlobalBackendConfig && object.GetNamespace() == utils.GlobalBackendConfigNamespace { ctx := context.Background() sinks := &v1alpha1.SinkList{} err := mgr.GetClient().List(ctx, sinks) @@ -209,7 +209,7 @@ func (r *SinkReconciler) SetupWithManager(mgr ctrl.Manager) error { }) } return requests - } else if object.GetName() == utils.NamespacedMeshConfig { + } else if object.GetName() == utils.NamespacedBackendConfig { ctx := context.Background() sinks := &v1alpha1.SinkList{} err := mgr.GetClient().List(ctx, sinks, client.InNamespace(object.GetNamespace())) diff --git a/controllers/source_controller.go b/controllers/source_controller.go index 89738bef..2fee4b0a 100644 --- a/controllers/source_controller.go +++ b/controllers/source_controller.go @@ -57,7 +57,7 @@ type SourceReconciler struct { // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=sources,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=sources/status,verbs=get;update;patch // +kubebuilder:rbac:groups=compute.functionmesh.io,resources=sources/finalizers,verbs=get;update -// +kubebuilder:rbac:groups=compute.functionmesh.io,resources=meshconfigs,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=compute.functionmesh.io,resources=backendconfigs,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=apps,resources=statefulsets,verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups=batch,resources=jobs,verbs=get;list;watch;create;update;delete // +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;watch;create;update;patch;delete @@ -191,9 +191,9 @@ func (r *SourceReconciler) SetupWithManager(mgr ctrl.Manager) error { if r.GroupVersionFlags != nil && r.GroupVersionFlags.APIAutoscalingGroupVersion != "" { AddControllerBuilderOwn(manager, r.GroupVersionFlags.APIAutoscalingGroupVersion) } - manager.Watches(&k8ssource.Kind{Type: &v1alpha1.MeshConfig{}}, handler.EnqueueRequestsFromMapFunc( + manager.Watches(&k8ssource.Kind{Type: &v1alpha1.BackendConfig{}}, handler.EnqueueRequestsFromMapFunc( func(object client.Object) []reconcile.Request { - if object.GetName() == utils.GlobalMeshConfig && object.GetNamespace() == utils.GlobalMeshConfigNamespace { + if object.GetName() == utils.GlobalBackendConfig && object.GetNamespace() == utils.GlobalBackendConfigNamespace { ctx := context.Background() sources := &v1alpha1.SourceList{} err := mgr.GetClient().List(ctx, sources) @@ -207,7 +207,7 @@ func (r *SourceReconciler) SetupWithManager(mgr ctrl.Manager) error { }) } return requests - } else if object.GetName() == utils.NamespacedMeshConfig { + } else if object.GetName() == utils.NamespacedBackendConfig { ctx := context.Background() sources := &v1alpha1.SourceList{} err := mgr.GetClient().List(ctx, sources, client.InNamespace(object.GetNamespace())) diff --git a/controllers/spec/common.go b/controllers/spec/common.go index 8e0a4a0b..43fe45ac 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -20,7 +20,6 @@ package spec import ( "bytes" "context" - // used for template _ "embed" "encoding/json" @@ -281,44 +280,44 @@ func MakeStatefulSet(objectMeta *metav1.ObjectMeta, replicas *int32, downloaderI // PatchStatefulSet Apply global and namespaced configs to StatefulSet func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string, statefulSet *appsv1.StatefulSet) (string, string, error) { - globalMeshConfigVersion := "" - namespacedMeshConfigVersion := "" + globalBackendConfigVersion := "" + namespacedBackendConfigVersion := "" envData := make(map[string]string) - if utils.GlobalMeshConfig != "" && utils.GlobalMeshConfigNamespace != "" { - globalMeshConfig := &v1alpha1.MeshConfig{} + if utils.GlobalBackendConfig != "" && utils.GlobalBackendConfigNamespace != "" { + globalBackendConfig := &v1alpha1.BackendConfig{} err := cli.Get(ctx, types.NamespacedName{ - Namespace: utils.GlobalMeshConfigNamespace, - Name: utils.GlobalMeshConfig, - }, globalMeshConfig) + Namespace: utils.GlobalBackendConfigNamespace, + Name: utils.GlobalBackendConfig, + }, globalBackendConfig) if err != nil { // ignore not found error if !k8serrors.IsNotFound(err) { return "", "", err } } else { - globalMeshConfigVersion = globalMeshConfig.ResourceVersion - for key, val := range globalMeshConfig.Spec.Env { + globalBackendConfigVersion = globalBackendConfig.ResourceVersion + for key, val := range globalBackendConfig.Spec.Env { envData[key] = val } } } // patch namespaced configs - if utils.NamespacedMeshConfig != "" { - namespacedMeshConfig := &v1alpha1.MeshConfig{} + if utils.NamespacedBackendConfig != "" { + namespacedBackendConfig := &v1alpha1.BackendConfig{} err := cli.Get(ctx, types.NamespacedName{ Namespace: namespace, - Name: utils.NamespacedMeshConfig, - }, namespacedMeshConfig) + Name: utils.NamespacedBackendConfig, + }, namespacedBackendConfig) if err != nil { // ignore not found error if !k8serrors.IsNotFound(err) { return "", "", err } } else { - namespacedMeshConfigVersion = namespacedMeshConfig.ResourceVersion - for key, val := range namespacedMeshConfig.Spec.Env { + namespacedBackendConfigVersion = namespacedBackendConfig.ResourceVersion + for key, val := range namespacedBackendConfig.Spec.Env { envData[key] = val } } @@ -326,7 +325,7 @@ func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string, // merge env if len(envData) == 0 { - return globalMeshConfigVersion, namespacedMeshConfigVersion, nil + return globalBackendConfigVersion, namespacedBackendConfigVersion, nil } globalEnvs := make([]corev1.EnvVar, 0, len(envData)) for key, val := range envData { @@ -340,7 +339,7 @@ func PatchStatefulSet(ctx context.Context, cli client.Client, namespace string, globalEnvs...) } - return globalMeshConfigVersion, namespacedMeshConfigVersion, nil + return globalBackendConfigVersion, namespacedBackendConfigVersion, nil } func MakeStatefulSetSpec(replicas *int32, container *corev1.Container, filebeatContainer *corev1.Container, diff --git a/controllers/spec/function.go b/controllers/spec/function.go index 02def19e..65bfded8 100644 --- a/controllers/spec/function.go +++ b/controllers/spec/function.go @@ -70,15 +70,15 @@ func MakeFunctionStatefulSet(ctx context.Context, cli client.Client, function *v function.Spec.VolumeMounts, function.Spec.VolumeClaimTemplates, function.Spec.PersistentVolumeClaimRetentionPolicy) - globalMeshConfigVersion, namespacedMeshConfigVersion, err := PatchStatefulSet(ctx, cli, function.Namespace, statefulSet) + globalBackendConfigVersion, namespacedBackendConfigVersion, err := PatchStatefulSet(ctx, cli, function.Namespace, statefulSet) if err != nil { return nil, err } - if globalMeshConfigVersion != "" { - function.Status.GlobalMeshConfigRevision = globalMeshConfigVersion + if globalBackendConfigVersion != "" { + function.Status.GlobalBackendConfigRevision = globalBackendConfigVersion } - if namespacedMeshConfigVersion != "" { - function.Status.NamespacedMeshConfigRevision = namespacedMeshConfigVersion + if namespacedBackendConfigVersion != "" { + function.Status.NamespacedBackendConfigRevision = namespacedBackendConfigVersion } return statefulSet, nil diff --git a/controllers/spec/sink.go b/controllers/spec/sink.go index f5d6204b..321f9ecd 100644 --- a/controllers/spec/sink.go +++ b/controllers/spec/sink.go @@ -64,15 +64,15 @@ func MakeSinkStatefulSet(ctx context.Context, cli client.Client, sink *v1alpha1. makeSinkVolumes(sink, sink.Spec.Pulsar.AuthConfig), makeSinkLabels(sink), sink.Spec.Pod, *sink.Spec.Pulsar, sink.Spec.Java, sink.Spec.Python, sink.Spec.Golang, sink.Spec.VolumeMounts, nil, nil) - globalMeshConfigVersion, namespacedMeshConfigVersion, err := PatchStatefulSet(ctx, cli, sink.Namespace, statefulSet) + globalBackendConfigVersion, namespacedBackendConfigVersion, err := PatchStatefulSet(ctx, cli, sink.Namespace, statefulSet) if err != nil { return nil, err } - if globalMeshConfigVersion != "" { - sink.Status.GlobalMeshConfigRevision = globalMeshConfigVersion + if globalBackendConfigVersion != "" { + sink.Status.GlobalBackendConfigRevision = globalBackendConfigVersion } - if namespacedMeshConfigVersion != "" { - sink.Status.NamespacedMeshConfigRevision = namespacedMeshConfigVersion + if namespacedBackendConfigVersion != "" { + sink.Status.NamespacedBackendConfigRevision = namespacedBackendConfigVersion } return statefulSet, nil diff --git a/controllers/spec/source.go b/controllers/spec/source.go index a0289df7..d077cb2a 100644 --- a/controllers/spec/source.go +++ b/controllers/spec/source.go @@ -65,15 +65,15 @@ func MakeSourceStatefulSet(ctx context.Context, cli client.Client, source *v1alp makeSourceVolumes(source, source.Spec.Pulsar.AuthConfig), makeSourceLabels(source), source.Spec.Pod, *source.Spec.Pulsar, source.Spec.Java, source.Spec.Python, source.Spec.Golang, source.Spec.VolumeMounts, nil, nil) - globalMeshConfigVersion, namespacedMeshConfigVersion, err := PatchStatefulSet(ctx, cli, source.Namespace, statefulSet) + globalBackendConfigVersion, namespacedBackendConfigVersion, err := PatchStatefulSet(ctx, cli, source.Namespace, statefulSet) if err != nil { return nil, err } - if globalMeshConfigVersion != "" { - source.Status.GlobalMeshConfigRevision = globalMeshConfigVersion + if globalBackendConfigVersion != "" { + source.Status.GlobalBackendConfigRevision = globalBackendConfigVersion } - if namespacedMeshConfigVersion != "" { - source.Status.NamespacedMeshConfigRevision = namespacedMeshConfigVersion + if namespacedBackendConfigVersion != "" { + source.Status.NamespacedBackendConfigRevision = namespacedBackendConfigVersion } return statefulSet, nil diff --git a/hack/gen-helm-crd-templates.sh b/hack/gen-helm-crd-templates.sh index 48f89e31..ff5affd2 100755 --- a/hack/gen-helm-crd-templates.sh +++ b/hack/gen-helm-crd-templates.sh @@ -150,11 +150,11 @@ function crd::main() { # set webhook_enabled to false since the functionmeshes don't have webhooks crd::generate_template "$source_file" "$target_file" false - # crd-meshconfigs - file="crd-compute.functionmesh.io-meshconfigs.yaml" + # crd-backendconfigs + file="crd-compute.functionmesh.io-backendconfigs.yaml" target_file="charts/function-mesh-operator/charts/admission-webhook/templates/$file" source_file="$tmp/$file" - "$KUSTOMIZE" build config/crd | "$YQ" eval '. | select(.metadata.name == "meshconfigs.compute.functionmesh.io")' > "$source_file" + "$KUSTOMIZE" build config/crd | "$YQ" eval '. | select(.metadata.name == "backendconfigs.compute.functionmesh.io")' > "$source_file" crd::generate_template "$source_file" "$target_file" true } diff --git a/main.go b/main.go index fc69de1f..359faa95 100644 --- a/main.go +++ b/main.go @@ -71,9 +71,9 @@ func main() { var configFile string var watchedNamespace string var enableInitContainers bool - var globalMeshConfig string - var globalMeshConfigNamespace string - var namespacedMeshConfig string + var globalBackendConfig string + var globalBackendConfigNamespace string + var namespacedBackendConfig string flag.StringVar(&metricsAddr, "metrics-addr", lookupEnvOrString("METRICS_ADDR", ":8080"), "The address the metric endpoint binds to.") flag.StringVar(&leaderElectionID, "leader-election-id", @@ -99,19 +99,19 @@ func main() { "The address the pprof binds to.") flag.BoolVar(&enableInitContainers, "enable-init-containers", lookupEnvOrBool("ENABLE_INIT_CONTAINERS", false), "Whether to use an init container to download package") - flag.StringVar(&globalMeshConfig, "global-mesh-config", lookupEnvOrString("GLOBAL_MESH_CONFIG", ""), - "The global mesh config name used for all functions&sinks&sources") - flag.StringVar(&globalMeshConfigNamespace, "global-mesh-config-namespace", lookupEnvOrString("GLOBAL_MESH_CONFIG_NAMESPACE", "default"), - "The namespace of the global mesh config name used for all functions&sinks&sources") - flag.StringVar(&namespacedMeshConfig, "namespaced-mesh-config", lookupEnvOrString("NAMESPACED_MESH_CONFIG", ""), - "The mesh config name used for functions&sinks&sources in the same namespace") + flag.StringVar(&globalBackendConfig, "global-backend-config", lookupEnvOrString("GLOBAL_BACKEND_CONFIG", ""), + "The global backend config name used for all functions&sinks&sources") + flag.StringVar(&globalBackendConfigNamespace, "global-backend-config-namespace", lookupEnvOrString("GLOBAL_BACKEND_CONFIG_NAMESPACE", "default"), + "The namespace of the global backend config name used for all functions&sinks&sources") + flag.StringVar(&namespacedBackendConfig, "namespaced-backend-config", lookupEnvOrString("NAMESPACED_BACKEND_CONFIG", "backend-config"), + "The backend config name used for functions&sinks&sources in the same namespace") flag.Parse() ctrl.SetLogger(zap.New(zap.UseDevMode(true))) utils.EnableInitContainers = enableInitContainers - utils.GlobalMeshConfig = globalMeshConfig - utils.GlobalMeshConfigNamespace = globalMeshConfigNamespace - utils.NamespacedMeshConfig = namespacedMeshConfig + utils.GlobalBackendConfig = globalBackendConfig + utils.GlobalBackendConfigNamespace = globalBackendConfigNamespace + utils.NamespacedBackendConfig = namespacedBackendConfig // enable pprof if enablePprof { diff --git a/manifests/crd.yaml b/manifests/crd.yaml index 2d11067d..a19fa60b 100644 --- a/manifests/crd.yaml +++ b/manifests/crd.yaml @@ -1,5 +1,65 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition +metadata: + annotations: + cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + controller-gen.kubebuilder.io/version: v0.9.2 + name: backendconfigs.compute.functionmesh.io +spec: + conversion: + strategy: Webhook + webhook: + clientConfig: + service: + name: webhook-service + namespace: system + path: /convert + port: 443 + conversionReviewVersions: + - v1 + - v1beta1 + group: compute.functionmesh.io + names: + kind: BackendConfig + listKind: BackendConfigList + plural: backendconfigs + singular: backendconfig + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + properties: + apiVersion: + type: string + kind: + type: string + metadata: + type: object + spec: + properties: + env: + additionalProperties: + type: string + type: object + name: + type: string + type: object + status: + type: object + type: object + x-kubernetes-preserve-unknown-fields: true + served: true + storage: true + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas + status: {} +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) @@ -13943,9 +14003,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 @@ -13973,66 +14033,6 @@ spec: --- apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition -metadata: - annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) - controller-gen.kubebuilder.io/version: v0.9.2 - name: meshconfigs.compute.functionmesh.io -spec: - conversion: - strategy: Webhook - webhook: - clientConfig: - service: - name: webhook-service - namespace: system - path: /convert - port: 443 - conversionReviewVersions: - - v1 - - v1beta1 - group: compute.functionmesh.io - names: - kind: MeshConfig - listKind: MeshConfigList - plural: meshconfigs - singular: meshconfig - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - properties: - apiVersion: - type: string - kind: - type: string - metadata: - type: object - spec: - properties: - env: - additionalProperties: - type: string - type: object - name: - type: string - type: object - status: - type: object - type: object - x-kubernetes-preserve-unknown-fields: true - served: true - storage: true - subresources: - scale: - labelSelectorPath: .status.selector - specReplicasPath: .spec.replicas - statusReplicasPath: .status.replicas - status: {} ---- -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition metadata: annotations: cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) @@ -17403,9 +17403,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 @@ -20784,9 +20784,9 @@ spec: type: string type: object type: object - globalMeshConfigRevision: + globalBackendConfigRevision: type: string - namespacedMeshConfigRevision: + namespacedBackendConfigRevision: type: string observedGeneration: format: int64 diff --git a/manifests/rbac.yaml b/manifests/rbac.yaml index d3c690b7..0a384859 100644 --- a/manifests/rbac.yaml +++ b/manifests/rbac.yaml @@ -90,6 +90,18 @@ rules: - list - update - watch +- apiGroups: + - compute.functionmesh.io + resources: + - backendconfigs + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - compute.functionmesh.io resources: @@ -137,18 +149,6 @@ rules: - get - patch - update -- apiGroups: - - compute.functionmesh.io - resources: - - meshconfigs - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - compute.functionmesh.io resources: diff --git a/utils/configs.go b/utils/configs.go index 9ef0a534..5e7bd902 100644 --- a/utils/configs.go +++ b/utils/configs.go @@ -19,6 +19,6 @@ package utils var EnableInitContainers = false -var GlobalMeshConfig = "" -var GlobalMeshConfigNamespace = "default" -var NamespacedMeshConfig = "" +var GlobalBackendConfig = "" +var GlobalBackendConfigNamespace = "default" +var NamespacedBackendConfig = ""