Exercise 9.2: Configuring a NodePort
kubectl -n accounting patch svc nginx-one --type=json -p='[ {"op": "replace", "path": "/spec/type", "value": "NodePort"}]'kubectl -n accounting describe svc nginx-onecurl localhost:NODE_PORTcurl localhost:$(kubectl get svc nginx-one -o=jsonpath='{.spec.ports[0].nodePort}' -n accounting)WORKER_IP_ADDRESS:NODE_PORTsudo iptables-savesudo iptables -t nat -L KUBE-SERVICES -n | column -tsudo iptables -t nat -L KUBE-NODEPORTS -n | column -t{ export NODEPORT_CHAIN=$(sudo iptables -t nat -L KUBE-NODEPORTS -n | column -t | grep "accounting/nginx-one" | grep -oE "^KUBE-EXT-[A-Z0-9]+") echo $NODEPORT_CHAIN }sudo iptables -t nat -L $NODEPORT_CHAIN -n | column -t{ export NODEPORT_TARGET=$(sudo iptables -t nat -L $NODEPORT_CHAIN -n | column -t | grep -oE "^KUBE-SVC-[A-Z0-9]+") echo $NODEPORT_TARGET }sudo iptables -t nat -L $NODEPORT_TARGET -n | column -tkubectl -n accounting get svc nginx-onesudo iptables -t nat -L \ $(sudo iptables -t nat -L $NODEPORT_TARGET -n | column -t | grep -oE "^KUBE-SEP-[A-Z0-9]+" | head -1) \ -n | column -tkubectl -n accounting get pod -o wide
Last updated