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

Update CNI plugins to v1.2.0 for K8s 1.27+ #15434

Merged
merged 2 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 10 additions & 24 deletions nodeup/pkg/model/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,32 +589,18 @@ func (c *NodeupModelContext) NodeName() (string, error) {
return strings.ToLower(strings.TrimSpace(nodeName)), nil
}

func (b *NodeupModelContext) AddCNIBinAssets(c *fi.NodeupModelBuilderContext, assetNames []string) error {
for _, assetName := range assetNames {
re, err := regexp.Compile(fmt.Sprintf("^%s$", regexp.QuoteMeta(assetName)))
if err != nil {
return err
}
if err := b.addCNIBinAsset(c, re); err != nil {
return err
}
}
return nil
}

func (b *NodeupModelContext) addCNIBinAsset(c *fi.NodeupModelBuilderContext, assetPath *regexp.Regexp) error {
name, res, err := b.Assets.FindMatch(assetPath)
if err != nil {
return err
func (b *NodeupModelContext) AddCNIBinAssets(c *fi.NodeupModelBuilderContext) error {
f := b.Assets.FindMatches(regexp.MustCompile(".*"))

for name, res := range f {
c.AddTask(&nodetasks.File{
Path: filepath.Join(b.CNIBinDir(), name),
Contents: res,
Type: nodetasks.FileType_File,
Mode: fi.PtrTo("0755"),
})
}

c.AddTask(&nodetasks.File{
Path: filepath.Join(b.CNIBinDir(), name),
Contents: res,
Type: nodetasks.FileType_File,
Mode: fi.PtrTo("0755"),
})

return nil
}

Expand Down
22 changes: 1 addition & 21 deletions nodeup/pkg/model/networking/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,7 @@ var _ fi.NodeupModelBuilder = &CommonBuilder{}

// Build is responsible for copying the common CNI binaries
func (b *CommonBuilder) Build(c *fi.NodeupModelBuilderContext) error {
// Based on https://github.com/containernetworking/plugins/releases/tag/v0.7.5
assets := []string{
"bridge",
"dhcp",
"flannel",
"host-device",
"host-local",
"ipvlan",
"loopback",
"macvlan",
"portmap",
"ptp",
"tuning",
"vlan",
"bandwidth",
"firewall",
"sbr",
"static",
}

if err := b.AddCNIBinAssets(c, assets); err != nil {
if err := b.AddCNIBinAssets(c); err != nil {
return err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ClusterName: minimal.example.com
ConfigBase: memfs://clusters.example.com/minimal.example.com
InstanceGroupName: master-us-test-1a
InstanceGroupRole: ControlPlane
NodeupConfigHash: gfxPBhZDQpJV0yPVRHpSf5oWzVF4Dgsk7r2pnha0/Ms=
NodeupConfigHash: Q8YfyZ01FrJoFj3BHdJIugpn1cny1S+QVPSd+62CaUs=

__EOF_KUBE_ENV

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ ConfigServer:
- https://kops-controller.internal.minimal.example.com:3988/
InstanceGroupName: nodes
InstanceGroupRole: Node
NodeupConfigHash: Gj7NVryCC35euCuGFWg6rTEr++c7EMmKikQnCabE5uU=
NodeupConfigHash: QrZGVvjDcvclRWRKDeUnQva9HojwCR/+W55pKgQw/AA=

__EOF_KUBE_ENV

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Assets:
- be5e79c70e926019e588c8c5c44d93efb1042f3be6f1db0de14e707141564d29@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/amd64/kubelet
- 4d416a4bed7c1bb576e284fc6b0bb843f879c08fa8e4beb7e2376305d2dc8299@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/amd64/kubectl
- 5035d7814c95cd3cedbc5efb447ef25a4942ef05caab2159746d55ce1698c74a@https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.27.1/linux/amd64/ecr-credential-provider-linux-amd64
- 962100bbc4baeaaa5748cdbfce941f756b1531c2eadb290129401498bfac21e7@https://storage.googleapis.com/k8s-artifacts-cni/release/v0.9.1/cni-plugins-linux-amd64-v0.9.1.tgz
- f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb9d42d2d37@https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz
- bb9a9ccd6517e2a54da748a9f60dc9aa9d79d19d4724663f2386812f083968e2@https://github.com/containerd/containerd/releases/download/v1.6.20/containerd-1.6.20-linux-amd64.tar.gz
- f00b144e86f8c1db347a2e8f22caade07d55382c5f76dd5c0a5b1ab64eaec8bb@https://github.com/opencontainers/runc/releases/download/v1.1.5/runc.amd64
- f90ed6dcef534e6d1ae17907dc7eb40614b8945ad4af7f0e98d2be7cde8165c6@https://artifacts.k8s.io/binaries/kops/1.21.0-alpha.1/linux/amd64/protokube,https://github.com/kubernetes/kops/releases/download/v1.21.0-alpha.1/protokube-linux-amd64
Expand All @@ -66,7 +66,7 @@ Assets:
- 2a15e9c291dce3e07db5d9948d5c37a4e52c9884343f63287189e4f0d4c3df76@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/arm64/kubelet
- c5fad9f96ab5fe04b8927ce83ceefc4db65b032303a23b35e353276479450d2a@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/arm64/kubectl
- b3d567bda9e2996fc1fbd9d13506bd16763d3865b5c7b0b3c4b48c6088c04481@https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.27.1/linux/arm64/ecr-credential-provider-linux-arm64
- ef17764ffd6cdcb16d76401bac1db6acc050c9b088f1be5efa0e094ea3b01df0@https://storage.googleapis.com/k8s-artifacts-cni/release/v0.9.1/cni-plugins-linux-arm64-v0.9.1.tgz
- 525e2b62ba92a1b6f3dc9612449a84aa61652e680f7ebf4eff579795fe464b57@https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-arm64-v1.2.0.tgz
- c3e6a054b18b20fce06c7c3ed53f0989bb4b255c849bede446ebca955f07a9ce@https://github.com/containerd/containerd/releases/download/v1.6.20/containerd-1.6.20-linux-arm64.tar.gz
- 54e79e4d48b9e191767e4abc08be1a8476a1c757e9a9f8c45c6ded001226867f@https://github.com/opencontainers/runc/releases/download/v1.1.5/runc.arm64
- 2f599c3d54f4c4bdbcc95aaf0c7b513a845d8f9503ec5b34c9f86aa1bc34fc0c@https://artifacts.k8s.io/binaries/kops/1.21.0-alpha.1/linux/arm64/protokube,https://github.com/kubernetes/kops/releases/download/v1.21.0-alpha.1/protokube-linux-arm64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Assets:
- be5e79c70e926019e588c8c5c44d93efb1042f3be6f1db0de14e707141564d29@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/amd64/kubelet
- 4d416a4bed7c1bb576e284fc6b0bb843f879c08fa8e4beb7e2376305d2dc8299@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/amd64/kubectl
- 5035d7814c95cd3cedbc5efb447ef25a4942ef05caab2159746d55ce1698c74a@https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.27.1/linux/amd64/ecr-credential-provider-linux-amd64
- 962100bbc4baeaaa5748cdbfce941f756b1531c2eadb290129401498bfac21e7@https://storage.googleapis.com/k8s-artifacts-cni/release/v0.9.1/cni-plugins-linux-amd64-v0.9.1.tgz
- f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb9d42d2d37@https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz
- bb9a9ccd6517e2a54da748a9f60dc9aa9d79d19d4724663f2386812f083968e2@https://github.com/containerd/containerd/releases/download/v1.6.20/containerd-1.6.20-linux-amd64.tar.gz
- f00b144e86f8c1db347a2e8f22caade07d55382c5f76dd5c0a5b1ab64eaec8bb@https://github.com/opencontainers/runc/releases/download/v1.1.5/runc.amd64
arm64:
- 2a15e9c291dce3e07db5d9948d5c37a4e52c9884343f63287189e4f0d4c3df76@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/arm64/kubelet
- c5fad9f96ab5fe04b8927ce83ceefc4db65b032303a23b35e353276479450d2a@https://dl.k8s.io/release/v1.27.0-alpha.3/bin/linux/arm64/kubectl
- b3d567bda9e2996fc1fbd9d13506bd16763d3865b5c7b0b3c4b48c6088c04481@https://artifacts.k8s.io/binaries/cloud-provider-aws/v1.27.1/linux/arm64/ecr-credential-provider-linux-arm64
- ef17764ffd6cdcb16d76401bac1db6acc050c9b088f1be5efa0e094ea3b01df0@https://storage.googleapis.com/k8s-artifacts-cni/release/v0.9.1/cni-plugins-linux-arm64-v0.9.1.tgz
- 525e2b62ba92a1b6f3dc9612449a84aa61652e680f7ebf4eff579795fe464b57@https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-arm64-v1.2.0.tgz
- c3e6a054b18b20fce06c7c3ed53f0989bb4b255c849bede446ebca955f07a9ce@https://github.com/containerd/containerd/releases/download/v1.6.20/containerd-1.6.20-linux-arm64.tar.gz
- 54e79e4d48b9e191767e4abc08be1a8476a1c757e9a9f8c45c6ded001226867f@https://github.com/opencontainers/runc/releases/download/v1.1.5/runc.arm64
CAs: {}
Expand Down
18 changes: 15 additions & 3 deletions upup/pkg/fi/cloudup/networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ import (
// https://github.com/kubernetes/kubernetes/issues/30338

const (
// defaultCNIAssetAmd64K8s_22 is the CNI tarball for k8s >= 1.22
// CNI tarball for k8s >= 1.22
defaultCNIAssetAmd64K8s_22 = "https://storage.googleapis.com/k8s-artifacts-cni/release/v0.9.1/cni-plugins-linux-amd64-v0.9.1.tgz"
defaultCNIAssetArm64K8s_22 = "https://storage.googleapis.com/k8s-artifacts-cni/release/v0.9.1/cni-plugins-linux-arm64-v0.9.1.tgz"

// CNI tarball for k8s >= 1.27
defaultCNIAssetAmd64K8s_27 = "https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz"
defaultCNIAssetArm64K8s_27 = "https://storage.googleapis.com/k8s-artifacts-cni/release/v1.2.0/cni-plugins-linux-arm64-v1.2.0.tgz"

// Environment variable for overriding CNI url
ENV_VAR_CNI_ASSET_URL = "CNI_VERSION_URL"
ENV_VAR_CNI_ASSET_HASH = "CNI_ASSET_HASH_STRING"
Expand Down Expand Up @@ -72,10 +76,18 @@ func findCNIAssets(c *kopsapi.Cluster, assetBuilder *assets.AssetBuilder, arch a

switch arch {
case architectures.ArchitectureAmd64:
cniAssetURL = defaultCNIAssetAmd64K8s_22
if c.IsKubernetesLT("1.27") {
cniAssetURL = defaultCNIAssetAmd64K8s_22
} else {
cniAssetURL = defaultCNIAssetAmd64K8s_27
}
klog.V(2).Infof("Adding default ARM64 CNI plugin binaries asset: %s", cniAssetURL)
case architectures.ArchitectureArm64:
cniAssetURL = defaultCNIAssetArm64K8s_22
if c.IsKubernetesLT("1.27") {
cniAssetURL = defaultCNIAssetArm64K8s_22
} else {
cniAssetURL = defaultCNIAssetArm64K8s_27
}
klog.V(2).Infof("Adding default AMD64 CNI plugin binaries asset: %s", cniAssetURL)
default:
return nil, nil, fmt.Errorf("unknown arch for CNI plugin binaries asset: %s", arch)
Expand Down