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 local Kubernetes in Docker

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces how to start the local Kubernetes in Docker, the content is very detailed, interested friends can refer to, hope to be helpful to you.

Install 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)

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

Then confirm that the "kind" cluster is available.

Kind get clusters sets 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/tutorials/stateful-application/mysql-wordpress-persistent-volume/

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 secrets kubectl get pvc kubectl get pods kubectl 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 Kubernetes 3306 on how to start the local Kubernetes in Docker to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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