Configure Kind Ingress Nodeport

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Nuevo metodo

cat <<EOF | kind create cluster --image kindest/node:v1.18.2 --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
- containerPort: 443
hostPort: 443
protocol: TCP
EOF

#kind load docker-image us.gcr.io/k8s-artifacts-prod/ingress-


nginx/controller:v0.34.1
#kind load docker-image docker.io/jettech/kube-webhook-certgen:v1.2.2
#kind load docker-image hashicorp/http-echo:0.2.3

kind load image-archive ingress-nginx.tar


kind load image-archive kube-webhook-certgen.tar
kind load image-archive http-echo.tar

#curl -LO https://raw.githubusercontent.com/kubernetes/ingress-


nginx/master/deploy/static/provider/kind/deploy.yaml
kubectl apply -f deploy.yaml

kubectl wait --namespace ingress-nginx \


--for=condition=ready pod \
--selector=app.kubernetes.io/component=controller \
--timeout=90s

#curl -LO https://kind.sigs.k8s.io/examples/ingress/usage.yaml


kubectl apply -f usage.yaml

# should output "foo"


#curl localhost/foo
# should output "bar"
#curl localhost/bar
# Download docker images
kind load docker-image us.gcr.io/k8s-artifacts-prod/ingress-
nginx/controller:v0.34.1
kind load docker-image docker.io/jettech/kube-webhook-certgen:v1.2.2

curl -LO https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-


v0.34.1/deploy/static/provider/baremetal/deploy.yaml

#curl -LO https://raw.githubusercontent.com/kubernetes/ingress-


nginx/master/deploy/static/provider/baremetal/service-nodeport.yaml

# Install the NGINX Ingress Controller

kubectl apply -f deploy.yaml

# Verify installation
kubectl get pods -n ingress-nginx \
-l app.kubernetes.io/name=ingress-nginx --watch

POD_NAMESPACE=ingress-nginx
POD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app.kubernetes.io/name=ingress-
nginx --field-selector=status.phase=Running -o
jsonpath='{.items[0].metadata.name}')

kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version

Let’s change the Ingress Service to a NodePort, since we won’t be getting a


LoadBalancer
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-
nginx/master/deploy/static/provider/baremetal/service-nodeport.yaml

# Let’s expose the Ingress NodePorts by creating two instances of socat for port 80
and 443
for port in 80 443
do
node_port=$(kubectl get service -n ingress-nginx ingress-nginx
-o=jsonpath="{.spec.ports[?(@.port == ${port})].nodePort}")

docker run -d --name banzai-kind-proxy-${port} \


--publish 127.0.0.1:${port}:${port} \
--link banzai-control-plane:target \
alpine/socat -dd \
tcp-listen:${port},fork,reuseaddr tcp-connect:target:${node_port}
done

You might also like