Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to start a local Kubernetes environment using kind and Docker

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains how to use kind and Docker to start the local Kubernetes environment, the content is clear, interested friends can learn, I believe it will be helpful after reading.

What is kind?

Because kind is implemented in the go language, make sure that the latest version of golang is installed. According to the developer's documentation, go1.11.5 or above is recommended. To install kind, run these commands (it may take a while)

Kind (Kubernetes IN Docker) is a tool for building Kubernetes clusters based on docker, which is very suitable for building a local Kubernetes-based development / test environment.

Go get-u sigs.k8s.io/kind kind create cluster

Then confirm that the "kind" cluster is available.

Kind get clusters

Set up kubectl

Similarly, use Homebrew or Chocolatey to install the latest version of kubernetes-cli. The latest version of Docker includes the functionality of Kubernetes, but uses the older version of kubectl.

Run the command to check its version number.

Kubectl version

Make sure that GitVersion: "v1.14.1" or later is displayed.

If you find kubectl running through Docker, try using brew link or reordering environment variables.

Once kubectl and kind are installed, open the bash console and run these commands.

Export KUBECONFIG= "$(kind get kubeconfig-path)" kubectl cluster-info

If kind is configured correctly, some information will be displayed. Now you can move on to the following work. Yeah!

Deploy the first application

What do we need to deploy to the cluster? A good choice is Wordpress because it includes MySQL and PHP applications.

Fortunately, there is an official introduction and a great description. We can try to use the kind cluster we just created to do most of the steps.

Https://kubernetes.io/docs/tut... Lume/

First, download mysql-deployment.yaml and wordpress-deployment.yaml from this page.

Run two cat commands to create the kustomization.yaml. Once these yaml files are ready, put the files in the appropriate directory as shown below.

K8s-wp/kustomization.yaml mysql-deployment.yaml wordpress-deployment.yaml

And then apply it to your cluster.

Cd k8s-wp kubectl apply-k. /

If the command is executed successfully, you will see the following output:

Secret/mysql-pass-7tt4f27774 created

Service/wordpress-mysql created

Service/wordpress created

Deployment.apps/wordpress-mysql created

Deployment.apps/wordpress created

Persistentvolumeclaim/mysql-pv-claim created

Persistentvolumeclaim/wp-pv-claim created

Let's enter these commands to check the status of the cluster:

Kubectl get secretskubectl get pvckubectl get podskubectl get services wordpress

Wait for all pod to become Running.

Then, run this command to get the service.

Kubectl port-forward svc/wordpress 8080:80

Then open http://localhost:8080/

Look at that! If you want to view the database, check your pod, run a command like this, and then open your client application.

Kubectl port-forward wordpress-mysql-bc9864c58-ffh5c 3306:3306

Conclusion

Kind is a good choice for minikube because it only uses a single Docker container.

By using it in conjunction with Kustomze integrated into Kubernetes1.14, it's easier to try Kubernetes on your local machine.

After reading the above content, do you have a better understanding of how to start the local Kubernetes environment using kind and Docker? if you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report