Commit 1769e7ed authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Bump helm-controller to v0.10.2

parent e365bc71
...@@ -90,7 +90,7 @@ require ( ...@@ -90,7 +90,7 @@ require (
github.com/google/uuid v1.2.0 github.com/google/uuid v1.2.0
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2 github.com/gorilla/websocket v1.4.2
github.com/k3s-io/helm-controller v0.8.3 github.com/k3s-io/helm-controller v0.10.3
github.com/k3s-io/kine v0.6.2 github.com/k3s-io/kine v0.6.2
github.com/klauspost/compress v1.12.2 github.com/klauspost/compress v1.12.2
github.com/kubernetes-sigs/cri-tools v0.0.0-00010101000000-000000000000 github.com/kubernetes-sigs/cri-tools v0.0.0-00010101000000-000000000000
......
...@@ -520,8 +520,8 @@ github.com/k3s-io/go-powershell v0.0.0-20200701182037-6845e6fcfa79 h1:9naOL3iARE ...@@ -520,8 +520,8 @@ github.com/k3s-io/go-powershell v0.0.0-20200701182037-6845e6fcfa79 h1:9naOL3iARE
github.com/k3s-io/go-powershell v0.0.0-20200701182037-6845e6fcfa79/go.mod h1:lsDHcxq5ugFJff6YHEwpzLh31NDv0B2cIKki1ViQ65o= github.com/k3s-io/go-powershell v0.0.0-20200701182037-6845e6fcfa79/go.mod h1:lsDHcxq5ugFJff6YHEwpzLh31NDv0B2cIKki1ViQ65o=
github.com/k3s-io/go-powershell v0.0.0-20201118222746-51f4c451fbd7 h1:C+6IIP6yECS10qkq2EeGQjr2ts0k7UxrutGF+pLPSnU= github.com/k3s-io/go-powershell v0.0.0-20201118222746-51f4c451fbd7 h1:C+6IIP6yECS10qkq2EeGQjr2ts0k7UxrutGF+pLPSnU=
github.com/k3s-io/go-powershell v0.0.0-20201118222746-51f4c451fbd7/go.mod h1:wJnuh+xbDmskSfAM3UikTsGO8kaWLu3iycSgUKAiYjQ= github.com/k3s-io/go-powershell v0.0.0-20201118222746-51f4c451fbd7/go.mod h1:wJnuh+xbDmskSfAM3UikTsGO8kaWLu3iycSgUKAiYjQ=
github.com/k3s-io/helm-controller v0.8.3 h1:GWxavyMz7Bw2ClxH5okkeOL8o5U6IBK7uauc44SDCjU= github.com/k3s-io/helm-controller v0.10.3 h1:P4VK98VzTSjReQfmjOk0se437dWbdqIRVfuXFNoR6/8=
github.com/k3s-io/helm-controller v0.8.3/go.mod h1:nZP8FH3KZrNNUf5r+SwwiMR63HS6lxdHdpHijgPfF74= github.com/k3s-io/helm-controller v0.10.3/go.mod h1:nZP8FH3KZrNNUf5r+SwwiMR63HS6lxdHdpHijgPfF74=
github.com/k3s-io/kine v0.6.2 h1:1aJTPfB8HG4exqMKFVE5H0z4bepF05tJHtYNXotWXa4= github.com/k3s-io/kine v0.6.2 h1:1aJTPfB8HG4exqMKFVE5H0z4bepF05tJHtYNXotWXa4=
github.com/k3s-io/kine v0.6.2/go.mod h1:rzCs93+rQHZGOiewMd84PDrER92QeZ6eeHbWkfEy4+w= github.com/k3s-io/kine v0.6.2/go.mod h1:rzCs93+rQHZGOiewMd84PDrER92QeZ6eeHbWkfEy4+w=
github.com/k3s-io/kubernetes v1.20.9-k3s1 h1:4wMCFw3JKCP02PRlSpSuM3ydpiHrotfY265n8wE/7UQ= github.com/k3s-io/kubernetes v1.20.9-k3s1 h1:4wMCFw3JKCP02PRlSpSuM3ydpiHrotfY265n8wE/7UQ=
......
...@@ -34,7 +34,7 @@ var ( ...@@ -34,7 +34,7 @@ var (
) )
const ( const (
image = "rancher/klipper-lb:v0.1.2" image = "rancher/klipper-lb:v0.2.0"
Ready = condition.Cond("Ready") Ready = condition.Cond("Ready")
) )
......
docker.io/rancher/coredns-coredns:1.8.3 docker.io/rancher/coredns-coredns:1.8.3
docker.io/rancher/klipper-helm:v0.4.3 docker.io/rancher/klipper-helm:v0.6.3-build20210804
docker.io/rancher/klipper-lb:v0.1.2 docker.io/rancher/klipper-lb:v0.2.0
docker.io/rancher/library-busybox:1.32.1 docker.io/rancher/library-busybox:1.32.1
docker.io/rancher/library-traefik:1.7.19 docker.io/rancher/library-traefik:1.7.19
docker.io/rancher/local-path-provisioner:v0.0.19 docker.io/rancher/local-path-provisioner:v0.0.19
......
...@@ -27,6 +27,7 @@ type HelmChartSpec struct { ...@@ -27,6 +27,7 @@ type HelmChartSpec struct {
Bootstrap bool `json:"bootstrap,omitempty"` Bootstrap bool `json:"bootstrap,omitempty"`
ChartContent string `json:"chartContent,omitempty"` ChartContent string `json:"chartContent,omitempty"`
JobImage string `json:"jobImage,omitempty"` JobImage string `json:"jobImage,omitempty"`
Timeout *metav1.Duration `json:"timeout,omitempty"`
} }
type HelmChartStatus struct { type HelmChartStatus struct {
......
...@@ -21,6 +21,7 @@ limitations under the License. ...@@ -21,6 +21,7 @@ limitations under the License.
package v1 package v1
import ( import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime" runtime "k8s.io/apimachinery/pkg/runtime"
intstr "k8s.io/apimachinery/pkg/util/intstr" intstr "k8s.io/apimachinery/pkg/util/intstr"
) )
...@@ -172,6 +173,11 @@ func (in *HelmChartSpec) DeepCopyInto(out *HelmChartSpec) { ...@@ -172,6 +173,11 @@ func (in *HelmChartSpec) DeepCopyInto(out *HelmChartSpec) {
(*out)[key] = val (*out)[key] = val
} }
} }
if in.Timeout != nil {
in, out := &in.Timeout, &out.Timeout
*out = new(metav1.Duration)
**out = **in
}
return return
} }
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"crypto/sha256" "crypto/sha256"
"fmt" "fmt"
"os" "os"
"regexp"
"sort" "sort"
"strings" "strings"
...@@ -27,7 +28,9 @@ import ( ...@@ -27,7 +28,9 @@ import (
) )
var ( var (
trueVal = true trueVal = true
commaRE = regexp.MustCompile(`\\*,`)
DefaultJobImage = "rancher/klipper-helm:v0.6.3-build20210804"
) )
type Controller struct { type Controller struct {
...@@ -39,12 +42,11 @@ type Controller struct { ...@@ -39,12 +42,11 @@ type Controller struct {
} }
const ( const (
DefaultJobImage = "rancher/klipper-helm:v0.4.3" Label = "helmcharts.helm.cattle.io/chart"
Label = "helmcharts.helm.cattle.io/chart" Annotation = "helmcharts.helm.cattle.io/configHash"
Annotation = "helmcharts.helm.cattle.io/configHash" CRDName = "helmcharts.helm.cattle.io"
CRDName = "helmcharts.helm.cattle.io" ConfigCRDName = "helmchartconfigs.helm.cattle.io"
ConfigCRDName = "helmchartconfigs.helm.cattle.io" Name = "helm-controller"
Name = "helm-controller"
) )
func Register(ctx context.Context, apply apply.Apply, func Register(ctx context.Context, apply apply.Apply,
...@@ -270,23 +272,40 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap, *core.ConfigMap) ...@@ -270,23 +272,40 @@ func job(chart *helmv1.HelmChart) (*batch.Job, *core.ConfigMap, *core.ConfigMap)
}, },
} }
if chart.Spec.Timeout != nil {
job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, core.EnvVar{
Name: "TIMEOUT",
Value: chart.Spec.Timeout.String(),
})
}
if chart.Spec.Bootstrap { if chart.Spec.Bootstrap {
job.Spec.Template.Spec.HostNetwork = true job.Spec.Template.Spec.HostNetwork = true
job.Spec.Template.Spec.Tolerations = []core.Toleration{ job.Spec.Template.Spec.Tolerations = []core.Toleration{
{ {
Key: "node.kubernetes.io/not-ready", Key: "node.kubernetes.io/not-ready",
Effect: "NoSchedule", Effect: core.TaintEffectNoSchedule,
}, },
{ {
Key: "node.cloudprovider.kubernetes.io/uninitialized", Key: "node.cloudprovider.kubernetes.io/uninitialized",
Operator: core.TolerationOpEqual, Operator: core.TolerationOpEqual,
Value: "true", Value: "true",
Effect: "NoSchedule", Effect: core.TaintEffectNoSchedule,
}, },
{ {
Key: "CriticalAddonsOnly", Key: "CriticalAddonsOnly",
Operator: core.TolerationOpExists, Operator: core.TolerationOpExists,
}, },
{
Key: "node-role.kubernetes.io/etcd",
Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoExecute,
},
{
Key: "node-role.kubernetes.io/control-plane",
Operator: core.TolerationOpExists,
Effect: core.TaintEffectNoSchedule,
},
} }
job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, []core.EnvVar{ job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, []core.EnvVar{
{ {
...@@ -397,12 +416,10 @@ func args(chart *helmv1.HelmChart) []string { ...@@ -397,12 +416,10 @@ func args(chart *helmv1.HelmChart) []string {
for _, k := range keys(spec.Set) { for _, k := range keys(spec.Set) {
val := spec.Set[k] val := spec.Set[k]
if val.StrVal == "false" || val.StrVal == "true" { if typedVal(val) {
args = append(args, "--set", fmt.Sprintf("%s=%s", k, val.StrVal)) args = append(args, "--set", fmt.Sprintf("%s=%s", k, val.String()))
} else if val.StrVal != "" {
args = append(args, "--set-string", fmt.Sprintf("%s=%s", k, val.StrVal))
} else { } else {
args = append(args, "--set", fmt.Sprintf("%s=%d", k, val.IntVal)) args = append(args, "--set-string", fmt.Sprintf("%s=%s", k, commaRE.ReplaceAllStringFunc(val.String(), escapeComma)))
} }
} }
...@@ -418,6 +435,33 @@ func keys(val map[string]intstr.IntOrString) []string { ...@@ -418,6 +435,33 @@ func keys(val map[string]intstr.IntOrString) []string {
return keys return keys
} }
// typedVal is a modified version of helm's typedVal function that operates on kubernetes IntOrString types.
// Things that look like an integer, boolean, or null should use --set; everything else should use --set-string.
// Ref: https://github.com/helm/helm/blob/v3.5.4/pkg/strvals/parser.go#L415
func typedVal(val intstr.IntOrString) bool {
if intstr.Int == val.Type {
return true
}
switch strings.ToLower(val.StrVal) {
case "true", "false", "null":
return true
default:
return false
}
}
// escapeComma should be passed a string consisting of zero or more backslashes, followed by a comma.
// If there are an even number of characters (such as `\,` or `\\\,`) then the comma is escaped.
// If there are an uneven number of characters (such as `,` or `\\,` then the comma is not escaped,
// and we need to escape it by adding an additional backslash.
// This logic is difficult if not impossible to accomplish with a simple regex submatch replace.
func escapeComma(match string) string {
if len(match)%2 == 1 {
match = `\` + match
}
return match
}
func setProxyEnv(job *batch.Job) { func setProxyEnv(job *batch.Job) {
proxySysEnv := []string{ proxySysEnv := []string{
"all_proxy", "all_proxy",
......
...@@ -686,7 +686,7 @@ github.com/json-iterator/go ...@@ -686,7 +686,7 @@ github.com/json-iterator/go
# github.com/k3s-io/go-powershell v0.0.0-20200701182037-6845e6fcfa79 # github.com/k3s-io/go-powershell v0.0.0-20200701182037-6845e6fcfa79
github.com/k3s-io/go-powershell/backend github.com/k3s-io/go-powershell/backend
github.com/k3s-io/go-powershell/utils github.com/k3s-io/go-powershell/utils
# github.com/k3s-io/helm-controller v0.8.3 # github.com/k3s-io/helm-controller v0.10.3
## explicit ## explicit
github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io
github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io/v1 github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io/v1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment