From 4b69906b1808f435a637f3782eb1e3b6973fb703 Mon Sep 17 00:00:00 2001 From: Tanmay Jain Date: Fri, 22 Sep 2023 14:29:59 +0530 Subject: [PATCH] updating ports in statefulsets. --- controllers/service.go | 5 +++++ controllers/statefulset.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/controllers/service.go b/controllers/service.go index cb19ce333..764a675ec 100644 --- a/controllers/service.go +++ b/controllers/service.go @@ -280,6 +280,11 @@ func (r *SingleClusterReconciler) updateServicePorts(service *corev1.Service) er ) } + r.Log.Info( + "Service already exist. Updated existing service", + "name", utils.NamespacedName(service.Namespace, service.Name), + ) + return nil } diff --git a/controllers/statefulset.go b/controllers/statefulset.go index 99ec70b9b..957e6adbb 100644 --- a/controllers/statefulset.go +++ b/controllers/statefulset.go @@ -549,6 +549,17 @@ func (r *SingleClusterReconciler) updateSTSStorage( sortContainerVolumeAttachments(st.Spec.Template.Spec.Containers) } +func (r *SingleClusterReconciler) updateSTSPorts( + st *appsv1.StatefulSet, +) { + ports := getSTSContainerPort( + r.aeroCluster.Spec.PodSpec.MultiPodPerHost, + r.aeroCluster.Spec.AerospikeConfig, + ) + + st.Spec.Template.Spec.Containers[0].Ports = ports +} + func sortContainerVolumeAttachments(containers []corev1.Container) { for idx := range containers { sort.Slice( @@ -572,6 +583,9 @@ func (r *SingleClusterReconciler) updateSTS( // Update settings from pod spec. r.updateSTSFromPodSpec(statefulSet, rackState) + // Updating ports when switching between tls and non-tls. + r.updateSTSPorts(statefulSet) + // Update the images for all containers from the spec. // Our Pod Spec does not contain image for the Aerospike Server // Container.