WSL Linux安装minikube

1.windows wsl版本信息

aven@VIRTUALWSL C:\>wsl --version
WSL 版本: 2.3.26.0
内核版本: 5.15.167.4-1
WSLg 版本: 1.0.65
MSRDC 版本: 1.2.5620
Direct3D 版本: 1.611.1-81528511
DXCore 版本: 10.0.26100.1-240331-1435.ge-release
Windows 版本: 10.0.19045.5131

aven@VIRTUALWSL C:\>

aven@VIRTUALWSL C:\>wsl -l -v
  NAME      STATE           VERSION
* Fedora    Running         2

aven@VIRTUALWSL C:\>

WSL 中的高级设置配置:https://learn.microsoft.com/zh-cn/windows/wsl/wsl-config

2.wsl linux调优

2.1 启动Fedora linux

aven@VIRTUALWSL C:\>wsl -d Fedora
[aven@virtualwsl c]$

2.2 设置wsl linux配置为systemd

  • 配置/etc/wsl.conf配置文件
[aven@virtualwsl c]$ sudo su -
[root@virtualwsl ~]# systemctl status ssh
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
[root@virtualwsl ~]# 

[root@virtualwsl ~]# cat /etc/wsl.conf
[boot]
systemd=true
[root@virtualwsl ~]#
  • 重启启动fedora
aven@VIRTUALWSL C:\>wsl --shutdown
aven@VIRTUALWSL C:\>wsl -d Fedora

2.3 安装docker

[root@virtualwsl ~]# dnf install wget curl net-tools vim -y
[root@virtualwsl ~]# wget https://mirrors.aliyun.com/docker-ce/linux/fedora/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
[root@virtualwsl ~]# dnf makecache
[root@virtualwsl ~]# dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

[root@virtualwsl ~]# cat <<EOF >/etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://dh-mirror.gitverse.ru",
    "https://dockerhub1.beget.com",
    "https://noohub.ru",
    "https://docker.m.daocloud.io"
  ]
}
EOF

[root@virtualwsl ~]# systemctl enable docker
[root@virtualwsl ~]# systemctl start docker

3.安装minikube

3.1 下载minikube程序

[root@virtualwsl ~]# curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
[root@virtualwsl ~]# sudo install minikube-linux-amd64 /usr/local/bin/minikube
[root@virtualwsl ~]# ls /usr/local/bin/minikube
/usr/local/bin/minikube
[root@virtualwsl ~]# minikube config defaults kubernetes-version

3.2 设置添加用户docker权限

[aven@virtualwsl c]$ sudo usermod -aG docker $USER && newgrp docker
[aven@virtualwsl c]$

3.3 minikube创建集群

[aven@virtualwsl c]$ minikube start \
--nodes 2 \
--driver=docker \
--network-plugin=cni \
--extra-config=kubeadm.pod-network-cidr=192.168.0.0/16 \
--service-cluster-ip-range=10.96.0.0/16 \
--kubernetes-version=v1.31.0 \
--registry-mirror=https://dh-mirror.gitverse.ru \
--cpus=2 \
--memory=4096mb \
--container-runtime=containerd
[aven@virtualwsl ~]$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured

minikube-m02
type: Worker
host: Running
kubelet: Running

[aven@virtualwsl ~]$
[aven@virtualwsl ~]$ minikube kubectl get nodes
NAME           STATUS   ROLES           AGE   VERSION
minikube       Ready    control-plane   17h   v1.30.3
minikube-m02   Ready    <none>          17h   v1.30.3
[aven@virtualwsl ~]$

[aven@virtualwsl ~]$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defaul
t qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group defa
ult qlen 1000
    link/ether 00:15:5d:e6:37:10 brd ff:ff:ff:ff:ff:ff
    inet 192.168.149.48/20 brd 192.168.159.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fee6:3710/64 scope link
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOW
N group default
    link/ether 02:42:2c:af:89:4a brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
4: br-6d25d6889149: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue sta
te UP group default
    link/ether 02:42:c6:d3:c6:28 brd ff:ff:ff:ff:ff:ff
    inet 192.168.49.1/24 brd 192.168.49.255 scope global br-6d25d6889149
       valid_lft forever preferred_lft forever
    inet6 fe80::42:c6ff:fed3:c628/64 scope link
       valid_lft forever preferred_lft forever
6: vethb63f889@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue mas
ter br-6d25d6889149 state UP group default
    link/ether 66:47:90:3f:a9:f2 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::6447:90ff:fe3f:a9f2/64 scope link
       valid_lft forever preferred_lft forever
8: vethf4b98f5@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue mas
ter br-6d25d6889149 state UP group default
    link/ether 6a:be:30:76:a5:56 brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::68be:30ff:fe76:a556/64 scope link
       valid_lft forever preferred_lft forever
[aven@virtualwsl ~]$
posted @ 2024-12-06 12:02  二乘八是十六  阅读(16)  评论(0编辑  收藏  举报