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

Bundle CNI plugins (v0.8.6) in kubelet deb/rpm packages #1309

Merged
merged 3 commits into from
May 31, 2020
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
5 changes: 4 additions & 1 deletion debian/bionic/kubelet/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Vcs-Browser: https://github.com/kubernetes/kubernetes

Package: kubelet
Architecture: {{ .DebArch }}
Depends: iptables (>= 1.4.21), kubernetes-cni ({{ .KubeletCNIVersion }}), iproute2, socat, util-linux, mount, ebtables, ethtool, conntrack, ${misc:Depends}
Depends: iptables (>= 1.4.21), iproute2, socat, util-linux, mount, ebtables, ethtool, conntrack, ${misc:Depends}
Provides: kubernetes-cni
Conflicts: kubernetes-cni
Replaces: kubernetes-cni
Description: Kubernetes Node Agent
The node agent of Kubernetes, the container cluster manager
1 change: 1 addition & 0 deletions debian/bionic/kubelet/debian/kubelet.install
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
usr/bin/kubelet usr/bin/
lib/systemd/system/kubelet.service lib/systemd/system/
bin/ opt/cni
4 changes: 4 additions & 0 deletions debian/bionic/kubelet/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ binary:
-o usr/bin/kubelet \
"{{ .DownloadLinkBase }}/bin/linux/{{ .Arch }}/kubelet"
chmod +x usr/bin/kubelet
mkdir -p ./bin
curl -sSL --fail --retry 5 \
"https://storage.googleapis.com/k8s-artifacts-cni/release/v{{ .CNIVersion }}/cni-plugins-linux-{{ .Arch }}-v{{ .CNIVersion }}.tgz" \
| tar -C ./bin -xz
dh_testroot
dh_auto_install
dh_shlibdeps
Expand Down
1 change: 0 additions & 1 deletion debian/bionic/kubernetes-cni/.gitignore

This file was deleted.

6 changes: 0 additions & 6 deletions debian/bionic/kubernetes-cni/debian/changelog

This file was deleted.

1 change: 0 additions & 1 deletion debian/bionic/kubernetes-cni/debian/compat

This file was deleted.

15 changes: 0 additions & 15 deletions debian/bionic/kubernetes-cni/debian/control

This file was deleted.

18 changes: 0 additions & 18 deletions debian/bionic/kubernetes-cni/debian/copyright

This file was deleted.

1 change: 0 additions & 1 deletion debian/bionic/kubernetes-cni/debian/kubernetes-cni.install

This file was deleted.

25 changes: 0 additions & 25 deletions debian/bionic/kubernetes-cni/debian/rules

This file was deleted.

59 changes: 8 additions & 51 deletions debian/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const (
ChannelUnstable ChannelType = "unstable"
ChannelNightly ChannelType = "nightly"

cniVersion = "0.7.5"
currentCNIVersion = "0.8.6"
minimumCNIVersion = "0.8.6"
criToolsVersion = "1.13.0"
pre180kubeadmconf = "pre-1.8/10-kubeadm.conf"
pre1110kubeadmconf = "post-1.8/10-kubeadm.conf"
Expand All @@ -63,8 +64,8 @@ type version struct {
Channel ChannelType
GetVersion func() (string, error)
GetDownloadLinkBase func(v version) (string, error)
CNIVersion string
KubeadmKubeletConfigFile string
KubeletCNIVersion string
}

type cfg struct {
Expand Down Expand Up @@ -303,15 +304,9 @@ func getReleaseDownloadLinkBase(v version) (string, error) {
}

func getKubeadmDependencies(v version) (string, error) {
cniVersion, err := getKubeletCNIVersion(v)
if err != nil {
return "", err
}

deps := []string{
"kubelet (>= 1.13.0)",
"kubectl (>= 1.13.0)",
fmt.Sprintf("kubernetes-cni (%s)", cniVersion),
"${misc:Depends}",
}
sv, err := semver.Make(v.Version)
Expand Down Expand Up @@ -362,23 +357,17 @@ func getKubeadmKubeletConfigFile(v version) (string, error) {
return latestkubeadmconf, nil
}

// CNI get bumped in 1.9, which is incompatible for kubelet<1.9.
// So we need to restrict the CNI version when install kubelet.
func getKubeletCNIVersion(v version) (string, error) {
func getCNIVersion(v version) (string, error) {
sv, err := semver.Make(v.Version)
if err != nil {
return "", err
}

v190, err := semver.Make("1.9.0-alpha.0")
if err != nil {
return "", err
if int(sv.Minor) == 16 {
return minimumCNIVersion, nil
}

if sv.GTE(v190) {
return fmt.Sprintf(">= %s", cniVersion), nil
}
return fmt.Sprint("= 0.5.1"), nil
return currentCNIVersion, nil
}

// getCRIToolsVersion assumes v coming in is >= 1.11.0-alpha.0
Expand Down Expand Up @@ -455,27 +444,6 @@ func main() {
},
},
},
{
Package: "kubernetes-cni",
Distros: distros,
Versions: []version{
{
Version: cniVersion,
Revision: revision,
Channel: ChannelStable,
},
{
Version: cniVersion,
Revision: revision,
Channel: ChannelUnstable,
},
{
Version: cniVersion,
Revision: revision,
Channel: ChannelNightly,
},
},
},
{
Package: "kubeadm",
Distros: distros,
Expand Down Expand Up @@ -552,17 +520,6 @@ func main() {
},
},
},
{
Package: "kubernetes-cni",
Distros: distros,
Versions: []version{
{
Version: cniVersion,
Revision: revision,
Channel: ChannelStable,
},
},
},
{
Package: "kubeadm",
Distros: distros,
Expand Down Expand Up @@ -615,7 +572,7 @@ func main() {
log.Fatalf("error getting kubeadm dependencies: %v", err)
}

c.KubeletCNIVersion, err = getKubeletCNIVersion(v)
c.CNIVersion, err = getCNIVersion(v)
if err != nil {
log.Fatalf("error getting kubelet CNI Version: %v", err)
}
Expand Down
2 changes: 0 additions & 2 deletions debian/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func TestGetKubeadmDependencies(t *testing.T) {
deps: []string{
"kubelet (>= 1.13.0)",
"kubectl (>= 1.13.0)",
"kubernetes-cni (>= 0.7.5)",
"${misc:Depends}",
"cri-tools (>= 1.13.0)",
},
Expand All @@ -91,7 +90,6 @@ func TestGetKubeadmDependencies(t *testing.T) {
deps: []string{
"kubelet (>= 1.13.0)",
"kubectl (>= 1.13.0)",
"kubernetes-cni (>= 0.7.5)",
"${misc:Depends}",
"cri-tools (>= 1.13.0)",
},
Expand Down
37 changes: 16 additions & 21 deletions rpm/kubelet.spec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
%define semver() (%1 * 256 * 256 + %2 * 256 + %3)
%global KUBE_SEMVER %{semver %{KUBE_MAJOR} %{KUBE_MINOR} %{KUBE_PATCH}}

%global CNI_VERSION 0.7.5
%global CNI_VERSION 0.8.6
%global CRI_TOOLS_VERSION 1.13.0

Name: kubelet
Expand All @@ -26,35 +26,26 @@ Source1: kubelet.service
Source2: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/%{ARCH}/kubectl
Source3: https://dl.k8s.io/v%{KUBE_VERSION}/bin/linux/%{ARCH}/kubeadm
Source4: 10-kubeadm.conf
Source5: https://dl.k8s.io/network-plugins/cni-plugins-%{ARCH}-v%{CNI_VERSION}.tgz
Source5: https://storage.googleapis.com/k8s-artifacts-cni/release/v%{CNI_VERSION}/cni-plugins-linux-%{ARCH}-v%{CNI_VERSION}.tgz
Source6: kubelet.env
Source7: https://storage.googleapis.com/k8s-artifacts-cri-tools/release/v%{CRI_TOOLS_VERSION}/crictl-v%{CRI_TOOLS_VERSION}-linux-%{ARCH}.tar.gz

BuildRequires: systemd
BuildRequires: curl
Requires: iptables >= 1.4.21
Requires: kubernetes-cni >= %{CNI_VERSION}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably change from Requires: to Obsoletes:, eg:

Obsoletes: kubernetes-cni

I don't know the debian meta options. Is there something like this there too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Tim! I'm going to do a little research and come back with the deb equivalent as well next week.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tpepper -- This should be ready to merge now. See the worklog below: #1309 (comment)

I ended up adding this to the rpm spec:

Obsoletes: kubernetes-cni
Conflicts: kubernetes-cni

and this to the debian package config:

Provides: kubernetes-cni
Conflicts: kubernetes-cni
Replaces: kubernetes-cni

Requires: socat
Requires: util-linux
Requires: ethtool
Requires: iproute
Requires: ebtables
Requires: conntrack
Obsoletes: kubernetes-cni
Conflicts: kubernetes-cni


%description
The node agent of Kubernetes, the container cluster manager.

%package -n kubernetes-cni

Version: %{CNI_VERSION}
Release: %{RPM_RELEASE}
Summary: Binaries required to provision kubernetes container networking
Requires: kubelet

%description -n kubernetes-cni
Binaries required to provision container networking.

%package -n kubectl

Version: %{KUBE_VERSION}
Expand All @@ -71,7 +62,6 @@ Release: %{RPM_RELEASE}
Summary: Command-line utility for administering a Kubernetes cluster.
Requires: kubelet >= 1.13.0
Requires: kubectl >= 1.13.0
Requires: kubernetes-cni >= 0.7.5
Requires: cri-tools >= 1.13.0

%description -n kubeadm
Expand Down Expand Up @@ -130,19 +120,17 @@ install -m 755 -d %{buildroot}%{_sysconfdir}/sysconfig/
install -p -m 644 -T kubelet.env %{buildroot}%{_sysconfdir}/sysconfig/kubelet

install -m 755 -d %{buildroot}/opt/cni/bin
# bin directory from cni-plugins-%{ARCH}-%{CNI_VERSION}.tgz with a list of cni plugins (among other things)
# bin directory from cni-plugins-linux-%{ARCH}-%{CNI_VERSION}.tgz with a list of cni plugins (among other things)
mv cni-plugins/* %{buildroot}/opt/cni/bin/

%files
%{_bindir}/kubelet
%{_unitdir}/kubelet.service
%{_sysconfdir}/kubernetes/manifests/
/opt/cni
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the implications but I think we should not own files in /opt generally in RPMs. Do you think we could move it to _libexecdir?

Ref: https://src.fedoraproject.org/rpms/containernetworking-plugins/blob/master/f/containernetworking-plugins.spec#_266


%config(noreplace) %{_sysconfdir}/sysconfig/kubelet

%files -n kubernetes-cni
/opt/cni

%files -n kubectl
%{_bindir}/kubectl

Expand All @@ -161,18 +149,25 @@ mv cni-plugins/* %{buildroot}/opt/cni/bin/
- Source cri-tools from https://storage.googleapis.com/k8s-artifacts-cri-tools/release
instead of https://github.com/kubernetes-sigs/cri-tools

* Thu Jun 24 2019 Stephen Augustus <saugustus@vmware.com> - 1.15.1
* Fri May 22 2020 Stephen Augustus <saugustus@vmware.com> - 1.18.4
- Bundle CNI plugins (v0.8.6) in kubelet package

* Fri May 22 2020 Stephen Augustus <saugustus@vmware.com> - 1.18.4
- Source CNI plugins from https://storage.googleapis.com/k8s-artifacts-cni/release
instead of https://dl.k8s.io/network-plugins

* Mon Jun 24 2019 Stephen Augustus <saugustus@vmware.com> - 1.15.1
- Bump minimum versions of all kubernetes dependencies
- Remove conditional logic for unsupported versions of Kubernetes

* Tue Jun 23 2019 Stephen Augustus <saugustus@vmware.com> - 1.15.1
* Sun Jun 23 2019 Stephen Augustus <saugustus@vmware.com> - 1.15.1
- Source cri-tools from https://github.com/kubernetes-sigs/cri-tools
instead of https://github.com/kubernetes-incubator/cri-tools

* Thu May 30 2019 Tim Pepper <tpepper@vmware.com>
- Change CNI version check to ">="

* Tue Mar 20 2019 Lubomir I. Ivanov <lubomirivanov@vmware.com>
* Wed Mar 20 2019 Lubomir I. Ivanov <lubomirivanov@vmware.com>
- Bump CNI version to v0.7.5.

* Tue Sep 25 2018 Chuck Ha <chuck@heptio.com> - 1.12.1
Expand Down