Forum archive › Kubernetes & Helm Charts
ArchiveAdd External IP to service to access it from outside the cluster
Problem
User wants to access a kubernetes services outside of the cluster ( for example: Webserver on port 8080 ). there are few options to expose the service
change the service type to LoadBalancer and assign ports running the following command
kubectl -n my-nginx patch svc my-nginx -p '{"spec": {"type": "LoadBalancer"}}'
or specify Ports
kubectl patch svc <my_service> -p '{"spec": {"ports": [{"port": 443,"targetPort": 443,"name": "https"},{"port": 80,"targetPort": 80,"name": "http"}],"type": "LoadBalancer"}}'
if you have deployment
kubectl expose deployment/'deployment-name' --type="LoadBalancer"
Change the service type to NodeIP
kubectl patch svc you-svc -p '{"spec": {"type": "NodePort"}}'
Assign External IP to ClusterIP
kubectl patch svc MYHTTPSERVICE -p '{"spec":{"externalIPs":["192.168.0.194"]}}'
Attachment: command.txt
We do this for a living.
Kubernetes, DevOps and platform engineering, delivered in days — not another weekend lost to a stack trace.
Start a project →