In this section, we will expose our voting application to external users by creating a Kubernetes service of the LoadBalancer type. Services have been covered in depth in Chapter 5, Kubernetes Networking. At the end of this section, anyone who has the external IP of your new service will be able to access the application.
To create the service, execute the following steps:
- Open the PowerShell window.
- Create a voting-application-service.yaml manifest file for the Kubernetes service with the following content:
apiVersion: v1
kind: Service
metadata:
namespace: dev
name: voting-application-frontend
labels:
app: voting-application
spec:
type: LoadBalancer (1)
ports:
- protocol: TCP
port: 80 (2)
selector:
app: voting-application
Here, the key points are ensuring that the type of service is LoadBalancer (1) and using the proper port for the service...