Jnnngs
Home
About
 Admin
  4 minutes

Kubernetes with kind

Yes, we are talking about KinD (Kubernetes in Docker). It is a tool for running local Kubernetes clusters using Docker container “nodes”. Kind was primarily designed to test Kubernetes but may be used for local development or CI.

Ubuntu install

 curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.17.0/kind-linux-amd64

 chmod +x ./kind

 sudo mv ./kind /usr/local/bin/kind

Cluster Config File

vi jnnngsClusterConfig.yaml

Contents

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: jnnngs-kind
nodes:
- role: control-plane
  kubeadmConfigPatches:
  - |
    kind: InitConfiguration
    nodeRegistration:
      kubeletExtraArgs:
        node-labels: "ingress-ready=true"
  extraPortMappings:
  - containerPort: 80
    hostPort: 80
    protocol: TCP
  - containerPort: 443
    hostPort: 443
    protocol: TCP

Create Cluster

kind create cluster --config jnnngsClusterConfig.yaml

Deploy ingress NGINX controller

kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml

Create Service

vi jnnngs-service.yaml

Contents

kind: Pod
apiVersion: v1
metadata:
name: jnnngs-app
labels:
  app: jnnngs-app
spec:
containers:
- name: jnnngs-app
  image: hashicorp/http-echo:0.2.3
  args:
  - "-text=Hello World! This is Jnnngs Kubernetes with kind App"

---

kind: Service
apiVersion: v1
metadata:
name: jnnngs-service
spec:
selector:
  app: jnnngs-app
ports:
# Default port used by the image
- port: 5678

---

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jnnngs-ingress
spec:
rules:
- http:
    paths:
    - pathType: Prefix
      path: "/jnnngs"
      backend:
        service:
          name: jnnngs-service
          port:
            number: 5678

---

Deploy

kubectl apply -f jnnngs-service.yaml

Check Status

kubectl get services

Test

http://IPADDRESS/jnnngs

NB: If we encounter any error related to the validate.nginx.ingress.kubernetes.io webhook, we should delete the ValidationWebhookConfiguration

kubectl delete -A ValidatingWebhookConfiguration ingress-nginx-admission
Useful Commands

kind get clusters
kubectl cluster-info --context kind-jnnngs-kind
kubectl get services
kubectl get pods -o wide
kubectl drain jnnngs-kind-control-plane --ignore-daemonsets --force
kubectl describe pod jnnngs-app
kind delete cluster --name jnnngs-kind
kubectl delete daemonsets,replicasets,services,deployments,pods,rc,ingress --all --all-namespaces