Junior — Middle
What methods can be used to make your application accessible outside the Kubernetes cluster?
sobes.tech AI
Answer from AI
To make an application accessible outside the Kubernetes cluster, several methods can be used:
-
Service of type LoadBalancer — creates an external load balancer (if supported by the cloud provider) that directs traffic to the pods.
-
NodePort — opens a fixed port on each cluster node, which can be accessed from outside the cluster.
-
Ingress — an object that manages external access to services within the cluster, usually via HTTP/HTTPS, with routing and SSL configuration options.
-
External IP — assigning an external IP address to a service (for example, in some clouds or using MetalLB).
Example of using Ingress:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: example-ingress
spec:
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-service
port:
number: 80
Thus, the choice of method depends on the infrastructure and access requirements.