kubernetes 集群_Minikube作为本地Kubernetes集群入门

kubernetes 集群

Kubernetes or K8s plays a major role in DevOps and currently, most applications are likely to be deployed in a Kubernetes cluster. Before Docker introduced in 2013, Virtualisation played a huge role in the IT industry.

KubernetesK8s在DevOps中起着主要作用,目前,大多数应用程序很可能部署在Kubernetes集群中。 在Docker于2013年推出之前,虚拟化在IT行业中发挥了巨大作用。

You could have certainly heard different tools such as Virtual Box, VM ware, etc and most probably you have already experienced them by today. But after the containers came into the picture, developers started containerising their applications because this technology gave them more feasibility solutions to go further.

您肯定已经听说过不同的工具,例如Virtual BoxVM ware等,并且很可能您已经体验了它们。 但是在容器出现之后,开发人员开始对应用程序进行容器化,因为该技术为他们提供了更多可行的解决方案,以进一步发展。

Once Google introduced Kubernetes which is a powerful system to manage containerised applications in a clustered environment, the real change started to happen. Kubernetes is an open-source system which has its’ own architecture and compatible with different 3rd-party tools and adapters.

一旦Google推出了Kubernetes,它是在集群环境中管理容器化应用程序的强大系统,那么真正的改变就开始发生。 Kubernetes是一个开源系统,它具有自己的体系结构,并与不同的第三方工具和适配器兼容。

In a clustered environment, you would probably have several master and worker nodes and most of them could be either physical machines or a cloud environment. But, what if you need to test something in your local machine? it could be simple containerised application or might be a production-level application which needs to be tested before you deploy it. Anyhow, this doesn’t mean that you need to buy all the required physical machines or a cloud environment to test them out in a cluster.

在集群环境中,您可能会有几个主节点和工作节点,其中大多数可以是物理机或云环境。 但是,如果您需要在本地计算机上进行测试呢? 它可能是简单的容器化应用程序,也可能是生产级应用程序,需要在部署前进行测试。 无论如何,这并不意味着您需要购买所有必需的物理机或云环境才能在集群中对其进行测试。

Then, what could be your choice? Here’s Minikube comes into the picture.

那么,您会选择什么呢? 这是Minikube的图片。

什么是Minikube? (What is Minikube?)

Minikube is an open-source tool which provides you with a one-node cluster where both master processes and worker processes run inside that node. You can easily install Minikube on your computer and test your application using it. Minikube provides you pre-installed Docker as your container runtime so that you don’t need to install Docker separately.

Minikube是一种开放源代码工具,可为您提供一个单节点群集,其中主进程和辅助进程都在该节点内运行。 您可以轻松地在计算机上安装Minikube并使用它测试您的应用程序。 Minikube为您提供了预安装的Docker作为容器运行时,因此您无需单独安装Docker。

Minikube requires a virtual machine manager or a hypervisor (eg: Virtual Box, VMware, Hyperkit, Hyper-V, KVM, etc) and Kubernetes command-line tool which is known as kubectl to interact with your Kubernetes workloads and services. You can use below link to install Minikube based on your operating system.

Minikube需要虚拟机管理器或虚拟机管理程序(例如:Virtual Box,VMware,Hyperkit,Hyper-V,KVM等)和Kubernetes命令行工具(称为kubectl)才能与Kubernetes工作负载和服务进行交互。 您可以使用下面的链接根据您的操作系统安装Minikube。

安装Minikube (Installing Minikube)

I’m using a Mac for this tutorial and this process is a bit easier on a Mac when compared to other operating systems. However, you can follow all the steps via the link above if you’re using any other OS rather than a Mac OS.

我在本教程中使用的是Mac,与其他操作系统相比,在Mac上此过程要容易一些。 但是,如果您使用的是其他操作系统而不是Mac OS,则可以通过上面的链接执行所有步骤。

Also, if you’re using a Mac, you can proceed with me and I’ll be showing you all the required steps that you need to follow on your Mac. To install Minikube, you need to have Homebrew on your Mac computer. If you don’t have it installed yet, use the below link to install Homebrew.

另外,如果您使用的是Mac,则可以继续进行操作,我将向您显示在Mac上需要执行的所有必需步骤。 要安装Minikube,您需要在Mac计算机上安装Homebrew 。 如果尚未安装,请使用下面的链接安装Homebrew。

Also, you might have installed Homebrew on your Mac but hasn’t updated it recently. Therefore, before installing Minikube, let’s update Homebrew on your Mac. Run the below command on terminal, to update Homebrew to it’s latest features.

另外,您可能已经在Mac上安装了Homebrew,但最近没有对其进行更新。 因此,在安装Minikube之前,让我们在Mac上更新Homebrew。 在终端上运行以下命令,将Homebrew更新为最新功能。

brew update
Image for post
Screenshot by Author
作者截图

You don’t need to open launchpad always to get the terminal, press command+space bar to get spotlight search and there you can type terminal and get it opened.

您无需始终打开启动板即可获取终端,按Command +空格键即可进行Spotlight搜索,然后您可以在其中键入terminal并将其打开。

If you prefer to know more hidden features & shortcuts on your Mac, head over to the below post and be familiar with them.

如果您想在Mac上了解更多隐藏的功能和快捷方式,请转至以下文章并对其进行熟悉。

Once you’re done with Homebrew, you can go and select a virtual machine manager to install Minikube. I’m using Hyperkit as my hypervisor because it’s easy to install with Homebrew and you can select whichever you prefer. To install Hyperkit, run the below command on your terminal.

一旦完成Homebrew的操作,就可以选择一个虚拟机管理器来安装Minikube。 我正在使用Hyperkit作为我的管理程序 因为使用Homebrew易于安装 然后您可以选择任何一个。 要安装Hyperkit,请在终端上运行以下命令。

brew install hyperkit
Image for post
Screenshot by Author
作者截图

Once you completed installing Hyperkit, you can start installing Minikube. To install Minikube run the below command on your terminal.

一旦完成Hyperkit的安装,就可以开始安装Minikube。 要安装Minikube,请在终端上运行以下命令。

brew install minikube
Image for post
Screenshot by Author
作者截图

In this screenshot, you can see Minikube is installing Kubernetes command-line tool (kubectl) as a dependency so that you don’t need to install it separately. But if you get any issue regarding kubectl, make sure to refer the official documentation on the install and set up kubectl.

在此屏幕截图中,您可以看到Minikube正在安装Kubernetes命令行工具(kubectl) 作为依赖项,因此您无需单独安装。 但是,如果您在有关kubectl方面遇到任何问题请确保参考安装的官方文档并设置kubectl

If you were able to complete all the steps successfully up to here, then you’re ready to start your local Kubernetes cluster. But before that, run both kubectl and minikube on your terminal, to verify whether you get the relevant outputs.

如果您能够成功完成所有步骤(到此处),那么就可以启动本地Kubernetes集群了。 但在此之前, minikube在终端上同时运行kubectlminikube ,以验证是否获得了相关的输出。

Once you’re done with both kubectl and minikube you can start your local cluster using the below command.

一旦完成了kubectlminikube ,就可以使用以下命令启动本地集群。

minikube start --vm-driver=hyperkit

minikube start is the command we use to start a local Kubernetes cluster and in this command, you need to specify which hypervisor you’re using to run Minikube. Since we chose Hyperkit as the hypervisor we need to specify it at the end of the minikube start command as above.

minikube start是我们用来启动本地Kubernetes集群的命令,在此命令中,您需要指定要使用哪个虚拟机管理程序来运行Minikube。 由于我们选择了Hyperkit作为虚拟机管理程序,因此我们需要在minikube start命令的末尾指定它。

This command will take some time to complete and when you’re running it for the first time it might ask your Mac password to complete the process.

该命令将需要一些时间才能完成,并且在您首次运行该命令时,可能会询问您的Mac密码来完成该过程。

Image for post
Screenshot by Author
作者截图

Now you’re almost done with the installation. Next, you can try out different kubectl commands to get outputs. Run the below command to get your nodes inside the cluster.

现在您几乎完成了安装。 接下来,您可以尝试使用不同的kubectl命令来获取输出。 运行以下命令以将节点放入群集中。

kubectl get nodes
Image for post
Screenshot by Author
作者截图

Above screenshot verifies that we’ve successfully installed Minikube on our computer and also in this screenshot, you can see our cluster has got only one node and as I mentioned above Minikube provides us one-node cluster to test our applications in a local environment.

上面的屏幕截图验证了我们已经在计算机上成功安装了Minikube,并且在此屏幕截图中,您可以看到我们的集群只有一个节点,并且如上所述,Minikube为我们提供了一个单节点集群来在本地环境中测试我们的应用程序。

Try out below commands as well, to see more information regarding Kubernetes and Minikube.

也可以尝试以下命令,以了解有关Kubernetes和Minikube的更多信息。

kubectl version

Using this command you can see both Kubernetes client and server version and these versions are really important when you’re integrating 3rd-party tools and adapters with Kubernetes.

使用此命令,您可以同时看到Kubernetes客户端和服务器版本,并且在将第三方工具和适配器与Kubernetes集成时,这些版本非常重要。

minikube status

This command gives you the current status of Minikube and you can verify whether the Minikube runs or not on your computer.

此命令为您提供Minikube的当前状态,并且您可以验证Minikube是否在计算机上运行。

Run kubectl and minikube on your terminal and you’ll see all the available commands and it’s always a good practice to be familiar with these commands when you go deep in Kubernetes.

在终端上运行kubectlminikube ,您将看到所有可用的命令,当您深入Kubernetes时,熟悉这些命令始终是一个好习惯。

结论 (Conclusion)

Congratulations! 🎉

恭喜你! 🎉

You have created your local Kubernetes cluster using Minikube. Minikube is a great tool to start with Kubernetes and it provides you with all the required basic features to get started. If you’re a beginner in DevOps, I think using Minikube will give you a better hands-on experience at no cost.

您已经使用Minikube创建了本地Kubernetes集群。 Minikube是从Kubernetes入门的好工具,它为您提供入门所需的所有基本功能。 如果您是DevOps的初学者,我认为使用Minikube可以免费为您提供更好的动手体验。

相关故事 (Related Stories)

Thanks for reading. I hope you found the information useful in this article. If you have any questions, feel free to leave a response below.

谢谢阅读。 希望您在本文中找到有用的信息。 如有任何疑问,请在下面留下您的答复。

翻译自: https://levelup.gitconnected.com/getting-started-with-minikube-as-your-local-kubernetes-cluster-d4eecbb4674e

kubernetes 集群

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值