ingress-annotator

by kuoss

Helm chartv0.3.0App v0.3.0Apache-2.0Verified publisher

Dynamically manages Kubernetes Ingress annotations based on ConfigMap rules, ensuring consistency and automation.

About this chart

ingress-annotator

The ingress-annotator Helm chart is a Kubernetes utility that automates the management of annotations across Ingress resources. By leveraging a ConfigMap-driven approach, it ensures consistent, dynamic, and conflict-free annotation application.

Prerequisites

  • Kubernetes 1.19+
  • Helm 3+

Add Helm Repository

helm repo add kuoss https://kuoss.github.io/helm-charts
helm repo update

Install Chart

helm install [RELEASE_NAME] kuoss/ingress-annotator

The command deploys ingress-annotator on the Kubernetes cluster using the default configuration. The configuration section lists the parameters that can be configured during installation.

Uninstallation

helm uninstall [RELEASE_NAME]

The command removes all the Kubernetes components associated with the chart and deletes the release.

Configuration

The following values can be customized in your values.yaml or via --set CLI options:

ParameterDescriptionDefault
replicaCountNumber of replicas for the deployment1
image.repositoryContainer image repositoryghcr.io/kuoss/ingress-annotator
image.pullPolicyImage pull policyIfNotPresent
image.tagOverrides the image tag whose default is the chart appVersion""
imagePullSecretsSecrets for image pull[]
nameOverrideOverride the name of the chart""
fullnameOverrideOverride the full name of the chart""
serviceAccount.createSpecifies whether a service account should be createdtrue
serviceAccount.annotationsAnnotations to add to the service account{}
serviceAccount.nameThe name of the service account to use""
podAnnotationsAdditional annotations for the pod{}
podSecurityContextSecurity context for the pod{}
metrics.service.typeService type for the metrics endpointClusterIP
metrics.service.portPort for the metrics service8081
resourcesResource requests and limits{}
autoscaling.enabledEnable autoscalingfalse
autoscaling.minReplicasMinimum number of replicas1
autoscaling.maxReplicasMaximum number of replicas100
autoscaling.targetCPUUtilizationPercentageTarget CPU utilization percentage80
nodeSelectorNode selector for scheduling{}
tolerationsTolerations for pod assignment[]
affinityAffinity rules for pod assignment{}
rulesConfiguration rules for managing ingress annotations{}

Defining Rules

You can define rules via values.yaml.

rules:
- description: enforce-https
  selector:
    include: "*"
  annotations:
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"

Rule Examples

IP Whitelisting for a Namespace

- description: allow-specific-ips
  selector:
    include: "dev"
  annotations:
    nginx.ingress.kubernetes.io/whitelist-source-range: "68.204.79.0/27,68.204.135.80/28,246.91.35.0/24"

Alternatively, using a list format:

[!NOTE] listAnnotations allows defining annotations in a structured list format, making it easier to manage multiple values and add descriptive comments.

- description: allow-specific-ips
  selector:
    include: "dev"
  listAnnotations: # Ensure listAnnotations not annotations
    nginx.ingress.kubernetes.io/whitelist-source-range:
      - 68.204.79.0/27   # Dev Site 1
      - 68.204.135.80/28 # Dev Site 2
      - 246.91.35.0/24   # Testers

Authentication (OAuth2)

- description: ns1-oauth
  selector:
    include: "ns1"
  annotations:
    nginx.ingress.kubernetes.io/auth-signin: "https://oauth.example.com/oauth2/start?rd=https://$host$request_uri"
    nginx.ingress.kubernetes.io/auth-url: "https://oauth.example.com/oauth2/auth"

Basic Authentication for Internal Services

- description: enforce-basic-auth
  selector:
    include: "internal/*"
  annotations:
    nginx.ingress.kubernetes.io/auth-type: "basic"
    nginx.ingress.kubernetes.io/auth-secret: "internal/basic-auth"

Rate Limiting for High-Traffic Endpoints

- description: rate-limit-api
  selector:
    include: "api/throttle-*"
  annotations:
    nginx.ingress.kubernetes.io/limit-rate: "10" # Limits requests to 10 per second

Enforcing HTTPS Redirects

- description: enforce-https
  selector:
    include: "*"
  annotations:
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true" # Forces HTTP to HTTPS redirect
    nginx.ingress.kubernetes.io/ssl-redirect: "true" # Ensures HTTPS enforcement

Selector Format

Selectors allow flexible matching using include and exclude fields, following the format: namespace/ingress-name. These fields support:

  • Multiple values as a comma-separated string (include: "dev,prod").
  • Wildcards (*) for broader matches (include: "*" applies to all namespaces and Ingress resources).
  • Explicit namespace-only selection (include: "dev" selects all Ingress resources in the dev namespace).
  • Explicit Ingress name selection (include: "prod/hello-world" selects only hello-world in the prod namespace).

Include Rules

include: "*"  # Applies to all Ingress resources
include: "dev"  # Applies to all Ingress resources in the 'dev' namespace
include: "prod/*"  # Applies to all Ingress resources in the 'prod' namespace
include: "dev,prod"  # Applies to both 'dev' and 'prod' namespaces
include: "prod/hello-*"  # Matches Ingress resources in 'prod' starting with 'hello-'

Exclude Rules

exclude: "prod/ingress1"  # Excludes 'ingress1' in 'prod'
exclude: "prod-*"  # Excludes all namespaces starting with 'prod-'

Deploy ingress-annotator with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has ingress-annotator on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartingress-annotator is pinned at v0.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply