Skip to main content

🔗 Services

Pods are born and die, and the IP changes every time they are recreated. The Service creates a fixed address in front of the pods, so that other applications (or you) can always reach them.

TypeWho accessesWhen to use
ClusterIPOnly inside the clusterCommunication between applications
NodePortFrom outside, via node IP + portTesting and simple access
LoadBalancerFrom outside, via its own IPProduction, without Ingress
info

Services are created with kubectl. The Nuvion Panel is used to open the external network access (step 5).


🚀 Before you start​

🚀 1. Create a test application​

kubectl create deployment web --image=nginx --replicas=2
kubectl get pods

Wait for both pods to be Running.

🚀 2. Create an internal Service (ClusterIP)​

kubectl expose deployment web --name=web-svc --port=80 --target-port=80
kubectl get svc web-svc

Note the CLUSTER-IP shown.

🚀 3. Test access inside the cluster​

kubectl run teste-curl --rm -it --image=curlimages/curl --restart=Never -- curl http://web-svc

If the Welcome to nginx! page appears, the Service is working.

🚀 4. Create an external Service (NodePort)​

kubectl expose deployment web --name=web-nodeport --type=NodePort --port=80
kubectl get svc web-nodeport

The PORT(S) column shows something like 80:31245/TCP. The number after the colon (31245) is the external port. Note yours.

🚀 5. Open the port on the network​

To access from outside, the port must be open and the node must have an accessible IP.

  1. Go to Compute > Security Groups and open the group used by the cluster nodes.
  2. Add an inbound rule, protocol TCP, on the port noted in step 4.
  3. Go to Compute > Floating IPs and associate an IP with one of the workers, if you do not have one yet.

Inbound rule in the security group

🚀 6. Access the application​

In the browser, open http://NODE-IP:PORT (example: http://203.0.113.10:31245).

✅ How to know it worked​

The Welcome to nginx! page opens in the browser.

❗ Common problems​

SymptomCauseSolution
Page does not open (timeout)Port not open or node without an accessible IPReview step 5
Empty ENDPOINTS in kubectl get endpoints web-svcThe Service did not find podsCheck that the pods are Running
EXTERNAL-IP shows as noneNormal for NodePortUse the node IP

🧹 Cleanup​

kubectl delete svc web-svc web-nodeport
kubectl delete deployment web

➡️ Next step: Ingress

🧠 Questions?​

Talk to our SaveinCloud technical support team!