注:一定要升级到19041 内核以后版本
winver 用易升升级要是购买的激活码不影响升级
C:\WINDOWS\System32\WindowsPowerShell\v1.0 或者shift + 右键桌面选择
执行
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
wsl下执行
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
执行
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
如果之前把应用商城卸载了,powershell下执行
1、 Get-AppxPackage -allusers | Select Name, PackageFullName
Microsoft.WindowsStore
Microsoft.WindowsStore_11811.1001.18.0_x64__8wekyb3d8bbwe就是商城应用包名
2、 安装应用商店
命令行执行以下语句即可安装
Add-appxpackage -register "C:\Program
Files\WindowsApps\Microsoft.WindowsStore_11811.1001.18.0_x64__8wekyb3d8bbwe\appxmanifest.xml"
–disabledevelopmentmode
3、 右键固定到开始屏幕
https://docs.microsoft.com/zh-cn/windows/wsl/wsl2-kernel下载内核更新包更新
Microsoft Store安装win 应用市场的Ubuntu-18.04
wsl -l -v 查看
wsl --set-version Ubuntu-18.04 2
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt-get update
sudo apt-get install curl
这一步可能要等很久
curl -s https://packagecloud.io/install/repositories/datawireio/telepresence/script.deb.sh | sudo bash
sudo apt install --no-install-recommends telepresence -y
sudo apt-get install python -y
sudo mv /usr/bin/python /usr/bin/python.bak
sudo ln -s /usr/bin/python3.6 /usr/bin/python
OpenSSH sshfs conntrack torsocks
C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps\ubuntu1804.exe config --default-user root
管理员cmd中运行net stop lxssmanager
重新打开shell即可
因为修改了默认用户, 默认进入的目录也变了, 可以通过在Linux中运行此命令修改默认进入的目录(我这里用ssh登入默认根下)
echo “cd ~用户名” >> ~/.bashrc
apt-cache search package sz
sudo apt-get install lrzsz
sudo apt-get install openssh-server
ps -e | grep ssh
sudo /etc/init.d/ssh start
win+r services.msc 关闭win10 自带ssh服务
sudo vi /etc/ssh/sshd_config 可以修改端口
PermitRootLogin yes
PubkeyAuthentication yes 允许公匙认证
PasswordAuthentication yes 允许密码认证
PermitEmptyPassword no 禁止空密码登录
sudo service ssh --full-restart
telnet 本地ip 68 wsl可以
wsl2 用127.0.0.1做ssh 本地登入
sudo service ssh restart
systemctl enable ssh
拷贝master /usr/bin/kubectl /root/.kube/config到ubuntu对应目录并赋权
chmod +x kubectl
https://storage.googleapis.com/kubernetes-release/release/v1.18.2/bin/windows/amd64/kubectl.exe
把这个文件放到C:\kubectl\
变量名: KUBECTL 变量值:C:\kubectl
再在path 的值 附加上 ;%KUBECTL%
把从k8s 环境下的config 复制到
C:\Users\Administrator.kube
https://www.runoob.com/docker/ubuntu-docker-install.html
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
启动
service docker start
WSL2(Ubuntu 18.04)
root@WIN-CKQKCJMPARV:~# vi /etc/init.wsl
service docker start
service ssh start
root@WIN-CKQKCJMPARV:~# sudo chmod +x /etc/init.wsl
win+r,shell:startup,创建win开机启动脚本
linux-start.vbs 内容如下:
Set ws = WScript.CreateObject("WScript.Shell")
ws.run "wsl -d Ubuntu-18.04 -u root /etc/init.wsl"
idea remote 的ip是eth0网卡地址ifconfig 获取每次会变的注意
这样就可以本地断点调试微服务节点
注:ctlr+c 关闭后pod 又会恢复先前的否则会驻留再k8s上
df –h查看挂载的本地路径
切换到项目目录
cd /mnt/f/my_cloud/cloud-gateway/
集群有对应的deployment时
telepresence --namespace kube-system --mount /tmp/known --swap-deployment cloud-auth --docker-run --rm -e MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18000 -v /tmp/known/var/run/secrets:/var/run/secrets -v $(pwd):/build -v /mnt/d/apache-maven-3.5.0/repo:/m2 -p 8000:8000 -p 18000:18000 192.168.1.4:5000/maven:3.6.2-ibmjava-8-alpine mvn -Dmaven.repo.local=/m2 -f /build spring-boot:run
集群无对应deployment时
telepresence --namespace kube-system --mount /tmp/known --new-deployment cloud-gateway --docker-run --rm -e MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=19200 -v /tmp/known/var/run/secrets:/var/run/secrets -v$(pwd):/build -v /mnt/d/apache-maven-3.5.0/repo:/m2 -p 9200:9200 -p 19200:19200 192.168.1.4:5000/maven:3.6.2-ibmjava-8-alpine mvn -Dmaven.repo.local=/m2 -f /build spring-boot:run
解决
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
启动
service docker start
设置开机启动
systemctl enable docker.service
wsl 1 不支持docker 守护进程(按要求升级到wsl2就不会有也是必须的)
我们需要在WSL上安装Docker客户端
执行命令:apt install docker.io
将WSL配置为连接到Docker for Windows
执行命令:export DOCKER_HOST=tcp://127.0.0.1:2375(只临时)
vi /etc/profile
export DOCKER_HOST=tcp://127.0.0.1:2375
source /etc/profile
wsl执行
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
HvHost
HV 主机服务 依赖组件无法启动
Hypervisor/Virtual Machine Support Driver
net start HvHost
命令行 driverquery /FO CSV >>D:/svc.txt
hvservice(的确该服务不存在,但不影响)
最终排查是根vmw冲突
VMware Workstation 与 Device/Credential Guard 不兼容。在禁用 Device/Credential Guard 后,可以运行 VMware Workstation
这个又要禁用Hyper-v 根据提示地址
只能win10 20H1 vmw 15.5.5, 否则虚拟机的不能同时安装Docker for Windows 或预览版wsl2
wsl> bcdedit /set hypervisorlaunchtype off
此处错误再次提醒必须wsl2
io.fabric8.kubernetes.client.KubernetesClientException: Operation: [list] for kind: [Service] with name: [null] in namespace: [null] failed.
…
Error reading service account token from: [/var/run/secrets/kubernetes.io/serviceaccount/token]. Ignoring
…
com.ibm.jsse2.util.h: PKIX path building failed: java.security.cert.CertPathBuilderException: PKIXCertPathBuilderImpl could not build a valid CertPath.; internal cause is
…
java.security.cert.CertPathValidatorException: The certificate issued by CN=kubernetes is not trusted
https://github.com/telepresenceio/telepresence/issues/563
解决办法:
--mount /tmp/known
-v /tmp/known/var/run/secrets:/var/run/secrets
https://www.kubernetes.org.cn/5313.html
https://blog.csdn.net/a605692769/article/details/82257054
https://www.telepresence.io/reference/windows
https://docs.microsoft.com/zh-cn/windows/wsl/install-win10?redirectedfrom=MSDN
https://blog.csdn.net/yixibo23921552/article/details/106888153/
设置开机启动https://www.jianshu.com/p/244a9d8a2309