Ceph: Add node topology labels to the drain-canary.

This serves to make the drain-canary selectable by failure domain.

Signed-off-by: Rohan CJ <rohantmp@gmail.com>
This commit is contained in:
Rohan CJ committed 2019-11-13 16:04:45 +05:30
1 parent 9ec12a587b
commit a930264b55
1 file changed
+9 -5
@@ -139,7 +139,7 @@ func (r *ReconcileNode) reconcile(request reconcile.Request) (reconcile.Result,
mutateFunc := func() error {
// lablels for the pod, the deployment, and the deploymentSelector
deploymentLabels := map[string]string{
selectorLabels := map[string]string{
corev1.LabelHostname: nodeHostnameLabel,
k8sutil.AppAttr: CanaryAppName,
NodeNameLabel: node.GetName(),
@@ -151,16 +151,20 @@ func (r *ReconcileNode) reconcile(request reconcile.Request) (reconcile.Result,
// a new object is going to be created
if deploy.ObjectMeta.CreationTimestamp.IsZero() {
deploy.Spec.Selector = &metav1.LabelSelector{
MatchLabels: deploymentLabels,
MatchLabels: selectorLabels,
}
}
// update
deploy.ObjectMeta.Labels = deploymentLabels
// update the deployment labels
topology, _ := osd.ExtractRookTopologyFromLabels(node.GetLabels())
for key, value := range topology {
selectorLabels[key] = value
}
deploy.ObjectMeta.Labels = selectorLabels
// update the Deployment pod template
deploy.Spec.Template = corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{Labels: deploymentLabels},
ObjectMeta: metav1.ObjectMeta{Labels: selectorLabels},
Spec: corev1.PodSpec{
NodeSelector: nodeSelector,
Containers: newDoNothingContainers(r.context.RookImage),