618买的《kubernetes in action》一直没空翻,这几天假期在家开始啃,并跟着书使用minikube来实验kubernetes相关操作。
遇到有几个问题记录如下:
1、网络问题
书上给的minikube下载地址与官网相同,都是 storage.googleapis.com的。国内访问不是很稳定,有时候连不上。国内还是阿里云速度比较快。
2、版本问题
按照使用 kubectl run
来直接创建并运行pod,参数有问题。
kubectl run kubia --image=luksa/kubia --port=8080 --generator=run/v1
提示:
Flag --generator has been deprecated, has no effect and will be removed in the future.
造成 kubectl expose rc
无法继续下去,因为并没有创建ReplicationController。
后根据 官方文档 中的示例参考解决:
kubectl expose deployment hello-minikube --type=NodePort --port=8080
3、环境问题
使用CentOS8.1 安装后,minikube集群中pod一直无法pull image,尝试了:
minikube start --image-mirror-country='cn' --registry-mirror=https://registry.docker-cn.com
minikube start --registry-mirror=registry.cn-hangzhou.aliyuncs.com/google_containers
等各种参数,任然无法解决。
后直接换操作系统,在CentOS7.6和ubuntu20.04上均正常,没有重现该问题。
4、标签问题
使用YAML文件创建的pod,未设定label,无法expose为服务。
kubectl expose pod kubia-manual --type=NodePort --port=8000
error: couldn't retrieve selectors via --selector flag or introspection: the pod has no labels and cannot be exposed
See 'kubectl expose -h' for help and examples