安装Kubernetes
本文介绍在Ubuntu 18.04中如何利用kubeadm安装kubernetes
安装相应的软件
1 | 添加源(阿里云镜像) |
启动kubernetes master
准备阶段
因为国内无法连接gcr.io,所以需要使用阿里云镜像将对应的docker images先pull下来
1 | 从aliyun中将对应的images pull下来, image name 是类似 registry.aliyuncs.com/google_containers/kube-apiserver:v1.18.0 ... |
init master
1 | kubeadm init |
在init完毕后,命令行会出现一些提示,按照提示操作
1 | To start using your cluster, you need to run the following as a regular user: |
配置网络
此时执行kubectl get nodes会看到master的状态是Not Ready,这是因为CNI网络插件没有安装好。使用Calico插件
1 | kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml |
可以执行kubectl get pods --all-namespace来查看相关的Pod是否都正常启动。可以执行kubectl --namespace=kube-system describe pod <pod_name>来看错误原因。
错误恢复
可以执行kubeadm reset来撤销kubeadm init所造成的影响。 但是要注意命令行的提示,有些影响需要手动reset。
Dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml
然后启动proxy, 执行kubectl proxy --address='0.0.0.0' --port=8001 --accept-hosts='^*$'
nginx需要做对应的配置。
访问urlhttps://k8sdashboard.ivyxjc.com/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ 即可访问
1.0的版本因为namespace是kube-system,所以url是https://k8sdashboard.ivyxjc.com/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
安装遇到的问题
安装1.10.0的时候遇到了一些问题。和这篇文章[https://www.pomit.cn/p/2412183455255041](Web基础配置篇(十七): Kubernetes dashboard安装配置)遇到的问题是一样的
Cheat Sheet
1 |
|
参考文章
- [https://www.pomit.cn/p/2412183455255041](Web基础配置篇(十七): Kubernetes dashboard安装配置) ([https://web.archive.org/web/20200407092613/https://www.pomit.cn/p/2412183455255041/](Internet Archive))
