Skip to content

Commit

Permalink
Add linux nodeSelector to all Helm jobs
Browse files Browse the repository at this point in the history
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Aug 20, 2021
1 parent 4d509b9 commit 5dad612
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/helm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const (
CRDName = "helmcharts.helm.cattle.io"
ConfigCRDName = "helmchartconfigs.helm.cattle.io"
Name = "helm-controller"

TaintExternalCloudProvider = "node.cloudprovider.kubernetes.io/uninitialized"
LabelNodeRolePrefix = "node-role.kubernetes.io/"
LabelControlPlaneSuffix = "control-plane"
LabelEtcdSuffix = "etcd"
)

func Register(ctx context.Context, apply apply.Apply,
Expand Down Expand Up @@ -279,15 +284,19 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap, *core.ConfigMap)
})
}

job.Spec.Template.Spec.NodeSelector = make(map[string]string)
job.Spec.Template.Spec.NodeSelector[core.LabelOSStable] = "linux"

if chart.Spec.Bootstrap {
job.Spec.Template.Spec.NodeSelector[LabelNodeRolePrefix+LabelControlPlaneSuffix] = "true"
job.Spec.Template.Spec.HostNetwork = true
job.Spec.Template.Spec.Tolerations = []core.Toleration{
{
Key: "node.kubernetes.io/not-ready",
Key: core.TaintNodeNotReady,
Effect: core.TaintEffectNoSchedule,
},
{
Key: "node.cloudprovider.kubernetes.io/uninitialized",
Key: TaintExternalCloudProvider,
Operator: core.TolerationOpEqual,
Value: "true",
Effect: core.TaintEffectNoSchedule,
Expand All @@ -297,12 +306,12 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap, *core.ConfigMap)
Operator: core.TolerationOpExists,
},
{
Key: "node-role.kubernetes.io/etcd",
Key: LabelNodeRolePrefix + LabelEtcdSuffix,
Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoExecute,
},
{
Key: "node-role.kubernetes.io/control-plane",
Key: LabelNodeRolePrefix + LabelControlPlaneSuffix,
Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoSchedule,
},
Expand All @@ -318,8 +327,6 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap, *core.ConfigMap)
Name: "BOOTSTRAP",
Value: "true"},
}...)
job.Spec.Template.Spec.NodeSelector = make(map[string]string)
job.Spec.Template.Spec.NodeSelector["node-role.kubernetes.io/master"] = "true"
}

setProxyEnv(job)
Expand Down

0 comments on commit 5dad612

Please sign in to comment.