Path: blob/master/model_deployment/fastapi_kubernetes/service.yaml
1480 views
# A service handles request either coming from inside the Kubernetes cluster1# from one pod to another or outside the cluster. They define how requests2# should be routed/handled. Service is usually a load balancer, though there3# are many different types of service that we can configure.45# Another term that is associated with exposing our application is ingress,6# we won't be using/discussing it here, as it's generally used for exposing7# multiple services under the same IP address, which we technically don't have/need8# for this application.9# https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e01011# 1. we create a service, and it's going to be applied to any pods that has12# the name fastapi-model (the selector section). `selector` labels are key-value13# pairs specified/used by the users to select a set of objects. We have the14# flexibility to develop our own conventions.1516# 2. there're many different options for configuring ports, see comments17apiVersion: v118kind: Service19metadata:20name: fastapi-model-service21spec:22selector:23app: fastapi-model24type: LoadBalancer25ports:26- protocol: TCP27# this port is accessible within the cluster,28# i.e. inter-communications between the pods, so if a pod inside29# the cluster wants to talk to this application30port: 8031# port to forward to inside the pod32targetPort: 803334