Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a flag to gate deploying kafka and zookeeper #543

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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