Kubernetes 安装

Kubernetes 安装指引

Ubuntu

从 Google 源安装

kubectl

sudo apt-get update && sudo apt-get install -y apt-transport-https gnupg2
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl

minikube

可执行文件,下载后即可使用:

curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube

# 大多 minikube 命令需非 root 用户运行,安装到各用户目录以便 root 误操作
mkdir ~/bin/
install minikube ~/bin/

 用 Docker 开通 minikube 集群需用非 root 用户启动:

$ minikube config set driver docker
$ minikube start

中国用户需要设置代理,让 minikube 从 Google 镜像服务器更新镜像启动服务。

# /etc/environment
http_proxy=
https_proxy=
no_proxy=localhost,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16

从国内镜像安装 

minikube start --vm-driver=podman --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers

CentOS 8

从 Google 源安装

更新 Podman

sudo dnf -y module disable container-tools                                                                                                                                                           
sudo dnf -y install 'dnf-command(copr)'
sudo dnf -y copr enable rhcontainerbot/container-selinux
sudo curl -kL -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_8/devel:kubic:libcontainers:stable.repo
sudo dnf -y install podman

minikube

CentOS 上 minikube 用 podman 运行,minikube 需用非 root 启动,minikube 安装在相关用户 ~/bin 目录下避免 root 用户误执行:

mkdir ~/bin
cd ~/bin
curl -Lo ~/bin/minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube

# 更新
curl -Lo ~/bin/minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 

# 启动
minikube start --vm-driver=podman 
Author: njun
njun's picture
Updated: 2020/09/07