diff --git a/manageiq-operator/deploy/crds/manageiq.org_manageiqs_crd.yaml b/manageiq-operator/deploy/crds/manageiq.org_manageiqs_crd.yaml index 143118a06..7cc382a90 100644 --- a/manageiq-operator/deploy/crds/manageiq.org_manageiqs_crd.yaml +++ b/manageiq-operator/deploy/crds/manageiq.org_manageiqs_crd.yaml @@ -48,6 +48,10 @@ spec: databaseVolumeCapacity: description: 'Database volume size (default: 15Gi)' type: string + deployMessagingService: + description: 'Flag to indicate if Kafka and Zookeeper should be deployed + (default: false)' + type: boolean enableApplicationLocalLogin: description: 'Flag to allow logging into the application without SSO (default: true)' diff --git a/manageiq-operator/deploy/olm-catalog/manageiq-operator/0.0.1/manageiq.org_manageiqs_crd.yaml b/manageiq-operator/deploy/olm-catalog/manageiq-operator/0.0.1/manageiq.org_manageiqs_crd.yaml index 143118a06..7cc382a90 100644 --- a/manageiq-operator/deploy/olm-catalog/manageiq-operator/0.0.1/manageiq.org_manageiqs_crd.yaml +++ b/manageiq-operator/deploy/olm-catalog/manageiq-operator/0.0.1/manageiq.org_manageiqs_crd.yaml @@ -48,6 +48,10 @@ spec: databaseVolumeCapacity: description: 'Database volume size (default: 15Gi)' type: string + deployMessagingService: + description: 'Flag to indicate if Kafka and Zookeeper should be deployed + (default: false)' + type: boolean enableApplicationLocalLogin: description: 'Flag to allow logging into the application without SSO (default: true)' diff --git a/manageiq-operator/pkg/apis/manageiq/v1alpha1/manageiq_types.go b/manageiq-operator/pkg/apis/manageiq/v1alpha1/manageiq_types.go index 4870f5e4b..0f4180cc1 100644 --- a/manageiq-operator/pkg/apis/manageiq/v1alpha1/manageiq_types.go +++ b/manageiq-operator/pkg/apis/manageiq/v1alpha1/manageiq_types.go @@ -184,6 +184,10 @@ type ManageIQSpec struct { // +optional PostgresqlSharedBuffers string `json:"postgresqlSharedBuffers"` + // Flag to indicate if Kafka and Zookeeper should be deployed (default: false) + // +optional + DeployMessagingService *bool `json:"deployMessagingService"` + // Image used for the kafka deployment (default: docker.io/bitnami/kafka) // +optional KafkaImageName string `json:"kafkaImageName"` @@ -354,6 +358,10 @@ func (m *ManageIQ) Initialize() { spec.PostgresqlSharedBuffers = "1GB" } + if spec.DeployMessagingService == nil { + spec.DeployMessagingService = new(bool) + } + if spec.KafkaImageName == "" { spec.KafkaImageName = "docker.io/bitnami/kafka" } diff --git a/manageiq-operator/pkg/apis/manageiq/v1alpha1/zz_generated.deepcopy.go b/manageiq-operator/pkg/apis/manageiq/v1alpha1/zz_generated.deepcopy.go index 297442fde..b647fffb2 100644 --- a/manageiq-operator/pkg/apis/manageiq/v1alpha1/zz_generated.deepcopy.go +++ b/manageiq-operator/pkg/apis/manageiq/v1alpha1/zz_generated.deepcopy.go @@ -82,6 +82,11 @@ func (in *ManageIQSpec) DeepCopyInto(out *ManageIQSpec) { *out = new(bool) **out = **in } + if in.DeployMessagingService != nil { + in, out := &in.DeployMessagingService, &out.DeployMessagingService + *out = new(bool) + **out = **in + } return } diff --git a/manageiq-operator/pkg/controller/manageiq/manageiq_controller.go b/manageiq-operator/pkg/controller/manageiq/manageiq_controller.go index bad3a07ae..68c863e80 100644 --- a/manageiq-operator/pkg/controller/manageiq/manageiq_controller.go +++ b/manageiq-operator/pkg/controller/manageiq/manageiq_controller.go @@ -128,8 +128,10 @@ func (r *ReconcileManageIQ) Reconcile(request reconcile.Request) (reconcile.Resu if e := r.generateMemcachedResources(miqInstance); e != nil { return reconcile.Result{}, e } - if e := r.generateKafkaResources(miqInstance); err != nil { - return reconcile.Result{}, e + if *miqInstance.Spec.DeployMessagingService { + if e := r.generateKafkaResources(miqInstance); e != nil { + return reconcile.Result{}, e + } } if e := r.generateOrchestratorResources(miqInstance); e != nil { return reconcile.Result{}, e diff --git a/manageiq-operator/pkg/helpers/miq-components/orchestrator.go b/manageiq-operator/pkg/helpers/miq-components/orchestrator.go index e6f64756a..39d96d102 100644 --- a/manageiq-operator/pkg/helpers/miq-components/orchestrator.go +++ b/manageiq-operator/pkg/helpers/miq-components/orchestrator.go @@ -11,6 +11,56 @@ import ( "github.com/google/uuid" ) +func addMessagingEnv(cr *miqv1alpha1.ManageIQ, c *corev1.Container) { + if !*cr.Spec.DeployMessagingService { + return + } + + messagingEnv := []corev1.EnvVar{ + corev1.EnvVar{ + Name: "MESSAGING_HOSTNAME", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{Name: kafkaSecretName(cr)}, + Key: "hostname", + }, + }, + }, + corev1.EnvVar{ + Name: "MESSAGING_PASSWORD", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{Name: kafkaSecretName(cr)}, + Key: "password", + }, + }, + }, + corev1.EnvVar{ + Name: "MESSAGING_PORT", + Value: "9092", + }, + corev1.EnvVar{ + Name: "MESSAGING_TYPE", + Value: "kafka", + }, + corev1.EnvVar{ + Name: "MESSAGING_USERNAME", + ValueFrom: &corev1.EnvVarSource{ + SecretKeyRef: &corev1.SecretKeySelector{ + LocalObjectReference: corev1.LocalObjectReference{Name: kafkaSecretName(cr)}, + Key: "username", + }, + }, + }, + } + + for _, env := range messagingEnv { + c.Env = append(c.Env, env) + } + + return +} + func NewOrchestratorDeployment(cr *miqv1alpha1.ManageIQ) (*appsv1.Deployment, error) { delaySecs, err := strconv.Atoi(cr.Spec.OrchestratorInitialDelay) if err != nil { @@ -144,6 +194,7 @@ func NewOrchestratorDeployment(cr *miqv1alpha1.ManageIQ) (*appsv1.Deployment, er }, } + addMessagingEnv(cr, &container) err = addResourceReqs(cr.Spec.OrchestratorMemoryLimit, cr.Spec.OrchestratorMemoryRequest, cr.Spec.OrchestratorCpuLimit, cr.Spec.OrchestratorCpuRequest, &container) if err != nil { return nil, err