• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Waypoint
  • Install
  • Tutorials
  • Documentation
  • CLI
  • Plugins
  • Try Cloud(opens in new tab)
  • Sign up
Waypoint Home

Documentation

Skip to main content
  • Documentation
  • Getting Started


    • Overview
      • Overview
      • Input Variables
      • External Data
      • artifact
      • deploy
      • entrypoint
      • labels
      • path
      • workspace
    • app
    • build
    • config
    • deploy
    • hook
    • plugin
    • registry
    • release
    • runner
    • url
    • use
    • variable
  • URL Service
  • Logs
  • Exec
  • Workspaces
  • Plugins
  • Triggers

  • Troubleshooting
  • Glossary

  • Roadmap

  • Resources

  • Tutorial Library
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  1. Developer
  2. Waypoint
  3. Documentation
  4. waypoint.hcl
  5. Variables
  6. labels
  • Waypoint
  • v0.9.x
  • v0.8.x
  • v0.7.x
  • v0.6.x
  • v0.5.x
  • v0.4.x
  • v0.3.x
  • v0.2.x
  • v0.1.x

ยปlabels Variable

Placementapp -> build
app -> deploy
app -> release

The labels variable is a map of the full set of labels that are set for the current operation.

Example: Kubernetes Annotations

The example below shows how we can set annotations on a Kubernetes deployment to mirror the Waypoint labels we have set.

app "web" {
  deploy {
    use "kubernetes" {
      annotations = { for k, v in labels: "waypoint/${k}" => v }
    }
  }
}

This examples goes a bit further and uses HCL map expressions to prefix all our labels with "waypoint/" to note they come from Waypoint. If you wanted to just map the labels directly, you can do annotations = labels directly.

Example: Conditional on Labels

The example below shows how we can use the selectormatch function to perform conditional logic with labels. The selector-prefixed functions all use the common label selector syntax that is used throughout various features in Waypoint.

app "web" {
  deploy {
    use "kubernetes" {
      image_secret = selectormatch(labels, "env == production") ?
        "ProdSecret" : "DevSecret"
    }
  }
}

This could also be done with selectorlookup which allows mapping matching selector expressions to specific values:

app "web" {
  deploy {
    use "kubernetes" {
      image_secret = selectorlookup(labels, {
        "env == production" = "ProdSecret"
      }, "DevSecret")
    }
  }
}
Edit this page on GitHub
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)