4篇 minikube related articles

Visit minikube dashboard in VM (访问虚拟内安装的minikube 后台)

上篇讲到在win10环境,vmware的虚拟机内安装minikube之后,发现在访问minikube dashboard是无法跳转的。

这里解决方法:

1 开启代理,虚拟机外可以通过 8081端口访问

kubectl proxy --address='0.0.0.0' --disable-filter=true

2 虚拟机通过如下地址访问

http://your_api_server_ip:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/

your_api_server_ip 换成虚拟机的外部IP,如192.168.136.111

如果有开firewalld,可以通过firewall-cmd --zone=public --add-port=8081/tcp --permanent 添加例外,或直接关闭防火墙

More ~

windows环境使用CentOS7虚拟机安装minikube

in10环境,安装的VMware Workstation Pro,创建了一台Centos7.x的虚拟机。并启用虚拟化。
截图20191015175316721.jpg

先安装kubectl

// v1.16.0版本可以从这里查 https://storage.googleapis.com/kubernetes-release/release/stable.txt
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version

上述如果在墙内,需要http代理可以,先将代理设为环境变量 export http_proxy=http://ip:port

也可以从github上下载
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG.md#client-binaries-1
找到Current release如 https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.16.md
再找到Client Binaries如v1.16.0下的 https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.16.md#client-binaries
再找到合适的tar包如 https://dl.k8s.io/v1.16.0/kubernetes-client-linux-amd64.tar.gz

wget https://dl.k8s.io/v1.16.0/kubernetes-client-linux-amd64.tar.gz
tar -zxvf kubernetes-client-linux-amd64.tar.gz
cd kubernetes/client/bin
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
kubectl version
More ~

Error loading config file "/var/lib/minikube/kubeconfig": open /var/lib/minikube/kubeconfig: permission denied

inikube start时minikube logs中报

Error loading config file "/var/lib/minikube/kubeconfig": open
/var/lib/minikube/kubeconfig: permission denied

解决方法:

sudo setenforce 0

再次执行minikube start即可

注意 这个setenforce重启会失败,需要修改/etc/selinux/config 将SELINUX=enforcing改为 SELINUX=disabled
然后重启即可。

More ~

failed to pull image k8s.gcr.io/kube-apiserver:v1.16.0...

虚拟机内使用minikube start --vm-driver=none装minikube时,报的这个

[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR ImagePull]: failed to pull image k8s.gcr.io/kube-apiserver:v1.16.0: output: Trying to pull repository k8s.gcr.io/kube-apiserver ...
Get https://k8s.gcr.io/v1/_ping: dial tcp 64.233.189.82:443: connect: connection refused
, error: exit status 1

实际上就是这个域名k8s.gcr.io不通。
可以执行minikube start --vm-driver=none --image-mirror-country=cn; 来指定国内镜像源。

More ~