Applying Tags to Node Pools

Find out how to apply tags to node pools you create using Kubernetes Engine (OKE).

When you create a managed node pool or a virtual node pool, you can optionally apply tags to the node pool resource. These tags are referred to as node pool tags. You can specify both defined tags and free-form tags as node pool tags.

Tag defaults with default values that are specified for the node pool's compartment are automatically applied to the node pool resource. Tag defaults with user-applied values are only applied to the node pool resource if the node pool is in a different compartment to the cluster. If that is the case, then you must specify a value for tag defaults with user-applied values by specifying node pool tags, as described in this section.

Note the following:

  • If you use the 'Quick Create' workflow to create a new cluster, the free-form tags "OKEclusterName": <cluster-name> and "OKEnodePoolName": <node-pool-name> are also automatically added to node pools in the new cluster. The tags are not added to node pools if you use the 'Custom Create' workflow to create the cluster. Note that the values of these tags do not change if you subsequently change the name of the cluster or node pool.
  • Node pool tags are not applied to worker nodes in the node pool. To apply tags to worker nodes, see Applying Tags to Nodes.
  • To apply defined tags from a tag namespace belonging to one compartment to a node pool belonging to a different compartment, you must include a policy statement to allow the cluster to use the tag namespace. See Additional IAM Policy when a Cluster and a Tag Namespace are in Different Compartments.

Using the Console to Specify Node Pool Tags

To add a node pool tag to a new node pool when creating a new cluster:

  1. Follow the instructions in Using the Console to create a Cluster with Explicitly Defined Settings in the 'Custom Create' workflow to create a new cluster.
  2. In the Node pool tags section of the Node pools page, select Add tag.
  3. To add a defined tag to the node pool:
    • Namespace: Select the tag namespace to which the tag belongs.
    • Key: Select the name of the defined tag to apply to the node pool.
    • Value: Either select the value for the tag from a pre-defined list of values, or enter a new value, or leave blank (depending on how the defined tag has been set up).
  4. To add a free-form tag to the node pool:
    • Namespace: Set to None (free-form tags do not belong to a tag namespace).
    • Key: Enter a name for the free-form tag to apply to the node pool.
    • Value: Enter a value for the tag to apply to the node pool.

To update node pool tags applied to an existing node pool:

  1. Follow the instructions in Modifying Node Pool and Worker Node Properties to update an existing node pool.
  2. Select the Tags tab of the node pool details page.
  3. In the Node pool tags section:
    • Select Add to apply additional defined tags and free-form tags to the node pool.
    • Select Edit from the the Actions menu (three dots) to change the value of defined tags and free-form tags previously applied to the node pool.
    • Select Delete from the the Actions menu (three dots) to remove defined tags and free-form tags previously applied to the node pool.

Using the CLI to Specify Managed Node Pool Tags

oci ce node-pool create \
--cluster-id <cluster-ocid> \
--compartment-id <compartment-ocid> \
--kubernetes-version <kubernetes-version> \
--name <node-pool-name> \
--node-shape <node-shape> \
--defined-tags <json-name-value-pairs> \
--freeform-tags <json-name-value-pairs>

For example:

oci ce node-pool create \
--cluster-id ocid1.cluster.oc1.iad.aaaaaaaaaf______jrd \
--compartment-id ocid1.compartment.oc1..aaaaaaaay______t6q \
--kubernetes-version v1.20.11 \
--name Finance-Node-Pool \
--node-shape VM.Standard2.1 \
--defined-tags {"Operations": {"CostCenter": "42"}} \
--freeform-tags {"Department": "Finance"}

Using the CLI to Specify Virtual Node Pool Tags

oci ce virtual-node-pool create \
--cluster-id <cluster-ocid> \
--compartment-id <compartment-ocid> \
--display-name <node-pool-name> \
--kubernetes-version <kubernetes-version> \
--placement-configurations "[{\"availabilityDomain\":\"<ad-name>\",\"faultDomain\":[\"FAULT-DOMAIN-<n>\"],\"subnetId\":\"<virtualnode-subnet-ocid>\"}]" \
--nsg-ids "[\"<virtual-node-nsg-ocid>\"]" \
--pod-configuration "{\"subnetId\":\"<pod-subnet-ocid>\",\"nsgIds\":[\"<pod-nsg-ocid>\"],\"shape\":\"<shape-name>\"}" \
--size <number-of-nodes> \
--defined-tags <json-name-value-pairs> \
--freeform-tags <json-name-value-pairs>

For example:

oci ce virtual-node-pool create \
--cluster-id ocid1.cluster.oc1.phx.aaaaaaaa______w5q \
--compartment-id ocid1.compartment.oc1..aaaaaaaa______n5q \
--display-name sales-vnp \
--kubernetes-version v1.24.1 \
--placement-configurations "[{\"availabilityDomain\":\"GMvH:PHX-AD-1\",\"faultDomain\":[\"FAULT-DOMAIN-1\"],\"subnetId\":\"ocid1.subnet.oc1.phx.aaaaaaaa______sra\"}]" \
--nsg-ids "[\"ocid1.networksecuritygroup.oc1.phx.aaaaaaaa______hpa\"]" \
--pod-configuration "{\"subnetId\":\"ocid1.subnet.oc1.phx.aaaaaaaa______o7q\",\"nsgIds\":[\"ocid1.networksecuritygroup.oc1.phx.aaaaaaaa______osq\"],\"shape\":\"Pod.Standard.E4.Flex\"}" \
--size 1 \
--defined-tags {"Operations": {"CostCenter": "43"}} \
--freeform-tags {"Department": "Sales"}

Using the API to Specify Node Pool Tags

To add and update managed node pool tags, use the freeformTags and definedTags attributes of the CreateNodePoolDetails and UpdateNodePoolDetails objects used by the CreateNodePool and UpdateNodePool operations.

To add and update virtual node pool tags, use the freeformTags and definedTags attributes of the CreateVirtualNodePoolDetails and UpdateVirtualNodePoolDetails objects used by the CreateVirtualNodePool and UpdateVirtualNodePool operations.