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

Check if all images already exist, before pulling the images #3145

Open
afbjorklund opened this issue Jan 3, 2025 · 3 comments
Open

Check if all images already exist, before pulling the images #3145

afbjorklund opened this issue Jan 3, 2025 · 3 comments
Labels
area/preflight area/UX kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Milestone

Comments

@afbjorklund
Copy link

afbjorklund commented Jan 3, 2025

Is this a BUG REPORT or FEATURE REQUEST?

Choose one: FEATURE REQUEST

Versions

kubeadm version (use kubeadm version):

v1.32.0

Environment:

  • Kubernetes version (use kubectl version): stable
  • Cloud provider or hardware configuration: Lima
  • OS (e.g. from /etc/os-release): Ubuntu LTS
  • Kernel (e.g. uname -a): 6.8
  • Container runtime (CRI) (e.g. containerd, cri-o): containerd
  • Container networking plugin (CNI) (e.g. Calico, Cilium): flannel
  • Others: QEMU/KVM

What happened?

When running the images preflight, the message is always printed:

[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'

What you expected to happen?

If you have already pulled all the images, a more friendly message:

[preflight] All images required for setting up a Kubernetes cluster exist

How to reproduce it (as minimally and precisely as possible)?

kubeadm init phase preflight

Anything else we need to know?

@neolit123 neolit123 added area/UX kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. area/preflight labels Jan 3, 2025
@neolit123 neolit123 added this to the v1.33 milestone Jan 3, 2025
@SataQiu
Copy link
Member

SataQiu commented Jan 4, 2025

The existing images will be skipped. You can see the detailed info by kubeadm init phase preflight -v 1

# kubeadm init phase preflight -v 1
...
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
I0104 02:50:25.901834    3238 checks.go:828] using image pull policy: IfNotPresent
I0104 02:50:25.934956    3238 checks.go:846] image exists: registry.k8s.io/kube-apiserver:v1.28.15
I0104 02:50:25.969421    3238 checks.go:846] image exists: registry.k8s.io/kube-controller-manager:v1.28.15
I0104 02:50:26.004269    3238 checks.go:846] image exists: registry.k8s.io/kube-scheduler:v1.28.15
I0104 02:50:26.039219    3238 checks.go:846] image exists: registry.k8s.io/kube-proxy:v1.28.15
I0104 02:50:26.098499    3238 checks.go:846] image exists: registry.k8s.io/pause:3.9
I0104 02:50:26.125516    3238 checks.go:846] image exists: registry.k8s.io/etcd:3.5.9-0
I0104 02:50:26.152237    3238 checks.go:846] image exists: registry.k8s.io/coredns/coredns:v1.10.1
...

@afbjorklund
Copy link
Author

afbjorklund commented Jan 4, 2025

The existing images will be skipped. You can see the detailed info by kubeadm init phase preflight -v 1

I know. What I wanted to be skipped is the output (not the verbose log), repeating the same instructions.

Here is the script that I used (redacted):

    kubeadm config images list
    kubeadm config images pull --cri-socket=unix:///run/containerd/containerd.sock
    cat <<EOF >kubeadm-config.yaml
    ....
    EOF
    kubeadm init --config kubeadm-config.yaml

And then you still get the output like:

[   84.777496] cloud-init[1063]: + kubeadm config images list
[   87.426339] cloud-init[1063]: registry.k8s.io/kube-apiserver:v1.32.0
[   87.428978] cloud-init[1063]: registry.k8s.io/kube-controller-manager:v1.32.0
[   87.429886] cloud-init[1063]: registry.k8s.io/kube-scheduler:v1.32.0
[   87.430467] cloud-init[1063]: registry.k8s.io/kube-proxy:v1.32.0
[   87.431475] cloud-init[1063]: registry.k8s.io/coredns/coredns:v1.11.3
[   87.431739] cloud-init[1063]: registry.k8s.io/pause:3.10
[   87.432060] cloud-init[1063]: registry.k8s.io/etcd:3.5.16-0
[   87.432334] cloud-init[1063]: + kubeadm config images pull --cri-socket=unix:///run/containerd/containerd.sock
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  109.962640] cloud-init[1063]: [config/images] Pulled registry.k8s.io/kube-apiserver:v1.32.0
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  127.815678] cloud-init[1063]: [config/images] Pulled registry.k8s.io/kube-controller-manager:v1.32.0
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  135.802980] cloud-init[1063]: [config/images] Pulled registry.k8s.io/kube-scheduler:v1.32.0
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  151.838119] cloud-init[1063]: [config/images] Pulled registry.k8s.io/kube-proxy:v1.32.0
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  160.425302] cloud-init[1063]: [config/images] Pulled registry.k8s.io/coredns/coredns:v1.11.3
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  167.723052] cloud-init[1063]: [config/images] Pulled registry.k8s.io/pause:3.10
[^[[0;32m  OK  ^[[0m] Started ^[[0;1;39mkubelet.service^[[0m - kubelet: The Kubernetes Node Agent.^M
[  178.685421] cloud-init[1063]: [config/images] Pulled registry.k8s.io/etcd:3.5.16-0
[  178.687124] cloud-init[1063]: + cat
[  178.688389] cloud-init[1063]: + kubeadm init --config kubeadm-config.yaml
[  181.335106] cloud-init[1063]: [init] Using Kubernetes version: v1.32.0
[  181.338246] cloud-init[1063]: [preflight] Running pre-flight checks
[  181.450118] cloud-init[1063]: [preflight] Pulling images required for setting up a Kubernetes cluster
[  181.450587] cloud-init[1063]: [preflight] This might take a minute or two, depending on the speed of your internet connection
[  181.450840] cloud-init[1063]: [preflight] You can also perform this action beforehand using 'kubeadm config images pull'
[  181.452407] cloud-init[1063]: W0103 19:04:49.387347    3169 checks.go:846] detected that the sandbox image "" of the container runtime is inconsistent with that used by kubeadm.It is recommended to use "registry.k8s.io/pause:3.10" as the CRI sandbox image.

So I already did the pull, and it is redundant.

  1. "Pulling images required" : nothing left to pull

  2. "This might take a minute or two": but not anymore

  3. "You can also perform this action beforehand": already did


Probably should stop the (unconfigured) kubelet service, while it is pulling the images?

But then again the images should probably be downloaded and cached, even earlier...

With k3s or with minikube they are using their own airgapped and preloaded tarballs.
Then you can download that before starting the cluster, like with ubuntu and nerdctl.

But we don't have that infrastructure for Kubernetes, there are no such tarballs available.
I could create my own, but I don't really want to host them. So doing the silent wait instead.

@neolit123
Copy link
Member

neolit123 commented Jan 4, 2025

So I already did the pull, and it is redundant.

  1. "Pulling images required" : nothing left to pull
  2. "This might take a minute or two": but not anymore
  3. "You can also perform this action beforehand": already did

i gave the idea how it can be better implemented here
kubernetes/kubernetes#129474 (review)

but these few kubeadm lines are linear and not too output-poluting.
#3145 (comment)

Probably should stop the (unconfigured) kubelet service, while it is pulling the images?

combining the logs from multiple tools in the same output seems bad.
but yes, you can stop the kubelet before running kubeadm. kubeadm will start it again later.

there is a tracking issue to not start the kubelet with a crashloop until kubeadm prepares the config, but it also requires deb/rpm package updates, and maybe a KEP to polish all corner cases:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/preflight area/UX kind/feature Categorizes issue or PR as related to a new feature. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants