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

Update service to ClusterIP when expose when "ExposeServices"flags are explictly set to false #1333

Merged
merged 1 commit into from
Nov 1, 2022
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
13 changes: 9 additions & 4 deletions pkg/controller/cluster/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,21 @@ func (c *Controller) checkConsoleSvc(ctx context.Context, tenant *miniov2.Tenant
// check the specification of the MinIO ClusterIP service
if !svcMatchesSpec {
if err != nil {
klog.Infof("Console Service don't match: %s", err)
klog.Infof("Console Service don't match: %s. Conciliating", err)
}

svc.ObjectMeta.Annotations = expectedSvc.ObjectMeta.Annotations
svc.ObjectMeta.Labels = expectedSvc.ObjectMeta.Labels
svc.Spec.Ports = expectedSvc.Spec.Ports
// we can only expose the service, not un-expose it
if tenant.Spec.ExposeServices != nil && tenant.Spec.ExposeServices.MinIO && svc.Spec.Type != v1.ServiceTypeLoadBalancer {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
// Only when ExposeServices is set an explicit value we do modifications to the service type
if tenant.Spec.ExposeServices != nil {
if tenant.Spec.ExposeServices.Console {
dilverse marked this conversation as resolved.
Show resolved Hide resolved
svc.Spec.Type = v1.ServiceTypeLoadBalancer
} else {
svc.Spec.Type = v1.ServiceTypeClusterIP
}
}

// update the selector
svc.Spec.Selector = expectedSvc.Spec.Selector

Expand Down
11 changes: 8 additions & 3 deletions pkg/controller/cluster/minio-services.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ func (c *Controller) checkMinIOSvc(ctx context.Context, tenant *miniov2.Tenant,
svc.ObjectMeta.Annotations = expectedSvc.ObjectMeta.Annotations
svc.ObjectMeta.Labels = expectedSvc.ObjectMeta.Labels
svc.Spec.Ports = expectedSvc.Spec.Ports
// we can only expose the service, not un-expose it
if tenant.Spec.ExposeServices != nil && tenant.Spec.ExposeServices.MinIO && svc.Spec.Type != v1.ServiceTypeLoadBalancer {
svc.Spec.Type = v1.ServiceTypeLoadBalancer

// Only when ExposeServices is set an explicit value we do modifications to the service type
if tenant.Spec.ExposeServices != nil {
if tenant.Spec.ExposeServices.MinIO {
svc.Spec.Type = v1.ServiceTypeLoadBalancer
} else {
svc.Spec.Type = v1.ServiceTypeClusterIP
}
}
_, err = c.kubeClientSet.CoreV1().Services(tenant.Namespace).Update(ctx, svc, metav1.UpdateOptions{})
if err != nil {
Expand Down