Skip to content

Commit

Permalink
Merge pull request #48 from MonzElmasry/new_branch
Browse files Browse the repository at this point in the history
Add bootstrap option to configure helm jobs to work with rke2
  • Loading branch information
galal-hussein authored Jun 5, 2020
2 parents 118c551 + 7c0ed07 commit 989c7d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/helm.cattle.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type HelmChartSpec struct {
Set map[string]intstr.IntOrString `json:"set,omitempty"`
ValuesContent string `json:"valuesContent,omitempty"`
HelmVersion string `json:"helmVersion,omitempty"`
HostNetwork bool `json:"hostNetwork,omitempty"`
Bootstrap bool `json:"bootstrap,omitempty"`
}

type HelmChartStatus struct {
Expand Down
23 changes: 22 additions & 1 deletion pkg/helm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) {
if chart.DeletionTimestamp != nil {
action = "delete"
}

job := &batch.Job{
TypeMeta: meta.TypeMeta{
APIVersion: "batch/v1",
Expand All @@ -176,7 +177,6 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) {
},
},
Spec: core.PodSpec{
HostNetwork: chart.Spec.HostNetwork,
RestartPolicy: core.RestartPolicyOnFailure,
Containers: []core.Container{
{
Expand Down Expand Up @@ -225,6 +225,27 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap) {
},
},
}

if chart.Spec.Bootstrap {
job.Spec.Template.Spec.HostNetwork = true
job.Spec.Template.Spec.Tolerations = []core.Toleration{
{
Key: "node.kubernetes.io/not-ready",
Effect: "NoSchedule",
},
}
job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, []core.EnvVar{
{
Name: "KUBERNETES_SERVICE_HOST",
Value: "127.0.0.1"},
{
Name: "KUBERNETES_SERVICE_PORT",
Value: "6443"},
}...)
job.Spec.Template.Spec.NodeSelector = make(map[string]string)
job.Spec.Template.Spec.NodeSelector["node-role.kubernetes.io/master"] = "true"
}

setProxyEnv(job)
configMap := configMap(chart)
if configMap == nil {
Expand Down

0 comments on commit 989c7d9

Please sign in to comment.