“使用阿里云镜像源快速搭建kubernetes(k8s) on debian10”的版本间的差异
跳到导航
跳到搜索
(→info) |
|||
第12行: | 第12行: | ||
=info= | =info= | ||
+ | k8smaster 192.168.88.70 | ||
+ | k8snode1 192.168.88.71 | ||
+ | k8snode2192.168.88.72 | ||
+ | |||
<pre> | <pre> | ||
cat >>/etc/hosts <<EOF | cat >>/etc/hosts <<EOF |
2021年8月6日 (五) 13:21的版本
目录
思路2021
先在围墙外的机器 pull下来 然后 push到自己的hub.docker 最后在内网的机器再pull 下来 再tag一下
参考一下 然后写成脚本吧 ubuntu 使用阿里云镜像源快速搭建kubernetes 1.15.2集群
初始化时 指定aliyun mirrors 本来是指定 1。17。1版本的 我改了新的
kubeadm init --apiserver-advertise-address=192.168.88.70 --image-repository registry.aliyuncs.com/google_containers --ignore-preflight-errors=all --kubernetes-version v1.17.3 --service-cidr=10.96.0.0/16 --pod-network-cidr=10.244.0.0/16
Docker国内镜像的配置及使用 pass
info
k8smaster 192.168.88.70 k8snode1 192.168.88.71 k8snode2192.168.88.72
cat >>/etc/hosts <<EOF 192.168.88.70 k8s-master 192.168.88.71 k8s-node1 192.168.88.72 k8s-node2 EOF 每台机器最少2GB内存,2CPUs。 集群中所有机器之间网络连接正常。 打开相应的端口,详见: [ Check required ports https://kubernetes.io/docs/setup/independent/install-kubeadm/#check-required-ports] Kubernetes要求集群中所有机器具有不同的Mac地址、产品uuid、Hostname。可以使用如下命令查看: # UUID cat /sys/class/dmi/id/product_uuid # Mac地址 ip link Set Hostname and update hosts file sudo hostnamectl set-hostname "k8s-master" sudo hostnamectl set-hostname k8s-node1 sudo hostnamectl set-hostname k8s-node2 #Add the following lines in /etc/hosts file on all three systems,
时间
安装Docker
https://blog.csdn.net/shykevin/article/details/98811021
安装kubelet,kubeadm,kubectl
基础信息
https://mirrors.aliyun.com/kubernetes/apt/dists/kubernetes-jessie/ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" 下一代 Debian 正式发行版的代号为 "buster" — 发布时间尚未确定 Debian 9("stretch") — 当前的稳定版 Debian 8("jessie") — 被淘汰的稳定版 kubectl version Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.5",
添加apt key以及源(所有主机)
apt update && apt install -y apt-transport-https curl curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add - #注意 不是追加 echo "deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-stretch main" >/etc/apt/sources.list.d/kubernetes.list 官方居然是这个 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 安装(所有主机) sudo apt update apt install -y kubelet kubeadm kubectl apt-mark hold kubelet kubeadm kubectl #kubeadm is already the newest version (1.20.5-00). sudo apt install -y kubelet=1.15.2-00 kubeadm=1.15.2-00 kubectl=1.15.2-00 sudo apt-mark hold kubelet=1.15.2-00 kubeadm=1.15.2-00 kubectl=1.15.2-00
安装kubernetes集群(仅master)
kubeadm init --apiserver-advertise-address=192.168.88.70 --image-repository registry.aliyuncs.com/google_containers --ignore-preflight-errors=all --kubernetes-version v1.20.2 --service-cidr=10.96.0.0/16 --pod-network-cidr=10.244.0.0/16 —image-repository 指定镜像源,指定为阿里云的源,这样就会避免在拉取镜像超时,如果没问题,过几分钟就能看到成功的日志输入 sudo kubeadm init --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.15.2 --pod-network-cidr=192.169.0.0/16
init 过程
s-master:~# kubeadm init --apiserver-advertise-address=192.168.88.70 --image-repository registry.aliyuncs.com/google_containers --ignore-preflight-errors=all --kubernetes-version v1.20.2 --service-cidr=10.96.0.0/16 --pod-network-cidr=10.244.0.0/16 [init] Using Kubernetes version: v1.20.2 [preflight] Running pre-flight checks [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/ [WARNING SystemVerification]: this Docker version is not on the list of validated versions: 20.10.5. Latest validated version: 19.03 [WARNING SystemVerification]: missing optional cgroups: hugetlb [preflight] Pulling images required for setting up a Kubernetes cluster [preflight] This might take a minute or two, depending on the speed of your internet connection [preflight] You can also perform this action in beforehand using 'kubeadm config images pull' [addons] Applied essential addon: CoreDNS [addons] Applied essential addon: kube-proxy 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 Alternatively, if you are the root user, you can run: export KUBECONFIG=/etc/kubernetes/admin.conf 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.88.70:6443 --token 8bemec.r64nlpkdmyijwrls \ --discovery-token-ca-cert-hash sha256:a21b898539b970e9efe7490037c0c55710d5541ce1c967ff5b9060be845b2d33
pod网络安装 flannel
可以下载或者直接复制出来
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
https://docs.projectcalico.org/getting-started/kubernetes/flannel/flannel
https://docs.projectcalico.org/getting-started/kubernetes/quickstart
node join
#在所有node上执行 kubeadm join 192.168.88.70:6443 --token 8bemec.r64nlpkdmyijwrls --discovery-token-ca-cert-hash sha256:a21b898539b970e9efe7490037c0c55710d5541ce1c967ff5b9060be845b2d33
常用命令
#等一下就全是Ready kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-master Ready control-plane,master 110m v1.20.5 k8s-node1 Ready <none> 93m v1.20.5 k8s-node2 Ready <none> 93m v1.20.5 root@k8s-master:~# kubectl get pod --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system coredns-7f89b7bc75-6fcdq 1/1 Running 0 4h23m kube-system coredns-7f89b7bc75-9n56h 1/1 Running 0 4h23m kube-system etcd-k8s-master 1/1 Running 0 4h23m kube-system kube-apiserver-k8s-master 1/1 Running 0 4h23m kube-system kube-controller-manager-k8s-master 1/1 Running 0 4h23m kube-system kube-flannel-ds-9kcwd 1/1 Running 0 4h7m kube-system kube-flannel-ds-ql2hn 1/1 Running 0 4h9m kube-system kube-flannel-ds-vk2qb 1/1 Running 0 4h7m kube-system kube-proxy-cgkhf 1/1 Running 0 4h23m kube-system kube-proxy-gcbsk 1/1 Running 0 4h7m kube-system kube-proxy-qnc27 1/1 Running 0 4h7m kube-system kube-scheduler-k8s-master 1/1 Running 0 4h23m root@k8s-master:~#
站内资源
Install and Configure Kubernetes (k8s) on ubuntu
使用kubeadm离线部署kubernetesv1.9.0 on centos7