diff --git a/operator/api/operator/shared/shared.go b/operator/api/operator/shared/shared.go index 2e11d37b0..e2e80373e 100644 --- a/operator/api/operator/shared/shared.go +++ b/operator/api/operator/shared/shared.go @@ -27,10 +27,6 @@ import ( // ResourceRequirements copied from corev1.ResourceRequirements // We do not need to support ResourceClaim type ResourceRequirements struct { - // Limits describes the maximum amount of compute resources allowed. - // For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - // +optional - Limits corev1.ResourceList `json:"limits,omitempty"` // Requests describes the minimum amount of compute resources required. // If requests are omitted for a container, it defaults to the specified limits. // If there are no specified limits, it defaults to an implementation-defined value. diff --git a/operator/api/operator/shared/zz_generated.deepcopy.go b/operator/api/operator/shared/zz_generated.deepcopy.go index 37ad0d49b..25fc8e3b7 100644 --- a/operator/api/operator/shared/zz_generated.deepcopy.go +++ b/operator/api/operator/shared/zz_generated.deepcopy.go @@ -27,13 +27,6 @@ import ( // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourceRequirements) DeepCopyInto(out *ResourceRequirements) { *out = *in - if in.Limits != nil { - in, out := &in.Limits, &out.Limits - *out = make(v1.ResourceList, len(*in)) - for key, val := range *in { - (*out)[key] = val.DeepCopy() - } - } if in.Requests != nil { in, out := &in.Requests, &out.Requests *out = make(v1.ResourceList, len(*in)) diff --git a/operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go b/operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go index b41555d74..93cb5db76 100644 --- a/operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go +++ b/operator/api/operator/v1alpha1/multiclusterglobalhubagent_types.go @@ -23,17 +23,22 @@ import ( shared "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared" ) -// 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. // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:shortName={mgha,mcgha} // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.phase",description="The overall status of the MulticlusterGlobalHubAgent" // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" +// MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents API +type MulticlusterGlobalHubAgent struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec MulticlusterGlobalHubAgentSpec `json:"spec,omitempty"` + Status MulticlusterGlobalHubAgentStatus `json:"status,omitempty"` +} + // MulticlusterGlobalHubAgentSpec defines the desired state of MulticlusterGlobalHubAgent type MulticlusterGlobalHubAgentSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file // ImagePullPolicy specifies the pull policy of the multicluster global hub agent image // +operator-sdk:csv:customresourcedefinitions:type=spec // +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:imagePullPolicy"} @@ -54,16 +59,9 @@ type MulticlusterGlobalHubAgentSpec struct { // Compute Resources required by the global hub agent // +optional Resources *shared.ResourceRequirements `json:"resources,omitempty"` - // TransportConfigSecretName specifies the secret which is used to connect to the global hub transport. - // You can fetch the information using the following commands from the global hub environment: - // cat <./kafka.yaml - // bootstrap.server: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].bootstrapServers}') - // topic.status: gh-status.global-hub - // ca.crt: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].certificates[0]}' | { if [[ "$OSTYPE" == "darwin"* ]]; then base64 -b 0; else base64 -w 0; fi; }) - // client.crt: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.crt}') - // client.key: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.key}') - // EOF - // You can create the secret `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"` + // TransportConfigSecretName specifies the secret which is used to connect to the global hub Kafka. + // You can get kafka.yaml content using `tools/generate-kafka-config.sh` from the global hub environment. + // Then you can create the secret in the current environment by running `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"` // +kubebuilder:default=transport-config TransportConfigSecretName string `json:"transportConfigSecretName,omitempty"` } @@ -74,20 +72,7 @@ type MulticlusterGlobalHubAgentStatus struct { // Important: Run "make" to regenerate code after modifying this file } -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status - -// MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents API -type MulticlusterGlobalHubAgent struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec MulticlusterGlobalHubAgentSpec `json:"spec,omitempty"` - Status MulticlusterGlobalHubAgentStatus `json:"status,omitempty"` -} - -//+kubebuilder:object:root=true - +// +kubebuilder:object:root=true // MulticlusterGlobalHubAgentList contains a list of MulticlusterGlobalHubAgent type MulticlusterGlobalHubAgentList struct { metav1.TypeMeta `json:",inline"` diff --git a/operator/api/operator/v1alpha1/zz_generated.deepcopy.go b/operator/api/operator/v1alpha1/zz_generated.deepcopy.go index 821055968..6ea0a6238 100644 --- a/operator/api/operator/v1alpha1/zz_generated.deepcopy.go +++ b/operator/api/operator/v1alpha1/zz_generated.deepcopy.go @@ -21,9 +21,10 @@ limitations under the License. package v1alpha1 import ( - "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared" "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" + + "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -119,14 +120,6 @@ func (in *MulticlusterGlobalHubAgentSpec) DeepCopy() *MulticlusterGlobalHubAgent return out } -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *MulticlusterGlobalHubAgentSpec) 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 *MulticlusterGlobalHubAgentStatus) DeepCopyInto(out *MulticlusterGlobalHubAgentStatus) { *out = *in diff --git a/operator/api/operator/v1alpha4/zz_generated.deepcopy.go b/operator/api/operator/v1alpha4/zz_generated.deepcopy.go index 365edbf3b..f7c6acd8a 100644 --- a/operator/api/operator/v1alpha4/zz_generated.deepcopy.go +++ b/operator/api/operator/v1alpha4/zz_generated.deepcopy.go @@ -21,10 +21,11 @@ limitations under the License. package v1alpha4 import ( - "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" + + "github.com/stolostron/multicluster-global-hub/operator/api/operator/shared" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. diff --git a/operator/bundle/manifests/multicluster-global-hub-operator.clusterserviceversion.yaml b/operator/bundle/manifests/multicluster-global-hub-operator.clusterserviceversion.yaml index fc1adbfbc..b2c5dbf6f 100644 --- a/operator/bundle/manifests/multicluster-global-hub-operator.clusterserviceversion.yaml +++ b/operator/bundle/manifests/multicluster-global-hub-operator.clusterserviceversion.yaml @@ -18,7 +18,9 @@ metadata: "metadata": { "name": "multiclusterglobalhubagent" }, - "spec": {} + "spec": { + "transportConfigSecretName": "transport-config" + } }, { "apiVersion": "operator.open-cluster-management.io/v1alpha4", @@ -39,7 +41,7 @@ metadata: categories: Integration & Delivery,OpenShift Optional certified: "false" containerImage: quay.io/stolostron/multicluster-global-hub-operator:latest - createdAt: "2024-11-06T07:58:55Z" + createdAt: "2025-01-14T11:53:57Z" description: Manages the installation and upgrade of the Multicluster Global Hub. features.operators.openshift.io/cnf: "false" features.operators.openshift.io/cni: "false" @@ -104,9 +106,8 @@ spec: kind: MulticlusterGlobalHubAgent name: multiclusterglobalhubagents.operator.open-cluster-management.io specDescriptors: - - description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: - Run "make" to regenerate code after modifying this file ImagePullPolicy - specifies the pull policy of the multicluster global hub agent image' + - description: ImagePullPolicy specifies the pull policy of the multicluster + global hub agent image displayName: Image Pull Policy path: imagePullPolicy x-descriptors: @@ -348,13 +349,16 @@ spec: - "" resources: - configmaps - - serviceaccounts - - services + - namespaces + - persistentvolumeclaims + - pods + - secrets verbs: - create - delete - get - list + - patch - update - watch - apiGroups: @@ -370,21 +374,6 @@ spec: - patch - update - watch - - apiGroups: - - "" - resources: - - namespaces - - persistentvolumeclaims - - pods - - secrets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - "" resources: diff --git a/operator/bundle/manifests/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml b/operator/bundle/manifests/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml index c3b9f3454..83ac05da6 100644 --- a/operator/bundle/manifests/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml +++ b/operator/bundle/manifests/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml @@ -11,10 +11,21 @@ spec: kind: MulticlusterGlobalHubAgent listKind: MulticlusterGlobalHubAgentList plural: multiclusterglobalhubagents + shortNames: + - mgha + - mcgha singular: multiclusterglobalhubagent scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - description: The overall status of the MulticlusterGlobalHubAgent + jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 schema: openAPIV3Schema: description: MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents @@ -38,16 +49,12 @@ spec: metadata: type: object spec: - description: |- - 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. - MulticlusterGlobalHubAgentSpec defines the desired state of MulticlusterGlobalHubAgent + description: MulticlusterGlobalHubAgentSpec defines the desired state + of MulticlusterGlobalHubAgent properties: imagePullPolicy: - description: |- - INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - Important: Run "make" to regenerate code after modifying this file - ImagePullPolicy specifies the pull policy of the multicluster global hub agent image + description: ImagePullPolicy specifies the pull policy of the multicluster + global hub agent image type: string imagePullSecret: description: ImagePullSecret specifies the pull secret of the multicluster @@ -61,17 +68,6 @@ spec: resources: description: Compute Resources required by the global hub agent properties: - limits: - additionalProperties: - anyOf: - - type: integer - - 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: |- - Limits describes the maximum amount of compute resources allowed. - For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object requests: additionalProperties: anyOf: @@ -128,16 +124,9 @@ spec: transportConfigSecretName: default: transport-config description: |- - TransportConfigSecretName specifies the secret which is used to connect to the global hub transport. - You can fetch the information using the following commands from the global hub environment: - cat <./kafka.yaml - bootstrap.server: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].bootstrapServers}') - topic.status: gh-status.global-hub - ca.crt: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].certificates[0]}' | { if [[ "$OSTYPE" == "darwin"* ]]; then base64 -b 0; else base64 -w 0; fi; }) - client.crt: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.crt}') - client.key: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.key}') - EOF - You can create the secret `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"` + TransportConfigSecretName specifies the secret which is used to connect to the global hub Kafka. + You can get kafka.yaml content using `tools/generate-kafka-config.sh` from the global hub environment. + Then you can create the secret in the current environment by running `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"` type: string type: object status: diff --git a/operator/config/crd/bases/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml b/operator/config/crd/bases/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml index a38611389..5ed626f16 100644 --- a/operator/config/crd/bases/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml +++ b/operator/config/crd/bases/operator.open-cluster-management.io_multiclusterglobalhubagents.yaml @@ -11,10 +11,21 @@ spec: kind: MulticlusterGlobalHubAgent listKind: MulticlusterGlobalHubAgentList plural: multiclusterglobalhubagents + shortNames: + - mgha + - mcgha singular: multiclusterglobalhubagent scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - description: The overall status of the MulticlusterGlobalHubAgent + jsonPath: .status.phase + name: Status + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 schema: openAPIV3Schema: description: MulticlusterGlobalHubAgent is the Schema for the multiclusterglobalhubagents @@ -38,16 +49,12 @@ spec: metadata: type: object spec: - description: |- - 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. - MulticlusterGlobalHubAgentSpec defines the desired state of MulticlusterGlobalHubAgent + description: MulticlusterGlobalHubAgentSpec defines the desired state + of MulticlusterGlobalHubAgent properties: imagePullPolicy: - description: |- - INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - Important: Run "make" to regenerate code after modifying this file - ImagePullPolicy specifies the pull policy of the multicluster global hub agent image + description: ImagePullPolicy specifies the pull policy of the multicluster + global hub agent image type: string imagePullSecret: description: ImagePullSecret specifies the pull secret of the multicluster @@ -61,17 +68,6 @@ spec: resources: description: Compute Resources required by the global hub agent properties: - limits: - additionalProperties: - anyOf: - - type: integer - - 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: |- - Limits describes the maximum amount of compute resources allowed. - For more information, see: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ - type: object requests: additionalProperties: anyOf: @@ -128,16 +124,9 @@ spec: transportConfigSecretName: default: transport-config description: |- - TransportConfigSecretName specifies the secret which is used to connect to the global hub transport. - You can fetch the information using the following commands from the global hub environment: - cat <./kafka.yaml - bootstrap.server: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].bootstrapServers}') - topic.status: gh-status.global-hub - ca.crt: $(kubectl get kafka kafka -n "multicluster-global-hub" -o jsonpath='{.status.listeners[1].certificates[0]}' | { if [[ "$OSTYPE" == "darwin"* ]]; then base64 -b 0; else base64 -w 0; fi; }) - client.crt: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.crt}') - client.key: $(kubectl get secret global-hub-kafka-user -n "multicluster-global-hub" -o jsonpath='{.data.user\.key}') - EOF - You can create the secret `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"` + TransportConfigSecretName specifies the secret which is used to connect to the global hub Kafka. + You can get kafka.yaml content using `tools/generate-kafka-config.sh` from the global hub environment. + Then you can create the secret in the current environment by running `kubectl create secret generic transport-config -n "multicluster-global-hub" --from-file=kafka.yaml="./kafka.yaml"` type: string type: object status: diff --git a/operator/config/manifests/bases/multicluster-global-hub-operator.clusterserviceversion.yaml b/operator/config/manifests/bases/multicluster-global-hub-operator.clusterserviceversion.yaml index 72d20cc74..dadf5e687 100644 --- a/operator/config/manifests/bases/multicluster-global-hub-operator.clusterserviceversion.yaml +++ b/operator/config/manifests/bases/multicluster-global-hub-operator.clusterserviceversion.yaml @@ -71,9 +71,8 @@ spec: kind: MulticlusterGlobalHubAgent name: multiclusterglobalhubagents.operator.open-cluster-management.io specDescriptors: - - description: 'INSERT ADDITIONAL SPEC FIELDS - desired state of cluster Important: - Run "make" to regenerate code after modifying this file ImagePullPolicy - specifies the pull policy of the multicluster global hub agent image' + - description: ImagePullPolicy specifies the pull policy of the multicluster + global hub agent image displayName: Image Pull Policy path: imagePullPolicy x-descriptors: diff --git a/operator/config/rbac/role.yaml b/operator/config/rbac/role.yaml index 1bb32bcf2..1ebbaecbf 100644 --- a/operator/config/rbac/role.yaml +++ b/operator/config/rbac/role.yaml @@ -8,13 +8,16 @@ rules: - "" resources: - configmaps - - serviceaccounts - - services + - namespaces + - persistentvolumeclaims + - pods + - secrets verbs: - create - delete - get - list + - patch - update - watch - apiGroups: @@ -30,21 +33,6 @@ rules: - patch - update - watch -- apiGroups: - - "" - resources: - - namespaces - - persistentvolumeclaims - - pods - - secrets - verbs: - - create - - delete - - get - - list - - patch - - update - - watch - apiGroups: - "" resources: diff --git a/operator/config/samples/operator_v1alpha1_multiclusterglobalhubagent.yaml b/operator/config/samples/operator_v1alpha1_multiclusterglobalhubagent.yaml index 7f5a13c01..4af1ff86d 100644 --- a/operator/config/samples/operator_v1alpha1_multiclusterglobalhubagent.yaml +++ b/operator/config/samples/operator_v1alpha1_multiclusterglobalhubagent.yaml @@ -2,4 +2,5 @@ apiVersion: operator.open-cluster-management.io/v1alpha1 kind: MulticlusterGlobalHubAgent metadata: name: multiclusterglobalhubagent -spec: {} +spec: + transportConfigSecretName: transport-config diff --git a/operator/pkg/controllers/agent/standalone_agent_controller.go b/operator/pkg/controllers/agent/standalone_agent_controller.go index 1788d7dc3..64760f6bd 100644 --- a/operator/pkg/controllers/agent/standalone_agent_controller.go +++ b/operator/pkg/controllers/agent/standalone_agent_controller.go @@ -69,7 +69,7 @@ func AddStandaloneAgentController(ctx context.Context, mgr ctrl.Manager) error { Named("standalone-agent-reconciler"). Watches(&appsv1.Deployment{}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(deplomentPred)). - //TODO: @clyang82 add more watches + // TODO: @clyang82 add more watches Complete(agentReconciler) if err != nil { return err @@ -131,7 +131,7 @@ func (s *StandaloneAgentController) Reconcile(ctx context.Context, req ctrl.Requ limits := corev1.ResourceList{ corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(operatorconstants.AgentMemoryLimit), } - utils.SetResourcesFromCR(mgha.Spec.Resources, requests, limits) + utils.SetResourcesFromCR(mgha.Spec.Resources, requests) resourceReq.Limits = limits resourceReq.Requests = requests diff --git a/operator/pkg/controllers/manager/manifests/global-hub-kafka-topic.yaml b/operator/pkg/controllers/manager/manifests/global-hub-kafka-topic.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/operator/pkg/controllers/manager/manifests/global-hub-kafka-user.yaml b/operator/pkg/controllers/manager/manifests/global-hub-kafka-user.yaml deleted file mode 100644 index e69de29bb..000000000 diff --git a/operator/pkg/controllers/meta.go b/operator/pkg/controllers/meta.go index 4ef9c7bc6..5c780fc19 100644 --- a/operator/pkg/controllers/meta.go +++ b/operator/pkg/controllers/meta.go @@ -38,7 +38,9 @@ import ( "github.com/stolostron/multicluster-global-hub/operator/api/operator/v1alpha1" "github.com/stolostron/multicluster-global-hub/operator/api/operator/v1alpha4" "github.com/stolostron/multicluster-global-hub/operator/pkg/config" + "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/acm" "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/agent" + "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/backup" "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/grafana" "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/inventory" "github.com/stolostron/multicluster-global-hub/operator/pkg/controllers/managedhub" diff --git a/operator/pkg/controllers/transporter/protocol/manifests/global-hub-kafka-user.yaml b/operator/pkg/controllers/transporter/protocol/manifests/global-hub-kafka-user.yaml index 4ea0e1f75..cb0c14946 100644 --- a/operator/pkg/controllers/transporter/protocol/manifests/global-hub-kafka-user.yaml +++ b/operator/pkg/controllers/transporter/protocol/manifests/global-hub-kafka-user.yaml @@ -19,8 +19,6 @@ spec: type: group - host: '*' operations: - - Describe - - Read - Write resource: name: {{.SpecTopic}} @@ -30,7 +28,6 @@ spec: operations: - Describe - Read - - Write resource: name: {{.StatusTopic}} patternType: {{.StatusTopicParttern}} diff --git a/operator/pkg/utils/utils.go b/operator/pkg/utils/utils.go index a5df0ec5a..6a2845e69 100644 --- a/operator/pkg/utils/utils.go +++ b/operator/pkg/utils/utils.go @@ -291,49 +291,41 @@ func GetResources(component string, advanced *v1alpha4.AdvancedSpec) *corev1.Res requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.GrafanaMemoryRequest) requests[corev1.ResourceName(corev1.ResourceCPU)] = resource.MustParse(operatorconstants.GrafanaCPURequest) if advanced != nil && advanced.Grafana != nil { - SetResourcesFromCR(advanced.Grafana.Resources, requests, limits) + SetResourcesFromCR(advanced.Grafana.Resources, requests) } case operatorconstants.Postgres: requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.PostgresMemoryRequest) requests[corev1.ResourceName(corev1.ResourceCPU)] = resource.MustParse(operatorconstants.PostgresCPURequest) if advanced != nil && advanced.Postgres != nil { - SetResourcesFromCR(advanced.Postgres.Resources, requests, limits) + SetResourcesFromCR(advanced.Postgres.Resources, requests) } case operatorconstants.Manager: requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.ManagerMemoryRequest) requests[corev1.ResourceName(corev1.ResourceCPU)] = resource.MustParse(operatorconstants.ManagerCPURequest) if advanced != nil && advanced.Manager != nil { - SetResourcesFromCR(advanced.Manager.Resources, requests, limits) + SetResourcesFromCR(advanced.Manager.Resources, requests) } case operatorconstants.Agent: requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.AgentMemoryRequest) requests[corev1.ResourceName(corev1.ResourceCPU)] = resource.MustParse(operatorconstants.AgentCPURequest) if advanced != nil && advanced.Agent != nil { - SetResourcesFromCR(advanced.Agent.Resources, requests, limits) + SetResourcesFromCR(advanced.Agent.Resources, requests) } case operatorconstants.Kafka: requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.KafkaMemoryRequest) requests[corev1.ResourceName(corev1.ResourceCPU)] = resource.MustParse(operatorconstants.KafkaCPURequest) if advanced != nil && advanced.Kafka != nil { - SetResourcesFromCR(advanced.Kafka.Resources, requests, limits) - } - case operatorconstants.Zookeeper: - requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.ZookeeperMemoryRequest) - requests[corev1.ResourceName(corev1.ResourceCPU)] = resource.MustParse(operatorconstants.ZookeeperCPURequest) - limits[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(operatorconstants.ZookeeperMemoryLimit) - if advanced != nil && advanced.Zookeeper != nil { - SetResourcesFromCR(advanced.Zookeeper.Resources, requests, limits) + SetResourcesFromCR(advanced.Kafka.Resources, requests) } } - resourceReq.Requests = requests return &resourceReq } -func SetResourcesFromCR(res *shared.ResourceRequirements, requests, limits corev1.ResourceList) { +func SetResourcesFromCR(res *shared.ResourceRequirements, requests corev1.ResourceList) { if res != nil { if res.Requests.Memory().String() != "0" { requests[corev1.ResourceName(corev1.ResourceMemory)] = resource.MustParse(res.Requests.Memory().String()) diff --git a/operator/pkg/utils/utils_test.go b/operator/pkg/utils/utils_test.go index c1e89f0a6..ad75c2c17 100644 --- a/operator/pkg/utils/utils_test.go +++ b/operator/pkg/utils/utils_test.go @@ -377,33 +377,9 @@ func Test_GetResources(t *testing.T) { }, custom: true, }, - { - name: "Test Zookeeper with default values", - component: constants.Zookeeper, - cpuRequest: constants.ZookeeperCPURequest, - cpuLimit: "0", - memoryRequest: constants.ZookeeperMemoryRequest, - memoryLimit: constants.ZookeeperMemoryLimit, - }, - { - name: "Test Zookeeper with customized values", - component: constants.Zookeeper, - advanced: func(resReq *shared.ResourceRequirements) *v1alpha4.AdvancedSpec { - return &v1alpha4.AdvancedSpec{ - Zookeeper: &v1alpha4.CommonSpec{ - Resources: resReq, - }, - } - }, - custom: true, - }, } resReq := &shared.ResourceRequirements{ - Limits: corev1.ResourceList{ - corev1.ResourceName(corev1.ResourceCPU): resource.MustParse(customCPULimit), - corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(customMemoryLimit), - }, Requests: corev1.ResourceList{ corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(customMemoryRequest), corev1.ResourceName(corev1.ResourceCPU): resource.MustParse(customCPURequest), diff --git a/test/integration/operator/controllers/transporter_test.go b/test/integration/operator/controllers/transporter_test.go index 5b4b0ba52..cbc6f4bd3 100644 --- a/test/integration/operator/controllers/transporter_test.go +++ b/test/integration/operator/controllers/transporter_test.go @@ -249,22 +249,6 @@ var _ = Describe("transporter", Ordered, func() { mgh.Spec.AdvancedSpec = &v1alpha4.AdvancedSpec{ Kafka: &v1alpha4.CommonSpec{ Resources: &shared.ResourceRequirements{ - Limits: corev1.ResourceList{ - corev1.ResourceName(corev1.ResourceCPU): resource.MustParse(customCPULimit), - corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(customMemoryLimit), - }, - Requests: corev1.ResourceList{ - corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(customMemoryRequest), - corev1.ResourceName(corev1.ResourceCPU): resource.MustParse(customCPURequest), - }, - }, - }, - Zookeeper: &v1alpha4.CommonSpec{ - Resources: &shared.ResourceRequirements{ - Limits: corev1.ResourceList{ - corev1.ResourceName(corev1.ResourceCPU): resource.MustParse(customCPULimit), - corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(customMemoryLimit), - }, Requests: corev1.ResourceList{ corev1.ResourceName(corev1.ResourceMemory): resource.MustParse(customMemoryRequest), corev1.ResourceName(corev1.ResourceCPU): resource.MustParse(customCPURequest),