centeros的搭建参考:https://www.jianshu.com/p/246a4c045f05
查看系统信息:
yay@10049605-ThinkPad-T470-W10DG:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
yay@10049605-ThinkPad-T470-W10DG:~$ sudo swapoff -a
yay@10049605-ThinkPad-T470-W10DG:~$ systemctl stop firewalld
Failed to stop firewalld.service: Unit firewalld.service not loaded.
yay@10049605-ThinkPad-T470-W10DG:~$ systemctl disable firewalld
Failed to disable unit: Unit file firewalld.service does not exist.
yay@10049605-ThinkPad-T470-W10DG:~$ setenforce 0
Command 'setenforce' not found, but can be installed with:
sudo apt install selinux-utils
yay@10049605-ThinkPad-T470-W10DG:~$ sudo apt install selinux-utils
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列【新】软件包将被安装:
selinux-utils
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 358 个软件包未被升级。
需要下载 81.7 kB 的归档。
解压缩后会消耗 362 kB 的额外空间。
获取:1 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 selinux-utils amd64 2.7-2build2 [81.7 kB]
已下载 81.7 kB,耗时 2秒 (43.0 kB/s)
正在选中未选择的软件包 selinux-utils。
(正在读取数据库 ... 系统当前共安装有 211709 个文件和目录。)
正准备解包 .../selinux-utils_2.7-2build2_amd64.deb ...
正在解包 selinux-utils (2.7-2build2) ...
正在设置 selinux-utils (2.7-2build2) ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
yay@10049605-ThinkPad-T470-W10DG:~$
yay@10049605-ThinkPad-T470-W10DG:~$ sudo apt-get update && apt-get install -y apt-transport-https curl
命中:1 https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu bionic InRelease
命中:2 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
获取:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
忽略:4 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu bionic InRelease
命中:5 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
命中:6 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
命中:7 https://download.sublimetext.com apt/stable/ InRelease
错误:8 http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu bionic Release
404 Not Found [IP: 91.189.95.83 80]
正在读取软件包列表... 完成
E: 仓库 “http://ppa.launchpad.net/webupd8team/sublime-text-3/ubuntu bionic Release” 没有 Release 文件。
N: 无法安全地用该源进行更新,所以默认禁用该源。
N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。
注意下面的问题你可能会碰到,按照tuzhongfangfajiej:
yay@10049605-ThinkPad-T470-W10DG:~$ sudo apt install -y kubelet kubeadm kubectl
E: 无法获得锁 /var/lib/dpkg/lock-frontend - open (11: 资源暂时不可用)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
yay@10049605-ThinkPad-T470-W10DG:~$ sudo rm /var/cache/apt/archives/lock
yay@10049605-ThinkPad-T470-W10DG:~$ sudo rm /var/lib/dpkg/lock
当然也可能是:
yay@10049605-ThinkPad-T470-W10DG:~$ sudo rm /var/lib/dpkg/lock-frontend
1. 在/etc/apt/sources.list添加系统安装源
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# kubeadm及kubernetes组件安装源
deb https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial main
2. 安装kubelet kubeadm kubect
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
3. 禁用虚拟内存
yinbodotcc@yay:~$ sudo swapoff -a
4. 查看我应当下载哪个版本的镜像及识别的镜像名称
yinbodotcc@yay:~$ kubeadm config images list
I0414 22:29:13.174588 24593 version.go:96] could not fetch a Kubernetes version from the internet: unable to get URL "https://dl.k8s.io/release/stable-1.txt": Get https://dl.k8s.io/release/stable-1.txt: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
I0414 22:29:13.174741 24593 version.go:97] falling back to the local client version: v1.14.1
k8s.gcr.io/kube-apiserver:v1.14.1
k8s.gcr.io/kube-controller-manager:v1.14.1
k8s.gcr.io/kube-scheduler:v1.14.1
k8s.gcr.io/kube-proxy:v1.14.1
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.10
k8s.gcr.io/coredns:1.3.1
5. 安装几个Docker镜像(在国内可以下载的镜像)
docker pull mirrorgooglecontainers/kube-apiserver-amd64:v1.14.1
docker pull mirrorgooglecontainers/kube-controller-manager-amd64:v1.14.1
docker pull mirrorgooglecontainers/kube-scheduler-amd64:v1.14.1
docker pull mirrorgooglecontainers/kube-proxy-amd64:v1.14.1
docker pull mirrorgooglecontainers/pause:3.1
docker pull mirrorgooglecontainers/etcd-amd64:3.3.10
docker pull coredns/coredns:1.3.1
docker tag docker.io/mirrorgooglecontainers/kube-proxy-amd64:v1.14.1 k8s.gcr.io/kube-proxy:v1.14.1
docker tag docker.io/mirrorgooglecontainers/kube-scheduler-amd64:v1.14.1 k8s.gcr.io/kube-scheduler:v1.14.1
docker tag docker.io/mirrorgooglecontainers/kube-apiserver-amd64:v1.14.1 k8s.gcr.io/kube-apiserver:v1.14.1
docker tag docker.io/mirrorgooglecontainers/kube-controller-manager-amd64:v1.14.1 k8s.gcr.io/kube-controller-manager:v1.14.1
docker tag docker.io/mirrorgooglecontainers/etcd-amd64:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag docker.io/mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag docker.io/coredns/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
docker tag docker.io/coredns/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
docker rmi mirrorgooglecontainers/kube-proxy-amd64:v1.14.1
docker rmi mirrorgooglecontainers/kube-scheduler-amd64:v1.14.1
docker rmi mirrorgooglecontainers/kube-apiserver-amd64:v1.14.1
docker rmi mirrorgooglecontainers/kube-controller-manager-amd64:v1.14.1
docker rmi mirrorgooglecontainers/etcd-amd64:3.3.10
docker rmi mirrorgooglecontainers/pause:3.1
docker rmi coredns/coredns:1.3.1
6.确定使用哪个接口
7. 创建一个 Master 节点
yinbodotcc@yay:~$ sudo kubeadm init --kubernetes-version=v1.14.1 --pod-network-cidr=192.168.1.36/16
上图部分内容为:
Your Kubernetes control-plane has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubeadm join 192.168.1.36:6443 --token lttdng.cfrikyvzmz2j3hvl \
--discovery-token-ca-cert-hash sha256:191e75cf2f86b653cf198170d557a6add61418c43af7740be48b295cf2ebb6d1
yinbodotcc@yay:~$
8. 开启端口代理
kubectl proxy --port=8080 &