一、修改Ubuntu镜像
-
打开配置文件:
sudo vim /etc/apt/sources.list
-
使用以下配置覆盖原配置信息:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
-
验证并更新:
sudo apt update
sudo apt dist-upgrade
二、安装Docker
-
卸载旧版本:
sudo apt remove docker docker-engine docker.io containerd runc
-
设置存储库:
sudo apt update sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
-
添加官方GPG密钥:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
设置稳定的存储库:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
安装docker引擎:
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io
-
运行hello-world验证docker是否正确安装:
sudo docker run hello-world
如果你使用的是非root用户,请执行7、8、9、10,否则直接跳过;
-
创建docker组:
sudo groupadd docker
-
将用户添加到docker组中:
sudo usermod -aG docker $USER
-
使更改生效:
newgrp docker
-
验证:
docker run hello-world
三、安装k8s
-
切换为root用户(已经是root用户,请直接进行第2步安装):
sudo su
-
安装k8s:
apt update
apt install 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
apt install kubelet kubeadm kubectl
四、安装minikube
-
安装
curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.12.1/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
-
启动
默认启动方式:
minikube start
国内源启动方式:
minikube start --vm-driver=docker --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers
第一次启动推荐使用国内源启动,或者使用:
minikube start --image-mirror-country=cn