This project demonstrates four main types of Kubernetes services:
- ClusterIP - Internal cluster service
- NodePort - Access via node port
- LoadBalancer - External load balancer
- ExternalName - DNS CNAME for external services
k8s-service/
├── clusterip/ # ClusterIP service
├── nodeport/ # NodePort service
├── loadbalancer/ # LoadBalancer service
├── externalname/ # ExternalName service
└── README.md # This file
- Minikube
- Helm 3.x
- kubectl
# Installation
helm install clusterip-demo ./clusterip
# Verification
kubectl get svc clusterip-demo-clusterip-service
# Testing (create a test pod)
kubectl run test-pod --image=curlimages/curl -it --rm --restart=Never -- sh
# Inside pod: curl http://clusterip-demo-clusterip-service
# Or via port-forward
kubectl port-forward svc/clusterip-demo-clusterip-service 8080:80
curl http://localhost:8080Features: Only accessible inside the cluster, used for internal pod communication.
# Installation
helm install nodeport-demo ./nodeport
# Verification
kubectl get svc nodeport-demo-nodeport-service
# Get NodePort and node IP
NODE_PORT=$(kubectl get svc nodeport-demo-nodeport-service -o jsonpath='{.spec.ports[0].nodePort}')
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
# Testing
curl http://$NODE_IP:$NODE_PORT
# For minikube
minikube service nodeport-demo-nodeport-serviceFeatures: Accessible externally via any node IP on port 30000-32767.
# Installation
helm install loadbalancer-demo ./loadbalancer
# Verification (wait for EXTERNAL-IP)
kubectl get svc loadbalancer-demo-loadbalancer-service
watch kubectl get svc loadbalancer-demo-loadbalancer-service
# Testing (after getting EXTERNAL-IP)
EXTERNAL_IP=$(kubectl get svc loadbalancer-demo-loadbalancer-service -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
curl http://$EXTERNAL_IP
# For minikube (requires minikube tunnel)
minikube tunnel # In a separate terminalFeatures: Automatically creates external load balancer (in cloud) or requires minikube tunnel (locally).
# Installation
helm install externalname-demo ./externalname
# Verification
kubectl get svc externalname-demo-externalname-service
# Testing (use test pod)
kubectl exec -it externalname-demo-externalname-service-test -- sh
# Inside pod:
nslookup externalname-demo-externalname-service
curl -v http://externalname-demo-externalname-serviceFeatures: Creates DNS CNAME to external service, allows using local name instead of external domain.
| Type | Availability | Use Case | Performance |
|---|---|---|---|
| ClusterIP | Inside cluster only | Internal pod-to-pod communication | High |
| NodePort | Via node IP, port 30000-32767 | Development, testing | Medium |
| LoadBalancer | External IP (cloud) | Production, public services | High |
| ExternalName | DNS CNAME to external service | Integration with external services | Depends on external service |
helm uninstall clusterip-demo
helm uninstall nodeport-demo
helm uninstall loadbalancer-demo
helm uninstall externalname-demoAfter deploying each service type, run the following commands to verify:
- ✅ Accessible via DNS name inside cluster
- ✅ Not accessible externally without port-forward
- ✅ Uses internal cluster IP
- ✅ Accessible via any node IP
- ✅ Port in range 30000-32767
- ✅ Works without additional configuration
- ✅ Gets external IP automatically in cloud
- ✅ Requires configuration in local clusters (minikube tunnel)
- ✅ Suitable for production
- ✅ Creates DNS CNAME record
- ✅ Allows accessing external services via local name
- ✅ Does not proxy traffic, only DNS resolution
All subprojects support Docker registry configuration via values.yaml:
image:
registry: "" # Use Docker Hub directly (default)
# registry: localhost:<PORT> # For local registry
repository: nginx
pullPolicy: IfNotPresent
tag: "1.25"If registry is not specified (empty string), images will be pulled directly from Docker Hub or other public registries.
