Services Flashcards
What types of services are there?
ClusterIp, NodePort, LoadBalancer, ExternalName
Describe the ClusterIp service type?
The ClusterIp type exposes an ip adress for a particular service accessile only from within the kubernetes cluster.
Describe the NodePort service type?
The NodePort service type exposes one port on each node that is linked to a ClusterIp for that service, allowing external access to the service.
Describe the LoadBalancer service type?
The LoadBalancer service type uses a cloud provider’s load balancer to access a NodePort type service
Describe the ExternalName service type?
Does not use selectors and instead adds a CNAME entry to DNS add-on for the service.
apiVersion: v1
kind: Service
metadata:
name: my-database
namespace: prod
spec:
type: ExternalName
externalName: my.database.example.com
With the above example a request to my-database.prod.svc.cluster.local is redirected to my.database.example.com
What is an EnpdointSlice?
An EndpointSlice is a resource that is created automatically by a Service that has a selector. The EndpointSlice will have endpoints to all the resources that have matching labels to that of the selector from the Service.
Create a service in a yaml file of type NodePort with port 3000 as target and port using tcp protocol and selector app: a-label
apiVersion: v1
kind: Service
metadata:
name: a-service
spec:
type: NodePort
ports:
- name: a-port
port: 3000
protocol: TCP
targetPort: 3000
selector:
app: a-label