本配置基于centos7
系统配置
- 加载内核模块
sudo modprobe overlay
sudo modprobe br_netfilter
cat <
- 配置系统参数
cat <
执行命令让配置生效
sudo sysctl -p /etc/sysctl.conf
安装配置containerd
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum --enablerepo=docker-ce-stable-x86_64 install containerd.io
cat <
containerd config default | sudo tee /etc/containerd/config.toml
替换成国内镜像源
endpoint = ["https://registry-1.docker.io"] 改成 endpoint = ["https://registry.aliyuncs.com"]
启动服务
sudo systemctl enable containerd
sudo systemctl restart containerd
安装kubernetes
- 下载k8s工具
cat <
sudo yum install -y kubelet kubeadm kubectl
- 修改kubeadm配置
kubeadm config print init-defaults > kubeadm-config.yaml
- cgroupDriver
在kubeadm-config.yaml文件里增加以下内容
---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cgroupDriver: systemd
- 镜像源
修改前配置(默认)
imageRepository: k8s.gcr.io
修改后配置
imageRepository: registry.aliyuncs.com/google_containers
- 配置crictl
crictl config runtime-endpoint /run/containerd/containerd.sock
部署集群
master节点
kubeadm init --config=kubeadm.yaml
集群时区
以flanneld为例
先创建ds-patch.yaml文件
apiVersion: v1
metadata:
name: kube-flannel-ds
spec:
template:
spec:
containers:
- name: kube-flannel
volumeMounts:
- name: timezone
mountPath: /etc/localtime
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
然后打补丁
kubectl patch --namespace=kube-system ds/kube-flannel-ds --patch "$(cat ds-patch.yaml)"