1 什么是minikube ?
Minikube是由Kubernetes社区维护的单机版的Kubernetes集群,支持macOS, Linux, and Windows等多种操作系统平台,使用最新的官方stable版本,并支持Kubernetes的大部分功能,从基础的容器编排管理,到高级特性如负载均衡、Ingress,权限控制等。非常适合作为Kubernetes入门,或开发测试环境使用。 安装k8s的麻烦就不用多说了,而且特别容易出错,烦的很,minikube部署简单可以用来测试学习用。
2 minikube安装
1 准备环境
2 配置镜像源
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
3 安装kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
mv ./kubectl /usr/local/bin/kubectl
4 安装minukube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x minikube
mv minikube /usr/local/bin/
5 启动集群 新建一个普通用户,否则会提示The “docker” driver should not be used with root privileges.
[root@VM-0-8-centos ~]# useradd ops -G docker
[root@VM-0-8-centos ~]# echo "123456" | passwd --stdin ops
Changing password for user ops.
[root@VM-0-8-centos ~]# su ops
启动本地k8s集群
[ops@VM-0-8-centos ~]$ minikube start
* minikube v1.23.2 on Centos 7.6.1908 (amd64)
* Automatically selected the docker driver
* Starting control plane node minikube in cluster minikube
* Pulling base image ...
* Downloading Kubernetes v1.22.2 preload ...
> preloaded-images-k8s-v13-v1...: 511.69 MiB / 511.69 MiB 100.00% 10.70 Mi
> index.docker.io/kicbase/sta...: 355.39 MiB / 355.40 MiB 100.00% 5.06 MiB
! minikube was unable to download gcr.io/k8s-minikube/kicbase:v0.0.27, but successfully downloaded docker.io/kicbase/stable:v0.0.27 as a fallback image
* Creating docker container (CPUs=2, Memory=2200MB) ...
! This container is having trouble accessing https://k8s.gcr.io
* To pull new external images, you may need to configure a proxy: https://minikube.sigs.k8s.io/docs/reference/networking/proxy/
* Preparing Kubernetes v1.22.2 on Docker 20.10.8 ...
- Generating certificates and keys ...
- Booting up control plane ...
- Configuring RBAC rules ...
* Verifying Kubernetes components...
- Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Enabled addons: default-storageclass, storage-provisioner
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
6 查看minikube状态
[ops@VM-0-8-centos ~]$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
3 配置可视化面板
minikube dashboard --url
* Enabling dashboard ...
* Verifying dashboard health ...
* Launching proxy ...
* Verifying proxy health ...
http://127.0.0.1:33457/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
开启kube-proxy端口映射,使其可以远程访问
kubectl proxy --port=30030 --address='0.0.0.0' --accept-hosts='^.*' &
http://127.0.0.1:30030/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
|