Skip to content

Commit

Permalink
Merge pull request #486 from pipejakob/patch-use-cni-0.6.0
Browse files Browse the repository at this point in the history
Fix rpm build after CNI 0.6.0 changes
  • Loading branch information
ixdy authored Dec 14, 2017
2 parents b8f954b + 7e20018 commit ae34da9
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
27 changes: 26 additions & 1 deletion debian/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
ChannelUnstable ChannelType = "unstable"
ChannelNightly ChannelType = "nightly"

cniVersion = "0.5.1"
cniVersion = "0.6.0"
)

type work struct {
Expand All @@ -44,6 +44,7 @@ type version struct {
GetVersion func() (string, error)
GetDownloadLinkBase func(v version) (string, error)
KubeadmKubeletConfigFile string
KubeletCNIVersion string
}

type cfg struct {
Expand Down Expand Up @@ -291,6 +292,25 @@ func getKubeadmKubeletConfigFile(v version) (string, error) {
}
}

// 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) {
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 sv.GTE(v190) {
return fmt.Sprintf("= %s", cniVersion), nil
}
return fmt.Sprint("= 0.5.1"), nil
}

func main() {
flag.Parse()

Expand Down Expand Up @@ -466,6 +486,11 @@ func main() {
log.Fatalf("error getting kubeadm config: %v", err)
}

c.KubeletCNIVersion, err = getKubeletCNIVersion(v)
if err != nil {
log.Fatalf("error getting kubelet config: %v", err)
}

return c.run()
}); err != nil {
log.Fatalf("err: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion debian/xenial/kubelet/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ Vcs-Browser: https://github.com/kubernetes/kubernetes

Package: kubelet
Architecture: {{ .DebArch }}
Depends: iptables (>= 1.4.21), kubernetes-cni (>= 0.5.1), iproute2, socat, util-linux, mount, ebtables, ethtool, ${misc:Depends}
Depends: iptables (>= 1.4.21), kubernetes-cni ({{ .KubeletCNIVersion }}), iproute2, socat, util-linux, mount, ebtables, ethtool, ${misc:Depends}
Description: Kubernetes Node Agent
The node agent of Kubernetes, the container cluster manager
7 changes: 4 additions & 3 deletions debian/xenial/kubernetes-cni/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
# -*- makefile -*-

#export DH_VERBOSE=1
CNI_RELEASE = 0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
CNI_VERSION = v0.6.0

build:
echo noop

binary:
mkdir -p ./bin
curl -sSL --fail --retry 5 \
"https://dl.k8s.io/network-plugins/cni-{{ .Arch }}-$(CNI_RELEASE).tar.gz" \
| tar xz
"https://dl.k8s.io/network-plugins/cni-plugins-{{ .Arch }}-$(CNI_VERSION).tgz" \
| tar -C ./bin -xz
dh_testroot
dh_auto_install
dh_shlibdeps
Expand Down
35 changes: 26 additions & 9 deletions rpm/kubelet.spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
%global KUBE_MINOR 8
%global KUBE_PATCH 0
%global KUBE_VERSION %{KUBE_MAJOR}.%{KUBE_MINOR}.%{KUBE_PATCH}
%global CNI_RELEASE 0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
%global RPM_RELEASE 1
%global ARCH amd64

Expand All @@ -12,6 +11,12 @@
%define semver() (%1 * 256 * 256 + %2 * 256 + %3)
%global KUBE_SEMVER %{semver %{KUBE_MAJOR} %{KUBE_MINOR} %{KUBE_PATCH}}

%if %{KUBE_SEMVER} >= %{semver 1 9 0}
%global CNI_VERSION 0.6.0
%else
%global CNI_VERSION 0.5.1
%endif

Name: kubelet
Version: %{KUBE_VERSION}
Release: %{RPM_RELEASE}
Expand All @@ -24,12 +29,16 @@ 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-%{ARCH}-%{CNI_RELEASE}.tar.gz
%if %{KUBE_SEMVER} < %{semver 1 9 0}
Source5: https://dl.k8s.io/network-plugins/cni-%{ARCH}-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz
%else
Source5: https://dl.k8s.io/network-plugins/cni-plugins-%{ARCH}-v%{CNI_VERSION}.tgz
%endif


BuildRequires: curl
Requires: iptables >= 1.4.21
Requires: kubernetes-cni >= 0.5.1
Requires: kubernetes-cni = %{CNI_VERSION}
Requires: socat
Requires: util-linux
Requires: ethtool
Expand All @@ -42,7 +51,7 @@ The node agent of Kubernetes, the container cluster manager.

%package -n kubernetes-cni

Version: 0.5.1
Version: %{CNI_VERSION}
Release: %{RPM_RELEASE}
Summary: Binaries required to provision kubernetes container networking
Requires: kubelet
Expand Down Expand Up @@ -94,11 +103,13 @@ cp -p %SOURCE1 %{_builddir}/
cp -p %SOURCE2 %{_builddir}/
cp -p %SOURCE3 %{_builddir}/
cp -p %SOURCE4 %{_builddir}/
%setup -D -T -a 5 -n %{_builddir}/
%setup -c -D -T -a 5 -n cni-plugins


%install

# The setup macro from prep will make install start in the cni-plugins directory, so cd back to the root.
cd %{_builddir}
install -m 755 -d %{buildroot}%{_bindir}
install -m 755 -d %{buildroot}%{_sysconfdir}/systemd/system/
install -m 755 -d %{buildroot}%{_sysconfdir}/systemd/system/kubelet.service.d/
Expand All @@ -112,10 +123,13 @@ install -p -m 755 -t %{buildroot}%{_sysconfdir}/systemd/system/ kubelet.service
install -p -m 755 -t %{buildroot}%{_sysconfdir}/systemd/system/kubelet.service.d/ 10-kubeadm.conf


install -m 755 -d %{buildroot}/opt/cni
# bin directory from cni-amd64-%{CNI_RELEASE}.tar.gz with a list of cni plugins (among other things)
mv bin/ %{buildroot}/opt/cni/

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)
%if %{KUBE_SEMVER} >= %{semver 1 9 0}
mv cni-plugins/* %{buildroot}/opt/cni/bin/
%else
mv cni-plugins/bin/ %{buildroot}/opt/cni/
%endif

%files
%{_bindir}/kubelet
Expand All @@ -136,6 +150,9 @@ mv bin/ %{buildroot}/opt/cni/


%changelog
* Thu Oct 19 2017 Di Xu <stephenhsu90@gmail.com>
- Bump CNI version to v0.6.0.

* Fri Sep 29 2017 Jacob Beacham <beacham@google.com> - 1.8.0
- Bump version of kubelet and kubectl to v1.8.0.

Expand Down

0 comments on commit ae34da9

Please sign in to comment.