Skip to content

Project Tags

A tag group with one or more key-value pair(s) can be created and associated with a project. These can be used to identify certain attributes associated with a project. As an example, from a cost management perspective, these tags can be used to identify the cost center ID, business group, billing approver ID etc.

A Tag Group can be created and associated to projects via multiple methods:

  • RCTL CLI
  • Swagger API
  • The Terraform Provider

Tags

Important

Support for doing this through UI will be added in a future release

Step1: Tag Group

Here you have the details on how to create, update, delete and get a tag group

Create Tag Group

Use the below v3 Spec to create a Tag Group

apiVersion: tags.k8smgmt.io/v3
kind: TagGroup
metadata:
  name: <string>
  project: <project-name>
spec:
  tags:
  - key: <string>
    value: <string>
  - key: <string>
    value: <string>

Example:

apiVersion: tags.k8smgmt.io/v3
kind: TagGroup
metadata:
  name: demo-taggroup
  project: default-project
spec:
  tags:
  - key: Orgname
    value: Org1
  - key: place
    value: onprem

Run the below command to create a tag group:

./rctl apply -f <taggroup_filename.yaml>

Update Tag Group

Update the existing parameter(s) or add new key-value pairs in the config file and run the apply command. For example, in the below config file, add a new key-value pair as highlighted.

Example

apiVersion: tags.k8smgmt.io/v3
kind: TagGroup
metadata:
  name: demo-taggroup
  project: default-project
spec:
  tags:
  - key: Orgname
    value: Org1
  - key: place
    value: onprem
  - key: user
    value: tim_1  

To apply the changes, run the below command

./rctl apply -f <taggroup_filename.yaml>

Get Tag Group

Use the below command to view the list of all tag groups

./rctl get taggroup
┌────────────────┬────────────────────────┐
│ TAG-GROUP NAME │        TAGS            |
│                ├────────────┬───────────┤   
│                │ TAG-KEY    │ TAG-VALUE │   
├────────────────┼────────────┼───────────┤
│ tg-qctest      │ key-test1  │ value-1   │  
│                ├────────────┼───────────┤   
│                │ key-test2  │ value-2   │      
└────────────────┴────────────┴───────────┘
│  tg-demo       │ key-test10 │ value-10  │
│                ├────────────┼───────────┤  
│                │ key-test20 │ value-20  │   
└────────────────┴────────────┴───────────┘

Use the below command to view a specific tag group details

./rctl get taggroup <taggroup_name>

Example

./rctl get taggroup tg-qctest
┌────────────────┬────────────────────────┐
│ TAG-GROUP NAME │        TAGS            |
│                ├────────────┬───────────┤   
│                │ TAG-KEY    │ TAG-VALUE │   
├────────────────┼────────────┼───────────┤
│ tg-qctest      │ key-test1  │ value-1   │  
│                ├────────────┼───────────┤   
│                │ key-test2  │ value-2   │      
└────────────────┴────────────┴───────────┘

To view a tag group config spec, use the below command

./rctl get taggroup demo-taggroup -o yaml  
apiVersion: tags.k8smgmt.io/v3
kind: TagGroup
metadata:
 name: demo-taggroup
 project: defaultproject
spec:
 tags:
 - key: key-test1
  value: value-1
 - key: key-test2
  value: value-2

Delete Tag Group

Use the below command to delete a specific tag group

./rctl delete taggroup <taggroup_name>

Use the below command to delete all the tag groups

./rctl delete taggroup

A set of comprehensive APIs are available that enable the users to seamlessly create, update, retrieve a list, and delete tag groups. The Tag Group Apply API allows you to easily create new tag groups by providing the project id and resource name

Projects Intro


Step 2: Project Tag Association

The below section captures details on how to create, update, delete and get tag group associations.

Once the Tag group is created, use the below v3 Spec for project tag association.

apiVersion: tags.k8smgmt.io/v3
kind: ProjectTagsAssociation
metadata:
  name: <string>
  project: <project-name>
spec:
  associations:
  - tagKey: <string>
    tagType: cost
  - tagKey: <string>
    tagType: cost

Important

The only supported tag type currently is cost.

Example

apiVersion: tags.k8smgmt.io/v3
kind: ProjectTagsAssociation
metadata:
  name: demo-projecttag
  project: default-project
spec:
  associations:
  - tagKey: orgname
    tagType: cost
  - tagKey: place
    tagType: cost

Run the below command for the project tag association.

./rctl apply -f <projtagassoc-filename.yaml>

On completing this association process, a schema for project association gets created in the database. Now the users can get the project scoped Tag Group with it’s key-value pairs configured.

Update Tag Association

Update the existing parameter(s) in the config file and run the apply command. For example, in the below config file, modify the tagKey and tagType as highlighted

Example

apiVersion: tags.k8smgmt.io/v3
kind: ProjectTagsAssociation
metadata:
  name: demo-projecttag
  project: default-project
spec:
  associations:
  - tagKey: orgname1
    tagType: cost

To apply the changes, run the below command

./rctl apply -f <projtagassoc-filename.yaml>

Get Project Tag Association

Use the below command to view the list of all Project Tag Associations.

./rctl get projtagassoc
┌───────────────────────────────┬──────────────────────────────┐
│  PROJECT-TAG-ASSOCIATION NAME │     TAGS-ASSOC               |
│                               ├────────────┬─────────────────┤   
│                               │ TAG-KEY    │ TAG-ASSOC-TYPE  │   
├───────────────────────────────┼────────────┼─────────────────┤
│ qc-projassoc                  │ key-test1  │ cost            │   
└───────────────────────────────┴────────────┴─────────────────┘
│ demo-projassoc                │ key-test3  │ cost            |    
└───────────────────────────────┴────────────┴─────────────────┘

Use the below command to view a specific project tag association details.

./rctl get projtagassoc <tagassoc_name>

Example

./rctl get projtagassoc qc-projassoc
┌───────────────────────────────┬──────────────────────────────┐
│  PROJECT-TAG-ASSOCIATION NAME │     TAGS-ASSOC               |
│                               ├────────────┬─────────────────┤   
│                               │ TAG-KEY    │ TAG-ASSOC-TYPE  │   
├───────────────────────────────┼────────────┼─────────────────┤
│ qc-projassoc                  │ key-test1  │ cost            │                
└───────────────────────────────┴────────────┴─────────────────┘

To view a project tag association config spec, use the below command

./rctl get projtagassoc qc-projassoc -o yaml
apiVersion: tags.k8smgmt.io/v3
kind: ProjectTagsAssociation
metadata:
  name: qc-projassoc
  project: defaultproject
spec:
  associations:
  - tagKey: key-test1
    tagType: cost

Delete Project Tag Association

Use the below command to delete a specific project tag association

./rctl delete projtagassoc <projtagassoc_name>

Use the below command to delete all the project tag association

./rctl delete projtagassoc

A set of comprehensive APIs are available that enable the users to seamlessly create, update, retrieve a list, and delete project tag association. The ProjectTagAssociation API allows you to easily create new tag association by providing the project id and resource name

Projects Intro