added information about using env refs with templates
parent
3e9a55133a
commit
ce4e57700d
|
@ -111,6 +111,70 @@ influx pkg export all \
|
|||
--telegraf-configs=00000x0x000X0x0X0
|
||||
```
|
||||
|
||||
## Include user-definable resource names
|
||||
To let users customize resource names when installing your template, use
|
||||
**environment references** in place of names.
|
||||
Environment references are replaced with user-defined values when the template is installed.
|
||||
|
||||
In your template manifest, replace a [supported resource field](#supported-resource-fields)
|
||||
with an `envRef` object.
|
||||
A `envRef` object contains a single `key` property.
|
||||
`key` is a string that references a user-defined environment reference key.
|
||||
|
||||
{{< code-tabs-wrapper >}}
|
||||
{{% code-tabs %}}
|
||||
[YAML](#)
|
||||
[JSON](#)
|
||||
{{% /code-tabs %}}
|
||||
{{% code-tab-content %}}
|
||||
```yml
|
||||
apiVersion: influxdata.com/v2alpha1
|
||||
kind: Bucket
|
||||
metadata:
|
||||
name:
|
||||
envRef:
|
||||
key: bucket-name-1
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{% code-tab-content %}}
|
||||
```json
|
||||
{
|
||||
"apiVersion": "influxdata.com/v2alpha1",
|
||||
"kind": "Bucket",
|
||||
"metadata": {
|
||||
"name": {
|
||||
"envRef": {
|
||||
"key": "bucket-name-1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
{{% /code-tab-content %}}
|
||||
{{< /code-tabs-wrapper >}}
|
||||
|
||||
Using the example above, users would include `--env-ref=bucket-name-1=myBucket`
|
||||
when [installing the template](/v2.0/influxdb-templates/use/#install-templates) to
|
||||
set the bucket name to "myBucket".
|
||||
|
||||
```sh
|
||||
influx pkg \
|
||||
-f /path/to/template.yml \
|
||||
--env-ref=bucket-name-1=myBucket
|
||||
```
|
||||
|
||||
If the user does not provide the environment reference key-value pair, InfluxDB
|
||||
uses the `key` string as the default value.
|
||||
|
||||
{{% note %}}
|
||||
#### Supported resource fields
|
||||
Only the following fields support environment references:
|
||||
|
||||
- `metadata.name`
|
||||
- `associations[].name`
|
||||
- `endpointName`
|
||||
{{% /note %}}
|
||||
|
||||
## Share your InfluxDB templates
|
||||
Share your InfluxDB templates with the entire InfluxData community.
|
||||
**Contribute your template to the [InfluxDB Community Templates](https://github.com/influxdata/community-templates/)
|
||||
|
|
|
@ -87,6 +87,7 @@ from your local filesystem or from URLs.
|
|||
- [Install all templates in a directory](#install-all-templates-in-a-directory)
|
||||
- [Install a template from a URL](#install-a-template-from-a-url)
|
||||
- [Install templates from both files and URLs](#install-templates-from-both-files-and-urls)
|
||||
- [Define environment references](#define-environment-references)
|
||||
- [Include a secret when installing a template](#include-a-secret-when-installing-a-template)
|
||||
|
||||
### Install a template from a file
|
||||
|
@ -161,6 +162,21 @@ influx pkg \
|
|||
--recurse
|
||||
```
|
||||
|
||||
### Define environment references
|
||||
Some templates include [environment references](/v2.0/influxdb-templates/create/#include-user-definable-resource-names) that let you provide custom names for resources in the template.
|
||||
Template maintainers should document what environment references exist in the template
|
||||
and what keys to use to replace them.
|
||||
|
||||
To provide values for environment references, include an `--env-ref` flag with
|
||||
the environment reference key and the value to replace it.
|
||||
|
||||
```sh
|
||||
influx pkg -f /path/to/template.yml \
|
||||
--env-ref=bucket-name-1=myBucket
|
||||
--env-ref=label-name-1=Label1 \
|
||||
--env-ref=label-name-2=Label2
|
||||
```
|
||||
|
||||
### Include a secret when installing a template
|
||||
Some templates use [secrets](/v2.0/security/secrets/) in queries.
|
||||
Secret values are not included in templates.
|
||||
|
|
Loading…
Reference in New Issue