Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cni): taint controller #4650

Merged
merged 41 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4d096dd
feat(cni): add delay to the cni startup and a failing test
slonka Jul 21, 2022
86476d4
feat(cni): make check pass
slonka Jul 21, 2022
ac24d98
feat(cni): taint controller e2e test passes
slonka Jul 24, 2022
47abf1a
feat(cni): add post meet comments and use kuma version instead of a h…
slonka Jul 25, 2022
8644d88
feat(cni): hook up new test into CI
slonka Jul 25, 2022
f4516ab
feat(cni): make check pass
slonka Jul 25, 2022
5ac9872
feat(cni): update golden files
slonka Jul 25, 2022
8939e78
feat(cni): make k3d makefile target use k3d
slonka Jul 25, 2022
c795ea2
feat(cni): fix target name
slonka Jul 25, 2022
6e4d858
feat(cni): update golden files
slonka Jul 25, 2022
012ff3e
feat(cni): add test that shows old cni is susceptible to the race con…
slonka Jul 26, 2022
9e498b4
feat(cni): clean up
slonka Jul 27, 2022
6553ac5
feat(cni): remove separate target
slonka Jul 27, 2022
b651262
feat(cni): self review fixes
slonka Jul 27, 2022
87611c6
feat(cni): move kind not supported flag to circleci config
slonka Jul 27, 2022
cc6e2a6
feat(cni): move create delete node to k8s implementation
slonka Jul 28, 2022
8866b3c
feat(cni): move filter label back to makefile
slonka Jul 28, 2022
66ae209
Update app/cni/pkg/install/main.go
slonka Jul 29, 2022
1dfad5f
feat(cni): apply review suggestions
slonka Jul 29, 2022
0564256
chore: merge with master
slonka Jul 29, 2022
66aab3e
Merge branch 'master' into feat/add-cni-taint-controller
slonka Jul 29, 2022
ef6e801
feat(cni): add index on spec node name
slonka Jul 29, 2022
cee53d9
Merge branch 'feat/add-cni-taint-controller' of github.com:slonka/kum…
slonka Jul 29, 2022
4cdedd9
feat(cni): remove no longer needed comment
slonka Aug 1, 2022
b58865f
feat(cni): apply review suggestions
slonka Aug 2, 2022
ee78af6
feat(cni): remove if around sleep
slonka Aug 2, 2022
f66140a
feat(cni): fix tests
slonka Aug 2, 2022
c35b5c6
feat(cni): shorten the waiting time
slonka Aug 2, 2022
fec6dd5
feat(cni): remove arm not supported label from new cni test
slonka Aug 2, 2022
30bb406
fix(cni): tmp
slonka Aug 3, 2022
7990c47
feat(cni): apply review suggestions
slonka Aug 4, 2022
67fbd7a
chore: merge with master
slonka Aug 4, 2022
a1ac880
feat(cni): update golden files
slonka Aug 4, 2022
7e1259b
fix(cni): make check pass
slonka Aug 4, 2022
63c05ee
fix(cni): remove filtering of nodes
slonka Aug 4, 2022
55a9aa8
chore: fix bad merge
slonka Aug 4, 2022
b9c1cf4
fix(cni): check that node name exists for both old and new object
slonka Aug 4, 2022
8dad501
Revert "fix(cni): check that node name exists for both old and new ob…
slonka Aug 4, 2022
e801dc1
fix(cni): udpate comment
slonka Aug 4, 2022
f6c9a77
fix(cni): change log level
slonka Aug 4, 2022
92cacba
fix(cni): put pod filtering in mapper because it is more performant
slonka Aug 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ jobs:
export K3D=true
fi
if [[ "<< parameters.arch >>" == "arm64" ]]; then
export GINKGO_E2E_TEST_FLAGS="--label-filter=\"!arm-not-supported\""
export GINKGO_E2E_TEST_FLAGS="$GINKGO_E2E_TEST_FLAGS --label-filter=\"!arm-not-supported\""
slonka marked this conversation as resolved.
Show resolved Hide resolved
export MAKE_PARAMETERS="-j1"
else
export MAKE_PARAMETERS="-j2"
Expand Down
14 changes: 14 additions & 0 deletions app/cni/pkg/install/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os/signal"
"path"
"path/filepath"
"strings"
"syscall"
"time"

Expand All @@ -23,6 +24,7 @@ const (
primaryBinDir = "/host/opt/cni/bin"
secondaryBinDir = "/host/secondary-bin-dir"
serviceAccountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
readyFilePath = "/tmp/ready"
)

var (
Expand Down Expand Up @@ -50,6 +52,11 @@ func cleanup(ic *InstallerConfig) {
} else {
log.V(1).Info("removed kubeconfig")
}
if err := os.Remove(readyFilePath); err != nil {
log.Error(err, "couldn't remove ready file")
} else {
log.V(1).Info("removed ready file")
}
log.Info("finished cleanup")
}

Expand Down Expand Up @@ -213,12 +220,19 @@ func Run() {
log.Error(err, "error occurred during config loading")
os.Exit(1)
}

err = install(installerConfig)
if err != nil {
log.Error(err, "error occurred during cni installation")
os.Exit(1)
}

err = atomic.WriteFile(readyFilePath, strings.NewReader(""))
if err != nil {
log.Error(err, "unable to mark as ready")
os.Exit(1)
}

if err := runLoop(installerConfig); err != nil {
log.Error(err, "checking installation failed - exiting")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type InstallControlPlaneArgs struct {
Cni_image_registry string `helm:"cni.image.registry,omitempty"`
Cni_image_repository string `helm:"cni.image.repository"`
Cni_image_tag string `helm:"cni.image.tag"`
Cni_imageExperimental_repository string `helm:"cni.imageExperimental.repository"`
Cni_imageExperimental_tag string `helm:"cni.imageExperimental.tag"`
Cni_experimental_image_repository string `helm:"cni.experimental.image.repository"`
Cni_experimental_image_tag string `helm:"cni.experimental.image.tag"`
Cni_nodeSelector map[string]string `helm:"cni.nodeSelector"`
ControlPlane_mode string `helm:"controlPlane.mode"`
ControlPlane_zone string `helm:"controlPlane.zone"`
Expand Down Expand Up @@ -106,8 +106,8 @@ func DefaultInstallCpContext() InstallCpContext {
Cni_image_registry: "",
Cni_image_repository: "install-cni",
Cni_image_tag: "0.0.10",
Cni_imageExperimental_repository: "kuma-cni",
Cni_imageExperimental_tag: kuma_version.Build.Version,
Cni_experimental_image_repository: "kuma-cni",
Cni_experimental_image_tag: kuma_version.Build.Version,
ControlPlane_mode: core.Standalone,
ControlPlane_zone: "",
ControlPlane_globalZoneSyncService_type: "LoadBalancer",
Expand Down
2 changes: 1 addition & 1 deletion app/kumactl/cmd/install/install_control_plane.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (cv *componentVersion) Set(v string) error {
cv.args.ControlPlane_image_tag = v
cv.args.DataPlane_image_tag = v
cv.args.DataPlane_initImage_tag = v
cv.args.Cni_imageExperimental_tag = v
cv.args.Cni_experimental_image_tag = v
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,8 @@ spec:
- name: install-cni
image: "docker.io/kumahq/install-cni:0.0.10"
imagePullPolicy: Always
command: ["/install-cni.sh"]
command: [ "/bin/sh", "-c", "--" ]
args: [ "sleep 0 && exec /install-cni.sh" ]
env:
# Name of the CNI config file to create.
- name: CNI_CONF_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,18 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- nodes
verbs:
- update
- apiGroups:
- "pods"
resources:
- pods
verbs:
- list
# validate k8s token before issuing mTLS cert
- apiGroups:
- authentication.k8s.io
Expand Down Expand Up @@ -1978,7 +1990,14 @@ spec:
- name: install-cni
image: "docker.io/kumahq/kuma-cni:0.0.1"
imagePullPolicy: IfNotPresent
command: ["/install-cni"]
readinessProbe:
initialDelaySeconds: 0
exec:
command:
- cat
- /tmp/ready
command: [ "/bin/sh", "-c", "--" ]
args: [ "sleep 0 && exec /install-cni" ]
env:
# Name of the CNI config file to create.
- name: CNI_CONF_NAME
Expand Down Expand Up @@ -2075,12 +2094,16 @@ spec:
value: "false"
- name: KUMA_API_SERVER_READ_ONLY
value: "true"
- name: KUMA_CNI_APP
value: "kuma-cni"
- name: KUMA_DEFAULTS_SKIP_MESH_CREATION
value: "false"
- name: KUMA_DP_SERVER_HDS_ENABLED
value: "false"
- name: KUMA_ENVIRONMENT
value: "kubernetes"
- name: KUMA_EXPERIMENTAL_CNI
value: "true"
- name: KUMA_GENERAL_TLS_CERT_FILE
value: "/var/run/secrets/kuma.io/tls-cert/tls.crt"
- name: KUMA_GENERAL_TLS_KEY_FILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,16 @@ cni:
# -- CNI image tag
tag: "0.0.10"

# -- it's only useful in tests to trigger a possible race condition
delayStartupSeconds: 0

# -- use new CNI image (experimental)
imageExperimental:
# -- CNI experimental image repository
repository: "kuma-cni"
# -- CNI experimental image tag - defaults to .Chart.AppVersion
tag:
experimental:
image:
# -- CNI experimental image repository
repository: "kuma-cni"
# -- CNI experimental image tag - defaults to .Chart.AppVersion
tag:

# -- Security context at the pod level for cni
podSecurityContext: {}
Expand Down
7 changes: 4 additions & 3 deletions deployments/charts/kuma/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ A Helm chart for the Kuma Control Plane
| cni.image.registry | string | `"docker.io/kumahq"` | CNI image registry |
| cni.image.repository | string | `"install-cni"` | CNI image repository |
| cni.image.tag | string | `"0.0.10"` | CNI image tag |
| cni.imageExperimental | object | `{"repository":"kuma-cni","tag":null}` | use new CNI image (experimental) |
| cni.imageExperimental.repository | string | `"kuma-cni"` | CNI experimental image repository |
| cni.imageExperimental.tag | string | `nil` | CNI experimental image tag - defaults to .Chart.AppVersion |
| cni.delayStartupSeconds | int | `0` | it's only useful in tests to trigger a possible race condition |
slonka marked this conversation as resolved.
Show resolved Hide resolved
| cni.experimental | object | `{"image":{"repository":"kuma-cni","tag":null}}` | use new CNI image (experimental) |
| cni.experimental.image.repository | string | `"kuma-cni"` | CNI experimental image repository |
| cni.experimental.image.tag | string | `nil` | CNI experimental image tag - defaults to .Chart.AppVersion |
| cni.podSecurityContext | object | `{}` | Security context at the pod level for cni |
| cni.containerSecurityContext | object | `{}` | Security context at the container level for cni |
| dataPlane.image.repository | string | `"kuma-dp"` | The Kuma DP image repository |
Expand Down
6 changes: 6 additions & 0 deletions deployments/charts/kuma/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ env:
- name: KUMA_EXPERIMENTAL_GATEWAY_API
value: "true"
{{- end }}
{{- if .Values.experimental.cni }}
- name: KUMA_EXPERIMENTAL_CNI
value: "true"
slonka marked this conversation as resolved.
Show resolved Hide resolved
- name: KUMA_CNI_APP
value: "kuma-cni"
{{- end }}
{{- if .Values.experimental.ebpf.enabled }}
- name: KUMA_RUNTIME_KUBERNETES_INJECTOR_EBPF_ENABLED
value: "true"
Expand Down
14 changes: 11 additions & 3 deletions deployments/charts/kuma/templates/cni-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,21 @@ spec:
containers:
- name: install-cni
{{- if .Values.experimental.cni }}
image: {{ include "kuma.formatImage" (dict "image" .Values.cni.imageExperimental "root" $) | quote }}
image: {{ include "kuma.formatImage" (dict "image" .Values.cni.experimental.image "root" $) | quote }}
imagePullPolicy: IfNotPresent
command: ["/install-cni"]
readinessProbe:
initialDelaySeconds: {{ .Values.cni.delayStartupSeconds }}
exec:
command:
- cat
- /tmp/ready
command: [ "/bin/sh", "-c", "--" ]
args: [ "sleep {{.Values.cni.delayStartupSeconds}} && exec /install-cni" ]
{{- else }}
slonka marked this conversation as resolved.
Show resolved Hide resolved
image: {{ include "kuma.formatImage" (dict "image" .Values.cni.image "root" $) | quote }}
imagePullPolicy: Always
command: ["/install-cni.sh"]
command: [ "/bin/sh", "-c", "--" ]
args: [ "sleep {{.Values.cni.delayStartupSeconds}} && exec /install-cni.sh" ]
{{- end }}
{{- if .Values.cni.containerSecurityContext }}
securityContext:
Expand Down
14 changes: 14 additions & 0 deletions deployments/charts/kuma/templates/cp-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,20 @@ rules:
- get
- list
- watch
{{- if .Values.experimental.cni }}
- apiGroups:
- ""
resources:
- nodes
verbs:
- update
- apiGroups:
- "pods"
resources:
- pods
verbs:
- list
{{- end }}
{{- end }}
# validate k8s token before issuing mTLS cert
- apiGroups:
Expand Down
14 changes: 9 additions & 5 deletions deployments/charts/kuma/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,16 @@ cni:
# -- CNI image tag
tag: "0.0.10"

# -- it's only useful in tests to trigger a possible race condition
delayStartupSeconds: 0

# -- use new CNI image (experimental)
imageExperimental:
# -- CNI experimental image repository
repository: "kuma-cni"
# -- CNI experimental image tag - defaults to .Chart.AppVersion
tag:
experimental:
image:
# -- CNI experimental image repository
repository: "kuma-cni"
# -- CNI experimental image tag - defaults to .Chart.AppVersion
tag:

# -- Security context at the pod level for cni
podSecurityContext: {}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ require (
github.com/testcontainers/testcontainers-go v0.13.0
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.21.0
golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a
Expand Down Expand Up @@ -180,7 +181,6 @@ require (
go.opencensus.io v0.23.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/exp v0.0.0-20220407100705-7b9b53b0aca4 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
Expand Down
1 change: 1 addition & 0 deletions mk/e2e.new.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ K8S_CLUSTER_TOOL=k3d
E2E_ENV_VARS += KUMA_K8S_TYPE=k3d
else
K8S_CLUSTER_TOOL=kind
GINKGO_E2E_TEST_FLAGS += --label-filter="!kind-not-supported"
lahabana marked this conversation as resolved.
Show resolved Hide resolved
endif

ifdef IPV6
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/app/kuma-cp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ type ExperimentalConfig struct {
// If true, instead of embedding kubernetes outbounds into Dataplane object, they are persisted next to VIPs in ConfigMap
// This can improve performance, but it should be enabled only after all instances are migrated to version that supports this config
KubeOutboundsAsVIPs bool `yaml:"kubeOutboundsAsVIPs" envconfig:"KUMA_EXPERIMENTAL_KUBE_OUTBOUNDS_AS_VIPS"`

// If true, new experimental CNI taint controller is enabled
Cni bool `yaml:"cni" envconfig:"KUMA_EXPERIMENTAL_CNI"`
// Name of the CNI pod
CniApp string `yaml:"cniApp" envconfig:"KUMA_CNI_APP"`
}

func (e ExperimentalConfig) Validate() error {
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ var _ = Describe("Config loader", func() {
Expect(cfg.Access.Static.ViewClusters.Groups).To(Equal([]string{"zt-group1", "zt-group2"}))

Expect(cfg.Experimental.GatewayAPI).To(BeTrue())
Expect(cfg.Experimental.Cni).To(BeTrue())
Expect(cfg.Experimental.CniApp).To(Equal("kuma-cni"))
Expect(cfg.Experimental.KubeOutboundsAsVIPs).To(BeTrue())
},
Entry("from config file", testCase{
Expand Down Expand Up @@ -490,6 +492,8 @@ access:
experimental:
gatewayAPI: true
kubeOutboundsAsVIPs: true
cni: true
cniApp: "kuma-cni"
`,
}),
Entry("from env variables", testCase{
Expand Down Expand Up @@ -648,6 +652,8 @@ experimental:
"KUMA_ACCESS_STATIC_VIEW_CLUSTERS_USERS": "zt-admin1,zt-admin2",
"KUMA_ACCESS_STATIC_VIEW_CLUSTERS_GROUPS": "zt-group1,zt-group2",
"KUMA_EXPERIMENTAL_GATEWAY_API": "true",
"KUMA_EXPERIMENTAL_CNI": "true",
"KUMA_CNI_APP": "kuma-cni",
"KUMA_EXPERIMENTAL_KUBE_OUTBOUNDS_AS_VIPS": "true",
},
yamlFileConfig: "",
Expand Down
Loading