General Purpose Tagging Guide

Use entity tags, Spinnaker’s provider-agnostic tagging capability.

This guide provides an introduction to the provider-agnostic tagging capabilities of Spinnaker, otherwise referred to as Entity Tags.

Requirements

This is an optional feature of Spinnaker that requires

  • Elasticsearch (tested with 6.8.2)
  • Front50 (backed by SQL, S3 or GCS)

See configuration for specific configuration details.

Overview

Spinnaker provides a provider-agnostic way of attaching additional attributes (key/value pairs) to any managed entity.

Managed Entities

Any object that is maintained (or visualized) by Spinnaker.

Includes (but is not limited to):

  • Applications
  • Server Groups
  • Load Balancers
  • Instances
  • Clusters

There are no restrictions on the size or quantity of these tags (unlike limitations imposed by native cloud provider tags).

Current limitations

  • Completely separate from any tag support on the underlying cloud provider
    • Callers must make an additional API call to retrieve entity tags
  • Limited lifecycle support
    • Only server groups have a delete hook that will cleanup associated tags

These limitations will be addressed on an as needed basis.

If they are blocking a particular use-case, please file an issue .

Common use cases

  • Server Group Alerts and Notices
  • Server Group Attribution (what pipeline / user created this server group)
  • Security (restricting when particular IAM roles can be used)

Tag namespaces

All tags have an associated namespace (default will be used if unspecified) that provides a means of grouping tags by a logical owner.

Tag names can be re-used across namespaces.

Eventually Spinnaker will allow permissions to be defined per-namespace (ie. certain namespaces can only be modified by particular users or groups).

Implementation details

These provider-agnostic tags are stored in S3 or GCS (via Front50) and indexed via Elasticsearch.

They are made up of:

  • An Identifier
  • An EntityRef
  • 1..* Tags (key/value pairs with the value being either a literal or object)
  • 1..* Tag Metadata (*last modified timestamps per tag*)

Identifier

A unique identifier representing a tagged entity: {cloudProvider}:{entityType}:{entityId}:{accountId}:{region}

EntityRef

cloudProvider The identifier of the cloud provider associated with this entity accountId The identifier of the account associated with this entity (supports * wildcard) region The identifier of the region associated with this entity (supports * wildcard) entityType The type of entity being tagged entityId The identifier of the entity being tagged application The identifier of the application associated with this entity

Supported Entity Types

Spinnaker has native support for the following:

  • application
  • servergroup
  • iamrole

tags structure

  1. {
  2. "id": "aws:servergroup:myservergroup-v001:100000000001:us-west-2",
  3. "tags": [
  4. {
  5. "name": "spinnaker_ui_alert:autoscaling:ec2_instance_launch_error",
  6. "namespace": "my_namespace",
  7. "value": {
  8. "message": "Insufficient capacity. Launching EC2 instance failed.",
  9. "type": "alert"
  10. },
  11. "valueType": "object"
  12. }
  13. ],
  14. "tagsMetadata": [
  15. {
  16. "name": "spinnaker_ui_alert:autoscaling:ec2_instance_launch_error",
  17. "lastModified": 1484162291500,
  18. "lastModifiedBy": "unknown",
  19. "created": 1484161809699,
  20. "createdBy": "unknown"
  21. }
  22. ],
  23. "entityRef": {
  24. "cloudProvider": "aws",
  25. "accountId": "100000000001",
  26. "region": "us-west-2",
  27. "entityType": "servergroup",
  28. "entityId": "myservergroup-v001",
  29. "application": "app"
  30. }
  31. }

API

The following APIs are exposed in gate but are subject to change given the current release candidate status.

GET /tags

Fetch all tags. Parameters are case-sensitive.

Parameter NameDescriptionExamples
entityTypeFilter by Entity Type?entityType=servergroup
entityIdFilter by Entity Id?entityId=myservergroup-v001
applicationFilter by Application?application=app
tagFilter by Tag (specific value)
Filter by Tag (any value)
?tag:my_tag=my_value
?tag:my_tag=*
maxResultsMaximum # of results to return (defaults to 100)?maxResults=1000

POST /tags

Parameter NameDescriptionExamples
entityTypeEntity Type?entityType=servergroup
entityIdEntity Id?entityId=myservergroup-v001
applicationapplication?application=app
accountAccount Name?account=production
?account= (wildcard)
regionRegion?region=us-west-2
?region= (wildcard)
cloudProvidercloudProvider?cloudProvider=aws
?cloudProvider=* (wildcard)

Upsert tags

  1. curl -X "POST" "http://gate/tags?entityId=myservergroup-v001&entityType=servergroup&account=production&region=us-west-2&cloudProvider=aws&application=app" \
  2. -H "Content-Type: application/json" \
  3. -d $'[
  4. {
  5. "name": "spinnaker_ui_alert:autoscaling:ec2_instance_launch_error",
  6. "namespace": "my_namespace",
  7. "value": {
  8. "message": "Insufficient capacity. Launching EC2 instance failed.",
  9. "type": "alert"
  10. },
  11. "valueType": "object"
  12. }
  13. ]'

POST /tasks

This API provides backwards compatibility with traditional Spinnaker tasks and can be used interchangeably with the POST /tags API.

Upsert tags

  1. curl -X "POST" "http://gate/tasks" \
  2. -H "Content-Type: application/json" \
  3. -d $'{
  4. "application": "spinnaker",
  5. "job": [
  6. {
  7. "type": "upsertEntityTags",
  8. "tags": [
  9. {
  10. "name": "spinnaker_ui_alert:autoscaling:ec2_instance_launch_error",
  11. "namespace": "my_namespace",
  12. "value": {
  13. "message": "Insufficient capacity. Launching EC2 instance failed.",
  14. "type": "alert"
  15. },
  16. "valueType": "object"
  17. }
  18. ],
  19. "entityRef": {
  20. "cloudProvider": "aws",
  21. "entityType": "servergroup",
  22. "entityId": "myservergroup-v001",
  23. "region": "us-west-2",
  24. "account": "production",
  25. "application": "app"
  26. }
  27. }
  28. ],
  29. "description": "Updating tags"
  30. }'

DELETE /tags/:id/:tagName

Delete tags

  1. curl -X "DELETE" "http://gate/tags/myservergroup-v001:100000000001:us-west-2/spinnaker_ui_alert:autoscaling:ec2_instance_launch_error" \
  2. -H "Content-Type: application/json" \
  3. -d $'{}'

FEATURE: Server group alerts and notices

Server Group Alerts and Notices is a Spinnaker feature is built upon entity tags.

General Purpose Tagging Guide - 图1

Add alert

  1. curl -X "POST" "http://gate/tags?entityId=spintest-v003&entityType=servergroup&account=test&region=us-west-2&cloudProvider=aws&application=app" \
  2. -H "Content-Type: application/json" \
  3. -d $'[
  4. {
  5. "name": "spinnaker_ui_alert:autoscaling:ec2_instance_launch_error",
  6. "namespace": "my_namespace",
  7. "value": {
  8. "message": "You have exceeded the number of VPC security groups allowed per instance. Launching EC2 instance failed.",
  9. "type": "alert"
  10. },
  11. "valueType": "object"
  12. }
  13. ]'

Add notice

  1. curl -X "POST" "http://gate/tags?entityId=spintest-v003&entityType=servergroup&account=test&region=us-west-2&cloudProvider=aws&application=app" \
  2. -H "Content-Type: application/json" \
  3. -d $'[
  4. {
  5. "name": "spinnaker_ui_notice:my_favorite_notice",
  6. "namespace": "my_namespace",
  7. "value": {
  8. "message": "This is an example notice!",
  9. "type": "notice"
  10. },
  11. "valueType": "object"
  12. }
  13. ]'

Delete alert (or notice)

  1. curl -X "DELETE" "http://gate/tags/aws:servergroup:spintest-v003:100000000001:us-west-2/spinnaker_ui_alert:autoscaling:ec2_instance_launch_error" \
  2. -H "Content-Type: application/json" \
  3. -d $'{}'

Configuration

The following configuration changes are necessary to enable entity tags on your Spinnaker installation:

clouddriver-local.yml

  1. elasticSearch:
  2. activeIndex: "tags_v2"
  3. connection: http://my-elastic-search-cluster:port

deck/settings-local.js

  1. window.spinnakerSettings.entityTags = {};
  2. window.spinnakerSettings.feature.entityTags=true;

elasticsearch index template

Make a POST request to http://my-elastic-search-cluster:port/_template with this template template


Last modified May 13, 2021: docs(migrate): add remaining Extending Spinnaker pages (3835a79)