The Kong Ingress Controller (KIC) is an open-source ingress controller for Kubernetes that leverages the power and flexibility of the Kong API Gateway. It allows you to manage and control external access to your Kubernetes services, providing advanced features like routing, load balancing, authentication, authorization, rate limiting, and transformations, all within a Kubernetes-native environment.
1. **Ingress Definition:**
```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata:
name: my-ingress annotations: kubernetes.io/ingress.class: kong # Use Kong Ingress Controllerspec:
rules: - http: paths: - path: /api pathType: Prefix backend: service: name: my-service port: number: 80```
This configuration defines an Ingress resource that uses the `kong` ingress class to route traffic to the `/api` path to the `my-service` service on port 80.
2. **KongPlugin Custom Resource:**
```yaml apiVersion: configuration.konghq.com/v1 kind: KongPlugin metadata:
name: rate-limitingconfig:
second: 10 # Limit to 10 requests per second policy: localplugin: rate-limiting ```
This configuration defines a KongPlugin resource that applies rate limiting to incoming requests, allowing a maximum of 10 requests per second.