Skip to content

Commit

Permalink
Use components.UsesKubenet to check if Kubenet is required
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciprian Hacman committed May 19, 2020
1 parent e608cd5 commit 9d666c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions nodeup/pkg/model/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ go_library(
"//pkg/k8scodecs:go_default_library",
"//pkg/kubeconfig:go_default_library",
"//pkg/kubemanifest:go_default_library",
"//pkg/model/components:go_default_library",
"//pkg/nodelabels:go_default_library",
"//pkg/pki:go_default_library",
"//pkg/rbac:go_default_library",
Expand Down
7 changes: 6 additions & 1 deletion nodeup/pkg/model/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/kops/nodeup/pkg/model/resources"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/model/components"
"k8s.io/kops/pkg/systemd"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
Expand Down Expand Up @@ -338,7 +339,11 @@ func (b *ContainerdBuilder) Build(c *fi.ModelBuilderContext) error {
// Using containerd with Kubenet requires special configuration. This is a temporary backwards-compatible solution
// and will be deprecated when Kubenet is deprecated:
// https://github.com/containerd/cri/blob/master/docs/config.md#cni-config-template
if b.Cluster.Spec.ContainerRuntime == "containerd" && b.Cluster.Spec.Networking != nil && b.Cluster.Spec.Networking.Kubenet != nil {
usesKubenet, err := components.UsesKubenet(&b.Cluster.Spec)
if err != nil {
return err
}
if b.Cluster.Spec.ContainerRuntime == "containerd" && usesKubenet {
b.buildKubenetCNIConfigTemplate(c)
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/model/components/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func (b *ContainerdOptionsBuilder) BuildOptions(o interface{}) error {

// Apply defaults for containerd running in container runtime mode
containerd.LogLevel = fi.String("info")
if clusterSpec.Networking != nil && clusterSpec.Networking.Kubenet != nil {
usesKubenet, err := UsesKubenet(clusterSpec)
if err != nil {
return err
}
if clusterSpec.Networking != nil && usesKubenet {
// Using containerd with Kubenet requires special configuration. This is a temporary backwards-compatible solution
// and will be deprecated when Kubenet is deprecated:
// https://github.com/containerd/cri/blob/master/docs/config.md#cni-config-template
Expand Down

0 comments on commit 9d666c7

Please sign in to comment.