Skip to content

Commit

Permalink
Merge pull request ManageIQ#543 from carbonin/gate_kafka_install
Browse files Browse the repository at this point in the history
Add a flag to gate deploying kafka and zookeeper
  • Loading branch information
bdunne authored Jun 10, 2020
2 parents 4b5eb15 + e5401f6 commit 1e9c2d4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 2 deletions.
4 changes: 4 additions & 0 deletions manageiq-operator/deploy/crds/manageiq.org_manageiqs_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions manageiq-operator/pkg/helpers/miq-components/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1e9c2d4

Please sign in to comment.