Services
Course: Kubernetes Part 2 - chapter 5
Services let you actually expose your app over the internet.
Nodeport
Section titled “Nodeport”- Create a
Nodeportservice (service.yml)
apiVersion: v1kind: Servicemetadata: name: nginx-servicespec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 nodePort: 30007 # This port can be any valid port within the NodePort range type: NodePort- Apply it
kubectl apply -f service.yml- Visit any of the nodes on 30007
http://localhost:30007/
💡 This will only work if you’ve started your
kindcluster with the config from slide 2 On vultr, it will just work
LoadBalancer (will only work on a cloud provider)
Section titled “LoadBalancer (will only work on a cloud provider)”The LoadBalancer service type is designed to work with cloud providers to create an external load balancer that routes traffic to the service.
- Replace the
typeto beLoadBalancer
apiVersion: v1kind: Servicemetadata: name: nginx-servicespec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 type: LoadBalancer- Re-apply the config
kubectl apply -f service.yml-
See the loadbalancer created on the dashboard

-
Visit the balancer to see the website
