From aebad9242665b4073b2100eed02e0a4614ea09fb Mon Sep 17 00:00:00 2001 From: stefanprodan Date: Thu, 23 Jul 2020 09:59:45 +0300 Subject: [PATCH] Add linux/amd64 node selector to controllers Set nodeSelector to linux/amd64 for clusters with mixed nodes (linux, windows, amd64, arm). --- cmd/tk/install.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmd/tk/install.go b/cmd/tk/install.go index 3305de23..3ca3b282 100644 --- a/cmd/tk/install.go +++ b/cmd/tk/install.go @@ -188,8 +188,10 @@ var kustomizationTmpl = `--- apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization namespace: {{.Namespace}} + transformers: - labels.yaml + resources: - namespace.yaml - policies.yaml @@ -198,6 +200,11 @@ resources: - {{.}}.yaml {{- end }} +patches: +- path: node-selector.yaml + target: + kind: Deployment + patchesJson6902: {{- range $i, $v := .Components }} {{- if ne $v "notification-controller" }} @@ -222,6 +229,19 @@ resources: nameSuffix: -{{.Namespace}} ` +var nodeSelectorTmpl = `--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: all +spec: + template: + spec: + nodeSelector: + kubernetes.io/arch: amd64 + kubernetes.io/os: linux +` + func downloadManifests(version string, tmpDir string) error { ghURL := "https://github.com/fluxcd/toolkit/releases/latest/download/manifests.tar.gz" if strings.HasPrefix(version, "v") { @@ -286,6 +306,10 @@ func genInstallManifests(version string, namespace string, components []string, return fmt.Errorf("generate labels failed: %w", err) } + if err := utils.execTemplate(model, nodeSelectorTmpl, path.Join(tmpDir, "node-selector.yaml")); err != nil { + return fmt.Errorf("generate node selector failed: %w", err) + } + if err := utils.execTemplate(model, kustomizationTmpl, path.Join(tmpDir, "kustomization.yaml")); err != nil { return fmt.Errorf("generate kustomization failed: %w", err) }