introduce
Have you ever spent the whole day trying to get started with Kubernetes? Thanks to some of the new tools that have emerged recently, you don’t have to worry about it anymore.
In this article, I will show you the steps to start a cluster in a single Docker container using kind.
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, it is recommended to use go1.11.5 and above. To install kind, run these commands (it may take some time)
kind (Kubernetes IN Docker) is a tool for building Kubernetes clusters based on docker, which is very suitable for building Kubernetes-based development/testing environments locally.
go get -u sigs./kind kind create cluster
Then confirm that the “kind” cluster is available.
kind get clusters
Setting up kubectl
Similarly, use Homebrew or Chocolatey to install the latest version of kubernetes-cli. The latest version of Docker includesKubernetesfunction, but use the old version of kubectl.
Run the command to check its version number.
kubectl version
Please 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 continue to start the work below. yeah!
Deploy the first application
What do we need to deploy to the cluster? A good option is Wordpress as it includes MySQL and PHP applications.
Fortunately, there is an official introduction and the description is great. We can try to use the kind cluster we just created to operate most of the steps in it.
/docs/tut ... lume/
First, download from this page and .
Run two cat commands to create. Once these yaml files are ready, put the files into the corresponding directory as shown below.
k8s-wp/
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
/wordpress-mysql created
/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 pods to become Running state.
Then, run this command to get the service.
kubectl port-forward svc/wordpress 8080:80
Then openhttp://localhost:8080/
Look! If you want to view the database, check your pod, run a command like this, and then open your client app.
kubectl port-forward wordpress-mysql-bc9864c58-ffh4c 3306:3306
in conclusion
kind is a good choice for minikube because it only uses a single Docker container.
Trying to use Kubernetes on your local machine is easier by using it in conjunction with Kustomze integrated into Kubernetes 1.14.
This is the end of this article about using kind and Docker to start a local Kubernetes environment. For more related kind and Docker to start a local Kubernetes content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!