$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]
}
EOF
#注:访问阿里云镜像服务获取容器镜像加速地址,替换掉xxxxxx
#获取容器镜像加速链接 https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors?spm=a2c6h.12873639.0.0.6c236235IWJdCd
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装 Docker-CE
sudo yum makecache fast
#sudo yum -y install docker-ce
sudo yum install docker-ce docker-ce-cli containerd.io --nobest
# Step 4: 开启Docker服务
sudo systemctl start docker
sudo systemctl enable docker
#查看状态
sudo systemctl status docker
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 </etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
cat < /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
setenforce 0
#yum install -y kubelet kubeadm kubectl
#systemctl enable kubelet && systemctl start kubelet
#minikube安装,官方说明:只需要kubectl
sudo yum update
yum install -y kubectl
#ps: 由于官网未开放同步方式, 可能会有索引gpg检查失败的情况, 这时请用 yum install -y --nogpgcheck kubelet kubeadm kubectl 安装
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/
为了访问海外的资源,阿里云提供了一系列基础设施,请按照如下参数进行配置。其中常见参数
--driver=***
从1.5.0版本开始,Minikube缺省使用本地最好的驱动来创建Kubernetes本地环境,测试过的版本 docker
, kvm
--image-mirror-country cn
将缺省利用 registry.cn-hangzhou.aliyuncs.com/google_containers 作为安装Kubernetes的容器镜像仓库 (阿里云版本可选)--iso-url=***
利用阿里云的镜像地址下载相应的 .iso 文件 (阿里云版本可选)--registry-mirror=***
为了拉取Docker Hub镜像,需要为 Docker daemon 配置镜像加速,参考阿里云镜像服务--cpus=2
: 为minikube虚拟机分配CPU核数--memory=2048mb
: 为minikube虚拟机分配内存数--kubernetes-version=***
: minikube 虚拟机将使用的 kubernetes 版本minikube start
minikube start --docker-env HTTPS_PROXY=${https://registry.docker-cn.com} --registry-mirror=https://registry-mirror.com --vm-driver=none
sudo yum install conntrack
minikube start --docker-env HTTPS_PROXY=${https://registry.docker-cn.com} --registry-mirror=https://registry-mirror.com --vm-driver=none
sudo mv /root/.kube /root/.minikube $HOME
sudo chown -R $USER $HOME/.kube $HOME/.minikube
#minikube start --docker-env HTTPS_PROXY=${https://registry.docker-cn.com} --registry-mirror=https://registry-mirror.com --vm-driver=none
#这是镜像加速地址 https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors?spm=a2c6h.12873639.0.0.ab202043HPVMuX&accounttraceid=9aeb6ddb011d4fb39a13157eed5e29afstpl,你可以得到 registy-mirror
minikube start --registry-mirror=https://ls16vb6g.mirror.aliyuncs.com --vm-driver=none
5、minikube安装的cluster信息查看(请参考官方文档 https://minikube.sigs.k8s.io/docs/start/)
minikube start/stop/status/delete
当你刚刚安装完minikube的时候查看所有的addons,
$ minikube addons list
|-----------------------------|----------|--------------|
| ADDON NAME | PROFILE | STATUS |
|-----------------------------|----------|--------------|
| ambassador | minikube | disabled |
| dashboard | minikube | disabled |
| default-storageclass | minikube | enabled ✅ |
| efk | minikube | disabled |
| freshpod | minikube | disabled |
| gvisor | minikube | disabled |
| helm-tiller | minikube | disabled |
| ingress | minikube | disabled |
| ingress-dns | minikube | disabled |
| istio | minikube | disabled |
| istio-provisioner | minikube | disabled |
| logviewer | minikube | disabled |
| metallb | minikube | disabled |
| metrics-server | minikube | disabled |
| nvidia-driver-installer | minikube | disabled |
| nvidia-gpu-device-plugin | minikube | disabled |
| olm | minikube | disabled |
| registry | minikube | disabled |
| registry-aliases | minikube | disabled |
| registry-creds | minikube | disabled |
| storage-provisioner | minikube | enabled ✅ |
| storage-provisioner-gluster | minikube | disabled |
|-----------------------------|----------|--------------|
$ minikube addons enable dashboard
$ minikube addons list
1.在kubernetes文档上一般做法是运行命令
$ minikube dashboard
#address='192.168.0.97',为内网访IP
kubectl proxy --port=8001 --address='192.168.0.97' --accept-hosts='^.*' &
红色部分127.0.0.1换成公网IP,集群分配的端口1-65535,均使用我们kubectl proxy代理的端口8001,就可以正常访问
http://124.70.208.216:8001/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
2. minikube会把dashboard映射到一个本地端口上。每次这样做有点麻烦。下面我们为dashboard的pods创建一个service,我们以后可以通过这个service来访问dashboard,每次就可以使用minikube的ip address和这个service的端口来访问dashboard。
vim minikube-dashbord-svc.yaml
apiVersion: v1
kind: Service
metadata:
labels:
addonmanager.kubernetes.io/mode: Reconcile
k8s-app: kubernetes-dashboard
kubernetes.io/minikube-addons: dashboard
name: minikube-dashboard-uri
namespace: kubernetes-dashboard
spec:
ports:
- port: 80
protocol: TCP
targetPort: 9090
nodePort: 30080
selector:
k8s-app: kubernetes-dashboard
sessionAffinity: None
type: NodePort
kubectl apply -f minikube-dashbord-svc.yaml
通过NodePort:nodePort,就可以访问minikube dashboard