Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ethen8181
GitHub Repository: ethen8181/machine-learning
Path: blob/master/model_deployment/fastapi_kubernetes/service.yaml
1480 views
1
# A service handles request either coming from inside the Kubernetes cluster
2
# from one pod to another or outside the cluster. They define how requests
3
# should be routed/handled. Service is usually a load balancer, though there
4
# are many different types of service that we can configure.
5
6
# Another term that is associated with exposing our application is ingress,
7
# we won't be using/discussing it here, as it's generally used for exposing
8
# multiple services under the same IP address, which we technically don't have/need
9
# for this application.
10
# https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0
11
12
# 1. we create a service, and it's going to be applied to any pods that has
13
# the name fastapi-model (the selector section). `selector` labels are key-value
14
# pairs specified/used by the users to select a set of objects. We have the
15
# flexibility to develop our own conventions.
16
17
# 2. there're many different options for configuring ports, see comments
18
apiVersion: v1
19
kind: Service
20
metadata:
21
name: fastapi-model-service
22
spec:
23
selector:
24
app: fastapi-model
25
type: LoadBalancer
26
ports:
27
- protocol: TCP
28
# this port is accessible within the cluster,
29
# i.e. inter-communications between the pods, so if a pod inside
30
# the cluster wants to talk to this application
31
port: 80
32
# port to forward to inside the pod
33
targetPort: 80
34