How to setup kubernetes using docker desktop on laptop where vpn/no internet is enabled

how to setup kubernetes using docker desktop on laptop where vpn/no internet is enabled

Do you mean you don’t have internet on the laptop? What is the role of the VPN here? Do you use VPN to connect to the laptop or to connect to something else from your laptop?

Normally you could download the images on a machine that has internet, copy that to the laptop and import them before you enable Kubernetes.

You can use kubeadm config images list to list the required images on a machine on which you install the same version kubeadm that Docker Desktop has. It depends on the version of Docker Desktop.

You can save the images using docker save

And import them using docker load

Hi @rimelek ,thanks for help.in case i have wrong images pulled and kubernetes fails to start , where can i see error logs and details so i can debug and see which images are missing?

unfortunately i could not find this information anywhere in docker desktop documentation.

Also ,to answer your question, by no internet i ment i am connecting via vpn and my system and docker desktop does not have direct internet access to internet. so i will be just pulling kubernetes images from my private docker repository(artifactory) in my case .

also ,i am relatively new to kubernetes ,and i obviously do not have a running kubernetes cluster and kubeadm yet. is there any other way to find out whih images are required for a particular kubeadm version .

ex. for my docker desktop ,kubernetes version is v.1.24.1

kubectl get pod --all-namespaces
will show you all the pods in Kubernetes. Then you can see which pod is failing.

kubectl describe pod -n NAMESPACE_NAME POD_NAME
will show you some events and the reason why the pod is failing. For example when the image cannot be pulled.

kubectl get events --all-namespaces
can also be useful.

So it is not Docker Desktop that should show you the logs

Then it is a good time to start using kubeadm :slight_smile: It is just a “simple” executable and I think the easiest way to get the right images.

However, since I wrote my last comment, I have read that Docker Desktop can run without internet, but installing Kubernetes requires internet to pull the images. I haven’t tried what I am suggesting to you, but I hope it helps. And if there is an other image that Docker Desktop requires, you will see in the logs using the commands I quoted above.

And now the commands (on linux) to print the image list

Source: Installing kubeadm | Kubernetes

RELEASE="v1.24.1"
ARCH="amd64" # or "arm64" in case of an ARM cpu.
sudo curl -L --remote-name-all https://dl.k8s.io/release/${RELEASE}/bin/linux/${ARCH}/kubeadm
sudo chmod +x kubeadm
./kubeadm  config images list --kubernetes-version=$RELEASE

Output:

k8s.gcr.io/kube-apiserver:v1.24.1
k8s.gcr.io/kube-controller-manager:v1.24.1
k8s.gcr.io/kube-scheduler:v1.24.1
k8s.gcr.io/kube-proxy:v1.24.1
k8s.gcr.io/pause:3.7
k8s.gcr.io/etcd:3.5.3-0
k8s.gcr.io/coredns/coredns:v1.8.6

i pulled the above mentioned images, still getting error "kubernetes failed to start "
please see below screenshot .


i just need to know where to find the reason of kubernetes failing to start

this is how my docker desktop settings looks like :

Have you tried to kubectl commands I gave you? You can’t solve everything right from Docker Desktop unfortunately. You could try the troubleshoot icon right next to the settings, but it is easier to use kubectl for now.

also, when i execute command kubectl get pod --all-namespaces and i get error :
Unable to connect to the server: EOF

kubectl version
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short. Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:“1”, Minor:“24”, GitVersion:“v1.24.1”, GitCommit:“3ddd0f45aa91e2f30c70734b175631bec5b5825a”, GitTreeState:“clean”, BuildDate:“2022-05-24T12:26:19Z”, GoVersion:“go1.18.2”, Compiler:“gc”, Platform:“windows/amd64”}
Kustomize Version: v4.5.4
Unable to connect to the server: EOF

Then I guess the documentation was right and you can’t run Kubernetes without internet. If Docker Desktop uses the “Always” pull policy, even if you have the images locally, it will not start.

Update:

Okay, wait, I am going to try it.

Let’s see what I was wrong about

  • I realized that you can’t use kubectl until the kube api server starts.
  • Technically I was not wrong about it, since I suspected it, but the kubeadm config images print command will not show some images that only Docker desktop requires. For example the image of “storage-provisioner” and “vpnkit-controller”

I am sorry for the misleading suggestions.

I ran Kubernetes on my macOS in Docker Desktop then I executed the following command to get the images:

kubectl get pod --all-namespaces  -o json | jq --raw-output '.items[].spec.containers[].image'  | sort | uniq

If you don’t have “jq” installed to parse the json output, you can try this on Linux or mac:

kubectl get pod --all-namespaces  -o jsonpath='{.items[*].spec.containers[*].image}' | tr ' ' "\n" | sort | uniq

In my case the output was:

docker/desktop-storage-provisioner:v2.0
docker/desktop-vpnkit-controller:v2.0
k8s.gcr.io/coredns:v1.9.3
k8s.gcr.io/etcd:3.5.4-0
k8s.gcr.io/kube-apiserver:v1.25.2
k8s.gcr.io/kube-controller-manager:v1.25.2
k8s.gcr.io/kube-proxy:v1.25.2
k8s.gcr.io/kube-scheduler:v1.25.2

So in this case, you would need a machine with internet access where you can install Kubernetes in Docker Desktop, get the list of images and try to copy those images. I would also enable “Show system containers” before loading the images on the machine without internet.

If something is still wrong, you can try the Docker Desktop troubleshoot: