Skip to content

Commit

Permalink
do intelligent detection of which ubuntu 24.04 deps are provided by k…
Browse files Browse the repository at this point in the history
…8s packages (#5346)
  • Loading branch information
laverya authored Aug 22, 2024
1 parent b8efefe commit 8d3b3d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 16 additions & 7 deletions bundles/k8s-ubuntu2404/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ RUN apt-get --print-uris --yes install \
RUN apt-get --print-uris --yes install \
kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep ^\' | cut -d\' -f2 >> ~/raw_urls.txt
RUN apt-get --print-uris --yes install \
kubectl=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep ^\' | cut -d\' -f2 >> ~/raw_urls.txt

RUN cat ~/raw_urls.txt | grep 'pkgs.k8s.io' > ~/urls.txt
RUN cd /archives && cat ~/urls.txt | xargs -I {} -n 1 curl -L -O {}
Expand All @@ -32,13 +35,19 @@ RUN apt-cache depends kubeadm=$(apt-cache madison kubeadm | grep ${KUBERNETES_VE
grep Depends | \
grep -v kubeadm | \
grep -v '<' | \
grep -v 'cri-tools' | \
grep -v 'kubernetes-cni' | \
awk '{ print $2 }' > /archives/Deps
awk '{ print $2 }' > ~/AllDeps
RUN apt-cache depends kubelet=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep Depends | \
grep -v kubeadm | \
grep -v kubelet | \
grep -v '<' | \
grep -v 'cri-tools' | \
grep -v 'kubernetes-cni' | \
awk '{ print $2 }' >> /archives/Deps \
awk '{ print $2 }' >> ~/AllDeps
RUN apt-cache depends kubectl=$(apt-cache madison kubeadm | grep ${KUBERNETES_VERSION}- | awk '{ print $3 }' | head -n 1) | \
grep Depends | \
grep -v kubectl | \
grep -v '<' | \
awk '{ print $2 }' >> ~/AllDeps

# list the dependency names in /archives like cri-tools_131.0.0-0_amd64.deb and then remove the version number
RUN ls /archives | awk -F_ '{ print $1 }' > ~/K8sDepsNames
# remove things from 'Deps' that are in 'K8sDepsNames'
RUN grep -v -f ~/K8sDepsNames ~/AllDeps > /archives/Deps
2 changes: 1 addition & 1 deletion scripts/common/host-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ function apt_is_host_package_installed() {
local package="$1"

log "Checking if $package is installed"
apt list --installed "$package" >/dev/null 2>&1
dpkg-query -W -f='${Status}' "$dep" 2>/dev/null | grep -q "ok installed" >/dev/null
}

# yum_is_host_package_installed returns 0 if the package is installed on the host
Expand Down

0 comments on commit 8d3b3d7

Please sign in to comment.