Step1: 配置国内源
- cat <<EOF > /etc/yum.repos.d/kubernetes.repo
- [kubernetes]
- name=Kubernetes
- baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
- enabled=1
- gpgcheck=1
- repo_gpgcheck=1
- gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
- EOF
- apt-get update && apt-get install -y apt-transport-https
- curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
- cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
- deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
- EOF
- apt-get update
- setenforce 0
- yum install -y kubectl
- yum install kubernetes-cni -y
yum install docker
- rm -rf /usr/local/go && tar -C /usr/local -xzf go1.18.3.linux-arm64.tar.gz
- export PATH=$PATH:/usr/local/go/bin
Step5: K8S 1.24版本后不支持docker,需要继续使用docker的话,要安装cri-dockerd
- git clone https://github.com/Mirantis/cri-dockerd.git
- # Run these commands as root
- ###Install GO###
- wget https://storage.googleapis.com/golang/getgo/installer_linux
- chmod +x ./installer_linux
- ./installer_linux
- source ~/.bash_profile
-
- cd cri-dockerd
- mkdir bin
- export GO111MODULE=on
- export GOPROXY=https://goproxy.cn
- go get && go build -o bin/cri-dockerd
- mkdir -p /usr/local/bin
- install -o root -g root -m 0755 bin/cri-dockerd /usr/local/bin/cri-dockerd
- cp -a packaging/systemd/* /etc/systemd/system
- sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
- systemctl daemon-reload
- systemctl enable cri-docker.service
- systemctl enable --now cri-docker.socket
-
- wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.20.0/crictl-v1.20.0-linux-amd64.tar.gz
- wget https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.24.2/crictl-v1.24.2-linux-arm.tar.gz
- sudo tar zxvf crictl-v1.20.0-linux-amd64.tar.gz -C /usr/bin
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-arm64 && chmod +x minikube
Step7: Docker镜像加速
- {
- "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
- }
service docker restart
systemctl stop firewalld.service
- sudo mkdir -p /usr/local/bin/
- sudo install minikube /usr/local/bin/
-
- minikube start --vm-driver=none --registry-mirror=https://registry.docker-cn.com --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --apiserver-ips='
' --extra-config=kubelet.cgroup-driver=systemd --extra-config=kubelet.runtime-cgroups=/systemd/system.slice --extra-config=kubelet.kubelet-cgroups=/systemd/system.slice --enable-default-cni --network-plugin=cni
minikube start --vm-driver=none --registry-mirror=https://registry.docker-cn.com --image-repository='registry.cn-hangzhou.aliyuncs.com/google_containers' --enable-default-cni
- crictl pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6
- docker image tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.6 k8s.gcr.io/pause:3.6
- kubectl get pods --namespace=kubernetes-dashboard
- kubectl logs kubernetes-dashboard-79d9cd965-q2kh7 --namespace=kubernetes-dashboard
- kubectl expose pods kubernetes-dashboard-79d9cd965-q2kh7 --type=NodePort --port=9090 --namespace=kubernetes-dashboard
- minikube service kubernetes-dashboard-79d9cd965-bnfz4 --url -n kubernetes-dashboard
修改kubelet的Cgroup Driver
修改/etc/systemd/system/kubelet.service.d/10-kubeadm.conf文件,在KUBELET_KUBECONFIG_ARGS这行行尾增加如下配置:
--cgroup-driver=systemd --runtime-cgroups=/systemd/system.slice --kubelet-cgroups=/systemd/system.slice
- systemctl daemon-reload
- systemctl restart kubelet
- journalctl -xeu kubelet