Sobes.tech
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:

  1. Service of type LoadBalancer — automatically creates an external load balancer (if supported by the cloud provider), which directs traffic to the pods.

  2. NodePort — opens a fixed port on all cluster nodes, through which the application can be accessed externally.

  3. Ingress — an object that manages external access to services, usually via HTTP/HTTPS, with the ability to configure routing rules, SSL, etc.

  4. 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.