Tags and labels are a way to organize and categorize your resources. This doc explains how to annotate your Konnect entities managed by Kong Gateway Operator with tags and labels depending on particular entity’s support for those.
Labelling and Tagging resources
Labeling
Labels are key-value pairs you can attach to certain objects. Currently, the only Konnect entity that supports labels is KonnectGatewayControlPlane
.
You can add labels to the KonnectGatewayControlPlane
object by specifying the labels
field in the spec
section.
echo '
kind: KonnectGatewayControlPlane
apiVersion: konnect.konghq.com/v1alpha1
metadata:
name: gateway-control-plane
namespace: default
spec:
labels: # Arbitrary key-value pairs
environment: production
team: devops
name: gateway-control-plane
konnect:
authRef:
name: konnect-api-auth # Reference to the KonnectAPIAuthConfiguration object
' | kubectl apply -f -
Check that Programmed
is True
on the gateway-control-plane
resource:
You can verify the KonnectGatewayControlPlane
was reconciled successfully by checking its Programmed
condition.
kubectl get -n kong konnectgatewaycontrolplane gateway-control-plane \
-o=jsonpath='{.status.conditions[?(@.type=="Programmed")]}' | jq
The output should look similar to this:
{
"observedGeneration": 1,
"reason": "Programmed",
"status": "True",
"type": "Programmed"
}
At this point, labels should be visible in the Gateway Manager UI.
Tagging
Tags are values that you can attach to objects. All the Kong Konnect entities that can be attached to a KonnectGatewayControlPlane
object support tagging. You can add tags to those entities by specifying the tags
field in their spec
section.
For example, to add tags to a KongService
object, you can apply the following YAML manifest:
echo '
kind: KongService
apiVersion: configuration.konghq.com/v1alpha1
metadata:
name: service
namespace: default
spec:
tags: # Arbitrary list of strings
- production
- devops
name: service
host: example.com
controlPlaneRef:
type: konnectNamespacedRef
konnectNamespacedRef:
name: gateway-control-plane # Reference to the KonnectGatewayControlPlane object
' | kubectl apply -f -
Check that Programmed
is True
on the service
resource:
You can verify the KongService
was reconciled successfully by checking its Programmed
condition.
kubectl get -n kong kongservice service \
-o=jsonpath='{.status.conditions[?(@.type=="Programmed")]}' | jq
The output should look similar to this:
{
"observedGeneration": 1,
"reason": "Programmed",
"status": "True",
"type": "Programmed"
}
At this point, tags should be visible in the Gateway Manager UI.