Sobes.tech
Middle

What methods of publishing applications from Kubernetes do you know?

sobes.tech AI

Answer from AI

Service Type

  • ClusterIP: Internal IP address accessible only within the cluster.
  • NodePort: Opens a port on each cluster node, traffic is redirected to Pod.
  • LoadBalancer: Integrates with cloud provider to create an external load balancer.

Ingress

Provides routing of HTTP/S traffic based on rules. Requires an Ingress controller (e.g., Nginx Ingress).

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - host: myapp.example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: my-service
            port:
              number: 80

Ingress Gateway (Service Mesh)

In a Service Mesh (e.g., Istio, Linkerd), an Ingress Gateway manages incoming traffic, including advanced routing, security policies (mTLS), and observability.

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway # Uses Istio's default ingress gateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - myapp.example.com

ExternalName Service

Creates a CNAME record in its DNS pointing to an external FQDN. Does not redirect traffic.

apiVersion: v1
kind: Service
metadata:
  name: my-ext-service
spec:
  type: ExternalName
  externalName: api.external.com

HostNetwork

Allows a Pod to use the node's network namespace. Usually not recommended for security and isolation reasons.

Using Third-Party Load Balancers and Reverse Proxies

  • Mechanism: Traffic first hits an external load balancer (HAProxy, Nginx Outside Kubernetes) or CDN, which then redirects it to NodePort or LoadBalancer Service in the cluster.
  • Advantages: Improved caching, WAF, more granular traffic control to the cluster.

Publishing via VPN

For accessing internal Kubernetes services from outside, but in a controlled environment.

Summary table of publishing methods:

Method Level Purpose Advantages Disadvantages
Service Type: ClusterIP Internal Interaction within the cluster Simplicity, security (internal) Not accessible from outside
Service Type: NodePort Node Access at the node level Simplicity, clarity Uses node ports, not scalable
Service Type: LoadBalancer Cloud External access via cloud LB Auto-scaling, cloud integration Cloud LB costs, provider dependency
Ingress L7 (HTTP/S) Routing of HTTP/S traffic Routing flexibility, centralized management Requires Ingress Controller
Ingress Gateway L7 (Service Mesh) Advanced traffic management (mTLS, A/B) Rich Service Mesh features Requires Service Mesh deployment
ExternalName Service DNS Points to an external FQDN Easy external service pointing Does not redirect traffic
HostNetwork Node network Uses node's network namespace Direct network access to the node Security risks, poor isolation
Third-Party LB/RP L4/L7 (External) Advanced cluster capabilities WAF, CDN, finer control Additional infrastructure needed
VPN Network Controlled external access Security (inside VPN) VPN setup required