Skip to content

Instantly share code, notes, and snippets.

@whoissqr
Last active May 3, 2025 11:12
Show Gist options
  • Select an option

  • Save whoissqr/f96e12af118b5fc37605ed4a39e82282 to your computer and use it in GitHub Desktop.

Select an option

Save whoissqr/f96e12af118b5fc37605ed4a39e82282 to your computer and use it in GitHub Desktop.
#WSL #nginx #KIND
cat <<-EOF > kind.config
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
EOF
kind create cluster --config kind.config --name kind-c1
k get node --show-labels
k create ns hello-ns
k create deployment hello --image=k8s.gcr.io/echoserver:1.4 -n hello-ns
k expose deployment hello --type=LoadBalancer --port 80 --target-port=8080 -n hello-ns
k get pod -n hello-ns -o wide
k get svc -n hello-ns
k apply --filename https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
k wait --namespace ingress-nginx --for=condition=ready pod --selector=app.kubernetes.io/component=controller --timeout=180s
cat <<-EOF > nginx-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: helloingress
namespace: hello-ns
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello
port:
number: 80
EOF
k apply --filename nginx-ingress.yaml
k describe ingress helloingress -n hello-ns
curl localhost
# launch a new utility pod from within the cluster
$kubectl run curl -n hello-ns --image=curlimages/curl -i --tty -- sh
# curl 10.244.0.13:8080 // probe the pod
# curl 10.96.20.23:80 // probe the service
@whoissqr
Copy link
Author

make it public

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment