From 0baf02cb81819c9d19b495964c0b2954f64b5c2b Mon Sep 17 00:00:00 2001 From: Kiran Mova Date: Fri, 13 Jul 2018 08:25:15 +0530 Subject: [PATCH] allow topology key without application label (#390) Signed-off-by: kmova --- orchprovider/k8s/v1/k8s.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/orchprovider/k8s/v1/k8s.go b/orchprovider/k8s/v1/k8s.go index 1842c8381f..7bf46ccc58 100644 --- a/orchprovider/k8s/v1/k8s.go +++ b/orchprovider/k8s/v1/k8s.go @@ -1128,9 +1128,17 @@ func (k *k8sOrchestrator) createReplicaDeployment(volProProfile volProfile.Volum //Depending on the topology key, additional label selectors may be required. if replicaTopoKeyDomainLV != "" && replicaTopoKeyTypeLV != "" { replicaTopoKey = replicaTopoKeyDomainLV + "/" + replicaTopoKeyTypeLV - //TODO : We are assuming here that the topology keys depend on - // the application label. - repAntiAffinityLabelSpec[string(v1.ApplicationSelectorKey)] = appLV + //There are two scenarios for specifying custom topology keys: + //(a) Deploy the application using a statefulset where application has single replica + // In this case, an application label to use as key is specified. + //(b) Deploy the replicas of a single application need to be spread out. + // In this case, there is no need to specify a seperate the application label. + // Use the auto generated id. + if appLV != "" { + repAntiAffinityLabelSpec[string(v1.ApplicationSelectorKey)] = appLV + } else { + repAntiAffinityLabelSpec[string(v1.VSMSelectorKey)] = vsm + } } else { //For host based anti-affinity, use the vsm name additional label repAntiAffinityLabelSpec[string(v1.VSMSelectorKey)] = vsm