使用minikube安装单机版Kubernetes
安装Docker
# 下载安装脚本
curl -sSL https://get.docker.com -o get-docker.sh
# 使用阿里云Docker软件源
sh get-docker.sh --mirror Aliyun
# 添加用户组
sudo usermod -aG docker zylan29
配置国内公共镜像,修改 /etc/docker/daemon.json 文件并添加上 registry-mirrors 键值。
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
注:访问阿里云镜像服务获取容器镜像加速地址,替换掉xxxxxx。
配置Kubernetes软件源
按照阿里云Kubernetest镜像的方法配置Kubernetes软件源。
sudo apt-get update && sudo apt-get install -y apt-transport-https
curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add -
sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF'
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
sudo apt-get update
sudo apt-get install -y kubectl
安装minikube
参考阿里云minikube配置指南安装minikube
curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/v1.14.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
启动K8s集群
minikube start
注:默认使用docker作为backend,使用阿里云容器镜像仓库。
验证K8s集群
~ kubectl get po -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6c76c8bb89-hk7fc 1/1 Running 0 22m
kube-system etcd-minikube 1/1 Running 0 22m
kube-system kube-apiserver-minikube 1/1 Running 0 22m
kube-system kube-controller-manager-minikube 1/1 Running 0 22m
kube-system kube-proxy-f9krv 1/1 Running 0 22m
kube-system kube-scheduler-minikube 1/1 Running 0 22m
kube-system storage-provisioner 1/1 Running 0 22m
Minikube基本操作
启动/停止/查看/删除K8s集群
minikube start/stop/status/delete