简体   繁体   中英

How can I use kubernetes cluster in Windows WSL2?

I am trying to create cluster by using this article in my WSl Ubuntu. But It returns some errors.

Errors:

yusuf@DESKTOP-QK5VI8R:~/aws/kubs2$ sudo systemctl daemon-reload
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
yusuf@DESKTOP-QK5VI8R:~/aws/kubs2$ sudo systemctl restart kubelet
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
yusuf@DESKTOP-QK5VI8R:~/aws/kubs2$ sudo kubeadm init --pod-network-cidr=10.244.0.0/16
[init] Using Kubernetes version: v1.21.1
[preflight] Running pre-flight checks
        [WARNING Service-Docker]: docker service is not enabled, please run 'systemctl enable docker.service'
        [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR Port-6443]: Port 6443 is in use
        [ERROR Service-Docker]: docker service is not active, please run 'systemctl start docker.service'
        [ERROR Swap]: running with swap on is not supported. Please disable swap
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

I don't understand the reason when I use sudo systemctl restart kubelet . Error like this occurs:

docker service is not enabled, please run 'systemctl enable docker.service'

When I use:

yusuf@DESKTOP-QK5VI8R:~/aws/kubs2$ systemctl enable docker.service
Failed to enable unit, unit docker.service does not exist.

But I have docker images still runnig:

在此处输入图像描述

What is wrong while creating Cluster Kubernetes in WSL? Is there any good tutorial for creating cluster in WSL?

Tutorial you're following is designed for cloud Virtual machines with Linux OS on them (this is important since WSL works a bit differently). Eg SystemD is not presented in WSL, behaviour you're facing is currently in development phase .

What you need is to follow designated tutorial for WSL (WSL2 in this case). Also see that docker is set up on Windows machine and shares its features with WSL integration. Please find Kubernetes on Windows desktop tutorial (this uses KinD or minikube which is enough for development and testing)

Also there's a part for enabling SystemD which can potentially resolve your issue on a state where you are (I didn't test this as I don't have a windows machine).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM