“使用阿里云镜像源快速搭建kubernetes(k8s) on debian10”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
第145行: 第145行:
  
 
</pre>
 
</pre>
=== 网络安装 flannel===
+
=== 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/flannel/flannel
  

2021年8月6日 (五) 08:47的版本

思路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

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,

时间

Linux时间同步的那些事儿#debian

安装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

  1. 可以下载或者直接复制出来
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