Junior — Middle
What methods can be used to ensure external connectivity to an application deployed in Kubernetes?
sobes.tech AI
Answer from AI
In Kubernetes, the following methods are commonly used to provide external access to an application:
-
Service of type LoadBalancer — automatically creates an external load balancer (if supported by the cloud provider), which directs traffic to the pods.
-
NodePort — opens a fixed port on all cluster nodes, through which the application can be accessed externally.
-
Ingress — an object that manages external access to services, usually via HTTP/HTTPS, with the ability to configure routing rules, SSL, etc.
-
External IP — assigning an external IP address to a service (if the infrastructure supports it).
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.