diff --git a/docs/advanced.md b/docs/advanced.md index 4d3d8fe024..5fe9c7e745 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -20,7 +20,7 @@ RKE2 will generate the `config.toml` for containerd in `/var/lib/rancher/rke2/ag For advanced customization of this file you can create another file called `config.toml.tmpl` in the same directory and it will be used instead. -The `config.toml.tmpl` will be treated as a Go template file, and the `config.Node` structure is being passed to the template. See [this template](https://github.com/rancher/k3s/blob/master/pkg/agent/templates/templates.go#L16-L32) for an example of how to use the structure to customize the configuration file. +The `config.toml.tmpl` will be treated as a Go template file, and the `config.Node` structure is being passed to the template. See [this template](https://github.com/k3s-io/k3s/blob/master/pkg/agent/templates/templates.go#L16-L32) for an example of how to use the structure to customize the configuration file. ## Secrets Encryption Config diff --git a/docs/architecture/architecture.md b/docs/architecture/architecture.md index 95f3053a47..70169168e1 100644 --- a/docs/architecture/architecture.md +++ b/docs/architecture/architecture.md @@ -133,7 +133,7 @@ On server nodes, the `helm-controller` can now apply to the cluster any [charts] The RKE2 process will now run indefinitely until it receives a SIGTERM or SIGKILL or if the `containerd` process exits. -[gh-k3s]: "K3s - Lightweight Kubernetes" +[gh-k3s]: "K3s - Lightweight Kubernetes" [io-k3s]: "K3s - Lightweight Kubernetes" [gh-kubernetes]: "Production-Grade Container Orchestration" [io-kubernetes]: "Production-Grade Container Orchestration" diff --git a/go.mod b/go.mod index 349fd836b4..f2866b6a62 100644 --- a/go.mod +++ b/go.mod @@ -53,8 +53,8 @@ require ( github.com/containerd/containerd v1.4.3 // indirect github.com/docker/docker v17.12.0-ce-rc1.0.20200916142827-bd33bbf0497b+incompatible // indirect github.com/google/go-containerregistry v0.0.0-20190617215043-876b8855d23c + github.com/k3s-io/helm-controller v0.8.0 github.com/pkg/errors v0.9.1 - github.com/rancher/helm-controller v0.7.3 github.com/rancher/k3s v1.19.2-0.20201208230637-989c936993fb github.com/rancher/wrangler v0.6.1 github.com/sirupsen/logrus v1.6.0 diff --git a/go.sum b/go.sum index ad0cefb8a5..cac5a2fa12 100644 --- a/go.sum +++ b/go.sum @@ -718,8 +718,6 @@ github.com/rancher/go-powershell v0.0.0-20200701182037-6845e6fcfa79 h1:UeC0rjrIe github.com/rancher/go-powershell v0.0.0-20200701182037-6845e6fcfa79/go.mod h1:xi4WpK6Op4m1Lknq61/e+VSjYlTs9bulVOaDNyBdzvk= github.com/rancher/go-powershell v0.0.0-20200701184732-233247d45373 h1:BePi97poJ4hXnkP9yX96EmNQgMg+dGScvB1sqIheJ7w= github.com/rancher/go-powershell v0.0.0-20200701184732-233247d45373/go.mod h1:Vz8oLnHgttpo/aZrTpjbcpZEDzzElqNau2zmorToY0E= -github.com/rancher/helm-controller v0.7.3 h1:WTQHcNF2vl9w6Xd1eBtXDe0JUsYMFFstqX9ghGhI5Ac= -github.com/rancher/helm-controller v0.7.3/go.mod h1:ZylsxIMGNADRPRNW+NiBWhrwwks9vnKLQiCHYWb6Bi0= github.com/rancher/k3s v1.19.2-0.20201208230637-989c936993fb h1:cF4MWn0eTyR3itEDw5B6lvQ8OfJfrI2brTaiU4cuD0w= github.com/rancher/k3s v1.19.2-0.20201208230637-989c936993fb/go.mod h1:5nBcSUFkqkYJlBKrqe82Vk5oiE5qwaGz+YOTFKimusE= github.com/rancher/moq v0.0.0-20190404221404-ee5226d43009/go.mod h1:wpITyDPTi/Na5h73XkbuEf2AP9fbgrIGqqxVzFhYD6U= diff --git a/pkg/bootstrap/bootstrap.go b/pkg/bootstrap/bootstrap.go index b9f6c68733..23a20073c0 100644 --- a/pkg/bootstrap/bootstrap.go +++ b/pkg/bootstrap/bootstrap.go @@ -18,9 +18,9 @@ import ( "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/google/go-containerregistry/pkg/v1/remote" "github.com/google/go-containerregistry/pkg/v1/tarball" + helmv1 "github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io/v1" + "github.com/k3s-io/helm-controller/pkg/helm" errors2 "github.com/pkg/errors" - helmv1 "github.com/rancher/helm-controller/pkg/apis/helm.cattle.io/v1" - "github.com/rancher/helm-controller/pkg/helm" "github.com/rancher/rke2/pkg/images" "github.com/rancher/wrangler/pkg/merr" "github.com/rancher/wrangler/pkg/schemes" @@ -124,9 +124,9 @@ func Stage(dataDir string, imageConf images.Images) (string, error) { } } - // Fix up HelmCharts to set default registry + // Fix up HelmCharts to pass through configured values // This needs to be done every time in order to sync values from the CLI - if err := setSystemDefaultRegistry(manifestsDir, imageConf.SystemDefaultRegistry); err != nil { + if err := setChartValues(dataDir, imageConf.SystemDefaultRegistry); err != nil { return "", err } @@ -307,13 +307,14 @@ func preloadBootstrapImage(dataDir string, imageName string) (v1.Image, error) { return nil, nil } -// setSystemDefaultRegistry scans the directory at manifestDir. It attempts to load all manifests +// setChartValues scans the directory at manifestDir. It attempts to load all manifests // in that directory as HelmCharts. Any manifests that contain a HelmChart are modified to -// pass through the systemDefaultRegistry setting to both the Helm job and the chart values. +// pass through settings to both the Helm job and the chart values. // NOTE: This will probably fail if any manifest contains multiple documents. This should // not matter for any of our packaged components, but may prevent this from working on user manifests. -func setSystemDefaultRegistry(manifestsDir string, systemDefaultRegistry string) error { +func setChartValues(dataDir string, systemDefaultRegistry string) error { serializer := json.NewSerializerWithOptions(json.DefaultMetaFactory, schemes.All, schemes.All, json.SerializerOptions{Yaml: true, Pretty: true, Strict: true}) + manifestsDir := manifestsDir(dataDir) files := map[string]os.FileInfo{} if err := filepath.Walk(manifestsDir, func(path string, info os.FileInfo, err error) error { @@ -336,17 +337,17 @@ func setSystemDefaultRegistry(manifestsDir string, systemDefaultRegistry string) var errs []error for fileName, info := range files { - if err := rewriteChart(fileName, info, systemDefaultRegistry, serializer); err != nil { + if err := rewriteChart(fileName, info, dataDir, systemDefaultRegistry, serializer); err != nil { errs = append(errs, err) } } return merr.NewErrors(errs...) } -// rewriteChart applies systemDefaultRegistry settings to the file at fileName with associated info. +// rewriteChart applies dataDir and systemDefaultRegistry settings to the file at fileName with associated info. // If the file cannot be decoded as a HelmChart, it is silently skipped. Any other IO error is considered // a failure. -func rewriteChart(fileName string, info os.FileInfo, systemDefaultRegistry string, serializer *json.Serializer) error { +func rewriteChart(fileName string, info os.FileInfo, dataDir, systemDefaultRegistry string, serializer *json.Serializer) error { chartChanged := false bytes, err := ioutil.ReadFile(fileName) @@ -364,16 +365,22 @@ func rewriteChart(fileName string, info os.FileInfo, systemDefaultRegistry strin // Ignore manifest if it is not a HelmChart chart, ok := obj.(*helmv1.HelmChart) if !ok { - logrus.Debugf("Manifest %q is not a HelmChart", fileName) + logrus.Debugf("Manifest %q is %T, not HelmChart", fileName, obj) return nil } // Generally we should avoid using Set on HelmCharts since it cannot be overridden by HelmChartConfig, // but in this case we need to do it in order to avoid potentially mangling the ValuesContent field by - // blindly appending content to it in order to set the global.systemDefaultRegistry value. + // blindly appending content to it in order to set values. if chart.Spec.Set == nil { chart.Spec.Set = map[string]intstr.IntOrString{} } + + if chart.Spec.Set["global.rke2DataDir"].StrVal != dataDir { + chart.Spec.Set["global.rke2DataDir"] = intstr.FromString(dataDir) + chartChanged = true + } + if chart.Spec.Set["global.systemDefaultRegistry"].StrVal != systemDefaultRegistry { chart.Spec.Set["global.systemDefaultRegistry"] = intstr.FromString(systemDefaultRegistry) chartChanged = true diff --git a/scripts/build-images b/scripts/build-images index 342393a4fa..27c8187499 100755 --- a/scripts/build-images +++ b/scripts/build-images @@ -15,7 +15,7 @@ xargs -n1 -t docker image pull --quiet << EOF > build/images.txt docker.io/rancher/hardened-flannel:v0.13.0-rancher1 docker.io/rancher/hardened-k8s-metrics-server:v0.3.6 docker.io/rancher/hardened-kube-proxy:${KUBERNETES_VERSION} - docker.io/rancher/klipper-helm:v0.3.0 + docker.io/rancher/klipper-helm:v0.3.2 docker.io/rancher/pause:3.2 docker.io/rancher/nginx-ingress-controller-defaultbackend:1.5-rancher1 docker.io/rancher/nginx-ingress-controller:nginx-0.30.0-rancher1