Deploy a Local Kind Cluster
This guide will help you through the process of deploying a local kind cluster.
Kind is a tool for running local Kubernetes clusters using Docker container “nodes”. Kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.
Prerequisites
This guide assumes you have already installed:
Create a Cluster
Create a kind config file called kind-config.yaml with the following content:
1kind: Cluster
2apiVersion: kind.x-k8s.io/v1alpha4
3nodes:
4 - role: control-plane
5 kubeadmConfigPatches:
6 - |
7 kind: InitConfiguration
8 nodeRegistration:
9 kubeletExtraArgs:
10 node-labels: "ingress-ready=true"
11 extraPortMappings:
12 - containerPort: 80
13 hostPort: 80
14 protocol: TCP
15 - containerPort: 443
16 hostPort: 443
17 protocol: TCP
Then create the cluster using the following command:
1kind create cluster --config kind-config.yaml
The configured cluster is ready to accept requests on ports 80 and 443.
Install the Ingress Controller
By default, Kubernetes does not have an ingress controller installed. To install the ingress controller, run the following command:
1kubectl apply -f \
2 https://raw.githubusercontent.com/kubernetes/\
3ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
This will install the nginx ingress controller in the cluster. It is one of the most widely used ingress controllers, but you can install others by changing the ingressClassName in your ingress resources.
Test the Cluster
To test the cluster you can create a simple deployment and a service:
1kubectl run hello \
2 --expose \
3 --image nginxdemos/hello:plain-text \
4 --port 80
Then create a file called ingress.yaml with the following content:
1apiVersion: networking.k8s.io/v1
2kind: Ingress
3metadata:
4 name: hello
5spec:
6 rules:
7 - host: hello.robertoconterosito.it
8 http:
9 paths:
10 - pathType: ImplementationSpecific
11 backend:
12 service:
13 name: hello
14 port:
15 number: 80
Then apply the ingress resource:
1kubectl apply -f ingress.yaml
Now you can test the ingress resource using the following command:
1curl -H "Host: hello.robertoconterosito.it" localhost