Installation
Install Ubuntu on WSL2 on Windows
Configuration
After the Docker Desktop installation we need to enable the following WSL integrations at Docker Desktop:
- Settings > General > check Use the WSL 2 based engine
- Settings > Resources > check Enable integration with my default WSL distro
Kind Cluster Setup
We can now download the latest version of kind, For this we open the Ubuntu App a.k.a Terminal for the installation and enter the following commands in the terminal.
## Download the latest version of KinD curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.10.0/kind-linux-amd64 ## Make the binary executable chmod +x ./kind ## Move the binary to your executable path sudo mv ./kind /usr/local/bin/
We need now a kubernetes cluster, but not with standards, instead with a few custom cluster config for ingress-nginx controller.
kind-config-port-mapping.yaml
kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - role: control-plane kubeadmConfigPatches: - | kind: InitConfiguration nodeRegistration: kubeletExtraArgs: node-labels: "ingress-ready=true" extraPortMappings: - containerPort: 80 hostPort: 80 protocol: TCP listenAddress: "127.0.0.1" - containerPort: 443 hostPort: 443 protocol: TCP listenAddress: "127.0.0.1" extraMounts: - hostPath: /home/YOUR-UBUNTU-NAME/PATH/ containerPath: /home/YOUR-UBUNTU-NAME/PATH/
and creating our cluster with following command:
kind create cluster --name YOUR-CLUSTER-NAME --config ./kind-config-port-mapping.yaml
For external access we need the Ingress, a.k.a ingress-nginx controller. They redirect to incoming request to correct service.
For ingress-nginx-controller installation type on following command in the terminal:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
Multi-Domain Setup
With a Real Domain:
You can simply create a new A RECORD into your domain DNS, then you have unlimited subdomain.
DNS Settings
and important! you need the google dns, with them you can disable rebind-dns-security for your local domains on your pc and router.
now you can simply enter the custom domain (like project-one.local.yourdoma.in) as host in the ingress.. For now, we can insert any domain with der prefix .local.yourdoma.in in ingress as host/domain, and instantly available, we don’t need to insert any etc/hosts entry etc.
Testing via simple project
For testing i create a very very simple a Ingress, Service and Pod in one .yaml File. I recommend Helm Package Manager for daily usage, but we want now only testing if they work..
one-simple-project.yaml
kind: Pod apiVersion: v1 metadata: name: bar-app labels: app: bar spec: containers: - name: bar-app image: hashicorp/http-echo:0.2.3 args: - "-text=bar" --- kind: Service apiVersion: v1 metadata: name: bar-service spec: selector: app: bar type: NodePort ports: - port: 5678 --- apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: example-ingress spec: rules: - host: project-one.local.yourdoma.in http: paths: - pathType: Prefix path: / backend: service: name: bar-service port: number: 5678
Don’t forget to replace project-one.local.yourdoma.in with your domain.
Deploy the projekt on your local kubernetes cluster
kubectl apply -f one-simple-project.yaml
All done!
Views: 79