如何在 RHEL 8 上安装 MiniKube
Kubernetes MiniKube
![](/data/attachment/album/202303/15/232024hn8312yg1qmy7mhv.jpg)



> 
> 在这篇文章中，我们将逐步介绍如何在 RHEL 8、Rocky Linux 8 或 AlmaLinux 8 上安装 MiniKube。
> 
> 
> 


MiniKube 是一个跨平台的开源工具，可以让你在本地机器上部署单节点 Kubernetes 集群。


Kubernetes，也被称为 k8s，或简称 Kube，是一个开源的容器编排平台，用于容器的自动化扩展和部署。MiniKube 集群帮助开发人员和管理员在集群中构建他们的测试环境。


##### MiniKube 的先决条件


* 最小化安装的 RHEL 8 或 Rocky Linux 8 或 AlmaLinux 8
* 本地配置的 RHEL 8 仓库或订阅
* 至少 2GB RAM 和 2 个 vCPU
* 20GB 硬盘空间
* 具有管理员身份的 sudo 用户
* 稳定的互联网连接
* Docker 或虚拟机管理器，如 VirtualBox、KVM 和 VMware 等


在这篇文章中，我们将使用 Docker 作为 MiniKube 的驱动程序。满足所有先决条件后，现在是时候卷起袖子动手了。


### 步骤 1）启用官方 Docker 仓库


要启用 Docker 官方仓库，运行：



```
$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
$ sudo dnf repolist

```

![](/data/attachment/album/202303/15/232419vx2ll5i8x0tzsz0z.jpg)


### 步骤 2）安装 Docker CE（社区版）


运行以下 `dnf` 命令来安装 Docker 及其依赖项：



```
$ sudo dnf install docker-ce docker-ce-cli containerd.io -y

```

输出：


![](/data/attachment/album/202303/15/232430xmxvyml7ry3rahhr.jpg)


安装 Docker 后启动并启用它的服务，运行以下 `systemctl` 命令：



```
$ sudo systemctl start docker
$ sudo systemctl start docker

```

允许你的本地用户在没有 `sudo` 的情况下运行 `docker` 命令，运行：



```
$ sudo usermod -aG docker $USER
$ newgrp docker

```

### 步骤 3）安装 kubectl 二进制文件


`kubectl` 是一个命令行工具，它通过 API 与 Kubernetes 集群进行交互。我们使用 `kubectl` 部署应用。默认情况下，`kubectl` 不包含在 RHEL 8 、Rocky Linux 8 或 AlmaLinux 8 软件包仓库中。因此，我们将使用下面的命令手动安装它：



```
$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
$ sudo cp kubectl /usr/local/bin/ && sudo chmod +x /usr/local/bin/kubectl
$ kubectl version --client

```

以上命令的输出如下所示：


![](/data/attachment/album/202303/15/232447ea862rhda129289s.jpg)


### 步骤 4）下载 MiniKube 二进制文件并启动集群


安装 `kubectl` 后，让我们使用以下命令下载并安装 MiniKube 二进制文件：



```
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
$ sudo install minikube-linux-amd64 /usr/local/bin/minikube

```

现在使用下面的命令启动 MiniKube 集群：



```
$ minikube start --driver docker

```

![](/data/attachment/album/202303/15/232457sc1x1ec2h7uxx21s.jpg)


上面的输出确认 `minikube` 命令已经使用 `docker` 作为驱动程序启动了单节点 Kubernetes 集群。


运行下面的 `minikube` 命令来验证本地 Kubernetes 集群的状态：



```
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
$
$ minikube ip
192.168.49.2
$

```

要停止 MiniKube 集群，请执行：



```
$ minikube stop

```

执行 `kubectl` 命令查看集群和节点信息：



```
$ kubectl cluster-info
$ kubectl get nodes

```

![](/data/attachment/album/202303/15/232510gqn80cn1tzn0cqd8.jpg)


### 步骤 5）测试和验证 Kubernetes 集群


为了测试 Kubernetes 集群，让我们尝试使用 echo 服务器镜像创建 k8s 部署，它相当于 HTTP Web 服务器并将其作为服务暴露在端口 8080 上：



```
$ kubectl create deployment test-minikube --image=k8s.gcr.io/echoserver:1.10
deployment.apps/test-minikube created
$

```

要访问 `test-minikube` 部署，将其公开为服务，运行以下命令：



```
$ kubectl expose deployment test-minikube --type=NodePort --port=8080
service/test-minikube exposed
$

```

运行以下 `kubectl` 命令以获取上面创建的部署、<ruby> 容器荚 <rt>  pod </rt></ruby> 和服务信息：



```
$ kubectl get deployment,pods,svc

```

![](/data/attachment/album/202303/15/232522uajvjj1d99i9iz40.jpg)


要访问服务，请通过运行下面的命令获取其 URL：



```
$ minikube service test-minikube --url
http://192.168.49.2:32291
$
$ curl http://192.168.49.2:32291/

```

![](/data/attachment/album/202303/15/232538eyydhncl9d2dlzow.jpg)


太好了，这意味着我们的 Kubernetes 集群工作正常，因为我们能够访问我们的示例应用。


##### 步骤 6）启用 MiniKube 插件


MiniKube 提供插件，可以为我们的集群添加额外的功能。要列出所有可用的插件，运行：



```
$ minikube addons list

```

![](/data/attachment/album/202303/15/232548p7vehvrn0nbrr1cq.jpg)


Kubernetes 附带一个仪表板，可让你管理集群。在 MiniKube 中，仪表板已作为插件添加。所以要启用它，运行：



```
$ minikube addons enable dashboard

```

还要启用 nginx 入口控制器，运行：



```
$ minikube addons enable ingress

```

![](/data/attachment/album/202303/15/232557nkekrbbi91pdqffb.jpg)


要访问仪表板，运行：



```
$ minikube dashbaord --url

```

这将在你系统的浏览器中启动仪表板。


![](/data/attachment/album/202303/15/232038x2a3y94vmmm4j82m.png)


就是这些了。我们已经成功地在 RHEL 8、Rocky Linux 8 或 AlmaLinux 8 上使用 MiniKube 安装了 Kubernetes。欢迎你在下面的评论部分分享你的反馈和意见。




---


via: <https://www.linuxtechi.com/install-minikube-on-rhel-rockylinux-almalinux/>


作者：[Pradeep Kumar](https://www.linuxtechi.com/author/pradeep/) 选题：[lkxed](https://github.com/lkxed/) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
In this post, we will cover how to install minikube on RHEL 8, Rocky Linux 8 or AlmaLinux 8 step by step.

[Minikube](https://minikube.sigs.k8s.io/docs/start/) is a cross-platform and open-source tool that makes it possible for you to deploy a single-node Kubernetes cluster on your local machine.

Kubernetes, also known as k8s or simply as Kube, is an open-source container orchestration platform used for the automation scaling and deployment of containers.Minikube cluster helps developers and admins to build their test environment in minikube cluster.

#### Prerequisites of MiniKube

- Minimal Installed RHEL 8 or Rocky Linux 8 or AlmaLinux 8
- Locally Configured Repo or Subscription for RHEL 8.
- Minimum of 2 GB RAM and 2 vCPUs
- 20 GB hard disk space
[Sudo User](https://www.linuxtechi.com/create-sudo-user-on-rhel-rocky-linux-almalinux/)with admin- A stable internet connection
- Docker or virtual machine manager like VirtualBox, KVM,and VMware etc.

In this post, we will be using docker as driver for minikube. With all the prerequisites met, it’s time now to roll up our sleeves and get our hands dirty.

## Step 1) Enable Official Docker Repository


To enable docker official repository run,

$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo $ sudo dnf repolist

## Step 2) Install Docker CE (Community Edition)


Run the following dnf command to install docker and its dependencies,

$ sudo dnf install docker-ce docker-ce-cli containerd.io -y

output,

Once docker is installed the start and enable it’s service, run following systemctl commands,

$ sudo systemctl start docker $ sudo systemctl start docker

Allow your local user to run docker commands without sudo, run

$ sudo usermod -aG docker $USER $ newgrp docker

## Step 3) Install Kubectl Binary


Kubectl is a command-line tool which interacts with Kubernetes cluster via APIs. Using kubectl we deploy our applications as deployment. By default, kubectl is not included in RHEL 8 , Rocky Linux 8 or AlmaLinux 8 package repositories. Therefore, we are going to manually install it using beneath commands,

$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" $ sudo cp kubectl /usr/local/bin/ && sudo chmod +x /usr/local/bin/kubectl $ kubectl version --client

Output of above commands would be something like below,

## Step 4) Download MiniKube Binary and Start Cluster


After installing the kubectl, let’s download and install minikube binary using the following commands,

$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 $ sudo install minikube-linux-amd64 /usr/local/bin/minikube

Now start minikube cluster using the beneath command,

$ minikube start --driver docker

Output above confirms that minikube command has started the single node Kubernetes cluster using docker as driver.

Run below minikube command to verify the status of your local Kubernetes cluster,

[sysops@localhost ~]$ minikube status minikube type: Control Plane host: Running kubelet: Running apiserver: Running kubeconfig: Configured [sysops@localhost ~]$ [sysops@localhost ~]$ minikube ip 192.168.49.2 [sysops@localhost ~]$

To stop stop the minikube cluster, execute,

$ minikube stop

Execute the “kubectl” commands to view cluster and node information

$ kubectl cluster-info $ kubectl get nodes

## Step 5) Test and Verify Kubernetes Cluster

To test Kubernetes cluster, let try to create k8s deployment using echo server image, it is equivalent to http web server and expose it as a service on port 8080,

[sysops@localhost ~]$ kubectl create deployment test-minikube --image=k8s.gcr.io/echoserver:1.10 deployment.apps/test-minikube created [sysops@localhost ~]$

To access test-minikube deployment, expose it as service, run the following command,

[sysops@localhost ~]$ kubectl expose deployment test-minikube --type=NodePort --port=8080 service/test-minikube exposed [sysops@localhost ~]$

Run below kubectl command to get deployment,pods and service information for above created deployment,

$ kubectl get deployment,pods,svc

To access service, get its url by running the beneath command.

[sysops@localhost ~]$ minikube service test-minikube --url http://192.168.49.2:32291 [sysops@localhost ~]$ [sysops@localhost ~]$ curl http://192.168.49.2:32291/

Great, it means our Kubernetes cluster is working fine as we are able to access our sample application.

#### Step 6) Enable MiniKube Addons


Minikube offers addons which can add additional functionality to our clusters. To list all available addons run,

$ minikube addons list

Kubernetes ships with a dashboard that allows you to manage your cluster. In Minikube, dashboard has been added as an addons. So to enable it, run

$ minikube addons enable dashboard

Also to enable nginx ingress controller, run

$ minikube addons enable ingress

To access the dashboard, run

$ minikube dashbaord --url

This will start the dashboard in your systems’s web vrowser.

And that’s just about it. We have managed to successfully install Kubernetes with Minikube on RHEL 8, Rocky Linux 8 or AlmaLinux 8. You are welcome to share your feedback and comments in below comments section.

**Also Read **: [How to Configure NFS based Persistent Volume in Kubernetes](https://www.linuxtechi.com/configure-nfs-persistent-volume-kubernetes/)

LokeshVery Good Article to set up minikube.

Lokesh[root@centosnews ~]# minikube dashboard –url

? Verifying dashboard health …

? Launching proxy …

? Verifying proxy health …

‘http://127.0.0.1:38423/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/’

Dashboard url is not working getting msg “This site can’t be reached”

Marco@Lokesh:

This worked for me: kubectl proxy –address=’0.0.0.0′ –disable-filter=true

For more info: https://stackoverflow.com/a/54960906

Phillip KnezevichThis is an excellent article, there’s been a few out there that I’ve tried with some error or lack of success. First article i’ve walked through that got it right e2e. Thanks!

RahulYou cant use ingress with the driver none, any workaround?

krishnaAfter Docker installation, one has to add user to ‘Docker’ group

sudo groupadd docker

sudo usermod -aG docker $USER

If not then one has to face the issue reported

‘https://github.com/kubernetes/minikube/issues/10589’

GaneshHey,

Thanks a lot for sharing such informative article and such crystal clear steps to setup the minikube.

Appreciated your efforts to share knowledge.