使用原生包管理工具安装kubectl
1.更新 apt 包索引,并安装使用 Kubernetes apt 仓库所需要的包
1 | sudo apt-get update |
2.下载 Google Cloud 公开签名秘钥,如果有网络问题的话,可以手动下载apt-key.gpg文件,然后将其改名并移动到/usr/share/keyrings/kubernetes-archive-keyring.gpg目录
1 | sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg |
3.添加 Kubernetes apt 仓库:
1 | echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list |
如果报错,可以使用中科大的源
1 | echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list |
4.更新 apt 包索引,使之包含新的仓库并安装 kubectl:
1 | sudo apt-get update |
参考
1 | https://kubernetes.io/zh/docs/tasks/tools/install-kubectl-linux/ |
使用minikube在单机上启动一个K8S机器用于测试
1 | https://github.com/kubernetes/minikube/releases/tag/v1.21.0 |
1.安装minikube
1 | curl -LO https://github.com/kubernetes/minikube/releases/download/v1.21.0/minikube_1.21.0-0_amd64.deb |
2.创建集群
1 | minikube start |
如果遇到The image ‘xxx’ was not found; unable to add it to cache的报错,可以使用如下命令
1 | minikube start --image-mirror-country='cn' |
删除集群
1 | minikube delete |
创建特定版本的集群
1 | minikube start --kubernetes-version=v1.21.1 |
3.查看集群
1 | kubectl get po -A |
minikube一些命令:K8s - Install Minikube in Linux
4.启动kubernetes-dashboard,需要在图形界面中
1 | minikube dashboard |
5.配置dashboard外网访问,address是你的运行minikube的机器ip,port是对外暴露的端口
1 | kubectl proxy --port=10018 --address='192.168.xx.xx' --accept-hosts='^.*' & |
此时就可以访问如下的网址来访问minikube dashboard
1 | http://master:10018/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/#/workloads?namespace=_all |
参考
1 | https://minikube.sigs.k8s.io/docs/start/ |
6.minikube使用ingress
1 | https://kubernetes.io/zh-cn/docs/tasks/access-application-cluster/ingress-minikube/ |