Adding external annotation to routes and ingresses

You can add external annotations and labels to routes and ingresses.

You can configure annotations for ingress and routes in API Connect on subsystems (Management, Portal, Analytics, and Gateway) or API Connect custom resource (CR). Depending on your needs, you can choose from the following two approaches to configure the annotations in the CR.

Using custom annotations

This approach is suitable when you manually define and manage the annotations in the CR. These annotations are carried over to the routes and ingresses managed by the API Connect operator.

The following example demonstrates the process of configuring external annotation using Management CR.

Example

apiVersion: management.apiconnect.ibm.com/v1beta1
kind: ManagementCluster
metadata:
  name: management
spec:
  apiManagerEndpoint:
    annotations:
      cert-manager.io/issuer: ingress-issuer
      my-custom-key: my-custom-value
    hosts:
    - name: manager.example.com
      secretName: apim-endpoint
You can use this custom annotation when,
  • You have a static set of annotations known in advance.
  • You want the API Connect operator to consistently manage these annotations.
  • You don’t expect these annotations to change dynamically.

Using pattern matching for external annotation

You can use this method when annotations or label patterns are generated and managed by an external process, and you want these to persist on the routes and ingresses without the API Connect operator removing them. This is especially useful when you are using a third-party load balancer which might add their own annotations.

By using the external annotation, you can preserve custom external annotations and labels when the key matches the regular expression. Usage of external annotation is supported during creation and update processes in OpenShift® Container Platform (OCP), Cloud Pak for Integration (CP4I), and Kubernetes (K8s).

The following example demonstrates the process of configuring external annotation using Management CR.

Example

apiVersion: management.apiconnect.ibm.com/v1beta1
kind: ManagementCluster
metadata:
  name: management
  annotations:
    apiconnect-operator/external-key-pattern: ".*myloadbalancerprovider.*"
spec:
 
You can use this custom annotation when,
  • Annotations are dynamically generated and managed by an external process (for example, a load balancer controller).
  • You need these annotations to persist without interference from the API Connect operator.
Note: If you use an invalid regex pattern, a webhook validation error occurs during installation or update. For more information on Golang regular expression syntax, see https://pkg.go.dev/regexp/syntax.