dev-resources.site
for different kinds of informations.
ClusterIP vs. NodePort
Published at
1/4/2025
Categories
clusterip
nodeport
kubernetes
cka
Author
cheedge_lee
Author
11 person written this
cheedge_lee
open
ClusterIP
kubectl expose deployment nginx --name nginx-svc --port 8080 --target-port 80
NodePort
kubectl expose deployment nginx --name nginx-svc --port 8081 --target-port 80 --type NodePort
Different Ports
-
target-port
-- container port- Where your pod/container listens
k get endpoints
-
port
-- service's internal port- access the svc from other port
k get svc
-
NodePort
-- expose to external/all nodes-
k get endpoints
ork get svc
-
controlplane $ k get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
apache-svc ClusterIP 10.104.249.75 <none> 8080/TCP 2m11s
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d8h
nginx-svc NodePort 10.97.210.100 <none> 8081:32433/TCP 3s
controlplane $ k get node -owide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
controlplane Ready control-plane 2d8h v1.31.0 172.30.1.2 <none> Ubuntu 20.04.5 LTS 5.4.0-131-generic containerd://1.7.13
ClusterIP vs. NodeIP
- For accessing from nodes:
-
curl localhost:NodePort
orcurl NODE_IP:NodePort
(NodePort) -
curl SVC_IP:SVC_Port
(ClusterIP)
-
# SVC_IP:SVC_Port
controlplane $ curl 10.97.210.100:8081
# Node_IP:Node_Port
controlplane $ curl 172.30.1.2:32433
# localhost:NodePort
controlplane $ curl localhost:32433
- For accessing from inside another pod:
-
curl SVC_NAME:SVC_Port
orcurl SVC_IP:SVC_Port
-
# SVC_NAME:SVC_Port
~ # curl nginx-svc:8081
~ # curl apache-svc:8080
# SVC_IP:SVC_Port
~ # curl 10.104.249.75:8080
~ # curl 10.97.210.100:8081
Endpoints
The Endpoints object (192.168.0.7:80) shows the actual pod IP and port where the traffic will eventually go. It's the backend configuration that tells Kubernetes where to forward the traffic from the service.
Therefore, endpoints IP -> Pod IP
controlplane $ k get endpoints
NAME ENDPOINTS AGE
apache-svc 192.168.0.6:80 2m20s
kubernetes 172.30.1.2:6443 2d8h
nginx-svc 192.168.0.7:80 12s
cka Article's
30 articles in total
Turning Markdown into Learning: publishing a challenge on labs.iximiuz.com
read article
CKA Quick Check Points -- RBAC
read article
CKA Quick Check Points -- Network
read article
CKA Quick Check Points -- Logs & Configs
read article
CKA Recap -- Deployment
read article
ClusterIP vs. NodePort
currently reading
CKA Recap -- Ingress & NetworkPolicy
read article
Kubernets Storage Demos
read article
3. CKA Storage
read article
Why must a Kubernetes cluster have an odd number of nodes
read article
Understanding Pod Topology Spread Constraints in Kubernetes
read article
Deployments and Replica Sets in Kubernetes
read article
40 days of Kubernetes: Docker Fundamentals
read article
Understanding Kubernetes Pods and YAML Fundamentals
read article
Creating a Kubernetes Cluster with Kubeadm and Containerd: A Comprehensive Step-by-Step Guide
read article
Mastering Multi-Stage Builds in Docker 🚀
read article
Mastering Docker Fundamentals: The First Step in Becoming a Certified Kubernetes Administrator
read article
How I Passed the Certified Kubernetes Administrator (CKA) Exam and How You Can Too
read article
AWS EKS Ingress - Canary
read article
Certified Kubernetes Administrator (CKA) Prep.
read article
Certified Kubernetes Administrator (CKA) - Several Successful Story
read article
YouTube 13k Subscriber crossed! Exciting Giveaway
read article
How to Pass the Certified Kubernetes Administrator Examination
read article
'Kubernetes Complete Course In 10 Hours' – your ultimate beginner's guide to Kubernetes FREE!
read article
Kubernetes CKA Exam Question Bank .. 17 Questions with Complete Lab .. In 3 hours .. FREE!
read article
ROAD TO CKA [Certified Kubernetes Administrator ]-Core Concept- Pod(Day-7)
read article
ROAD TO CKA [Certified Kubernetes Administrator ]-Kubernetes Architecture(Day-4)
read article
Installing Kubernetes-1.27.0 in Ubuntu 22.04
read article
ROAD TO CKA [Certified Kubernetes Administrator ]-What Kubernetes is & is not?(Day-3)
read article
ROAD TO CKA [Certified Kubernetes Administrator ]-Core Concept- Control Plane/Master Node (Day-5)
read article
Featured ones: