πŸ† The Evolution of Kubernetes Traffic Control: From Ingress to Gateway API, and Traefik CRD

This blog post summarizes three core methods for cluster traffic control today. By utilizing open-source Traefik, you can leverage all Kubernetes native features like Ingress and Gateway, as well as Traefik’s CRD, IngressRoute. Here, we will delve into how to write YAML files for these functionalities.


1. πŸ›οΈ The Power of the Classic: Kubernetes Native Ingress

Ingress, which has served as the gateway for traffic since the early days of Kubernetes, is the most familiar and proven method. It is the standard specification for L7 load balancing.

  • How it works: Ingress resources define rules, and the actual processing is handled by controllers like Nginx or Traefik.
  • Advantages: Configuration is very simple and works as a standard in almost all cloud environments.
  • Limitations: To implement complex routing (Canary, mirroring, etc.), one must rely on fragmented Annotations specific to each vendor, which significantly reduces configuration readability.

πŸ“ Ingress Manifest Example

YAML

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: native-ingress
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
  rules:
  - host: app.juhun.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: app-service
            port:
              number: 80

2. πŸš€ Next-Generation Standard: Kubernetes Native Gateway API

Emerging to overcome the limitations of Ingress, the Gateway API‘s core is its role-oriented design. This standardized structure is a great boon for engineers designing large-scale infrastructure.

  • Role Separation: It allows for clear separation of responsibilities between infrastructure administrators (GatewayClass, Gateway) and service developers (HTTPRoute).
  • Standardized Advanced Features: It supports traffic weight distribution, header manipulation, and more as standard specifications, without relying on Annotations.
  • Flexibility: It enables integrated control spanning from L4 (TCP/UDP) to L7, offering excellent extensibility.

πŸ“ Gateway API (HTTPRoute) Example

YAML

apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: app-gateway-route
spec:
  parentRefs:
  - name: my-gateway
  rules:
  - matches:
    - path: { type: PathPrefix, value: /api }
    backendRefs:
    - name: api-service-v1
      port: 80
      weight: 90
    - name: api-service-v2 # Canary deployment
      port: 80
      weight: 10

3. 🎨 The Essence of Optimization: Traefik CRD (IngressRoute)

Standards are good, but when you want to extract 100% of a specific solution’s performance, we choose

CRD (Custom Resource Definition)

. Traefik’s IngressRoute particularly offers both ‘intuitiveness’ and ‘powerful features’ simultaneously.

  • Middleware Chaining: Authentication, rate limiting, error page handling, etc., can be created as middleware objects and freely assembled.
  • Kubernetes Native: While using Kubernetes-style syntax, it allows for much finer-grained traffic control than standard Ingress.
  • Security Optimization: TLS configuration and authentication processing are very intuitive, making it optimal for building security infrastructure, a specialized field.

πŸ“ Traefik IngressRoute Example

YAML

apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: traefik-crd-route
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`juhun-lab.com`) && PathPrefix(`/admin`)
    kind: Rule
    services:
    - name: admin-service
      port: 80
    middlewares:
    - name: ip-whitelist # Apply security middleware

🧐 Final Comparison Guide

Category Ingress Gateway API Traefik CRD
Recommended For Simple web service deployment Large multi-tenancy clusters When you want to use Traefik’s full power
Complexity Low (Easy start) High (Thorough role separation) Medium (Intuitive CRD structure)
Flexibility Limited (Dependent on Annotations) Very High (Standard specification) High (Utilizes middleware)

πŸ’‘ Concluding Remarks

As you may have already realized, the choice of technology is not about ‘what is better,’ but ‘what is more suitable for a given environment.’ Just as you cherish the precious time spent with your youngest born in November, we hope our clusters will also be managed more robustly and peacefully through these three tools.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *