Managing Access By Applying Tags to Cluster-Related Resources
Find out how to use tags and IAM policies to manage access to resources related to the clusters you create using Kubernetes Engine (OKE).
Having applied tags to cluster-related resources, you can control access to other resources by including the tags in IAM policies.
Including tags in IAM policies is particularly useful when authorizing worker nodes to access other resources. If you specify node tags when initially defining a node pool and the node pool is subsequently scaled out, the node tags are automatically applied to any new worker nodes that are created. Provided you have included the node tags in an IAM policy that grants access to other resources, the new worker nodes are automatically authorized to access the same resources as existing worker nodes in the node pool.
Note that you cannot use free-form tags in IAM policies to control access to resources.
Example: Authorizing a managed node pool to read object storage objects
To authorize only worker nodes in a particular managed node pool to read object storage objects in a certain compartment:
- Define a new managed node pool and specify:
- A name for the node pool that is unique in the compartment. For example,
acme-pool-one
- A node tag set to the name of the node pool. For example, a defined tag named
acme-nodepool-name
in a tag namespace namedacme-project
, set to the valueacme-pool-one
.
When you create the node pool, the node tag
acme-project.acme-nodepool-name='acme-pool-one'
is applied to all the compute instances hosting worker nodes in the node pool. - A name for the node pool that is unique in the compartment. For example,
- Define a dynamic group to represent the node pool:
- Open the navigation menu and click Identity & Security. Under Identity, click Domains. Under Identity domain, click Dynamic groups.
- Follow the instructions in To create a dynamic group, and give the dynamic group a name (for example,
acme-oke-pool-one-dyn-grp
). -
Enter a rule that includes all worker nodes in the compartment to which the node tag has been applied, in the format:
All {instance.compartment.id = '<compartment_ocid>', tag.<tagnamespace>.<tagkey>.value = '<tagvalue>'}
For example:
All {instance.compartment.id = 'ocid1.compartment.oc1..aaaaaaaa23______smwa', tag.acme-project.acme-nodepool-name.value = 'acme-pool-one'}
- Click Create Dynamic Group.
- Define an IAM policy that authorizes the dynamic group to read object storage objects in a compartment:
- Open the navigation menu and click Identity & Security. Under Identity, click Policies.
- Follow the instructions in To create a policy, and give the policy a name (for example,
acme-oke-read-object-dyn-grp-policy
). -
Enter a policy statement to allow the dynamic group to read object storage objects, in the format:
Allow dynamic-group <dynamic-group-name> to read objects in compartment <compartment-name>
where:
<dynamic-group-name>
is the name of the dynamic group you created earlier. Note that if a dynamic group is not in the default identity domain, prefix the dynamic group name with the identity domain name, in the formatdynamic-group '<identity-domain-name>'/'<dynamic-group-name>'
. You can also specify the dynamic group using its OCID, in the formatdynamic-group id <dynamic-group-ocid>
.<compartment-name>
is the name of the compartment containing the object storage objects.
For example:
Allow dynamic-group acme-oke-pool-one-dyn-grp to read objects in compartment acme-oke-obj-storage-comp
- Click Create to create the new policy.
All worker nodes in the node pool can now read object storage objects in the compartment you specified.