Sha256: 833ac8dc23930e0c397750ec4cc4dde3a1f518e74ef8e980869b1432461c9dad

Contents?: true

Size: 1.54 KB

Versions: 35

Compression:

Stored size: 1.54 KB

Contents

---
title: Secret
categories: dsl
---

## Example

Here's an example of a Secret.

.kubes/resources/shared/secret.rb

```ruby
name "demo-secret"
data(
  username: base64("user"),
  password: base64("pass"),
)
```

Produces:

.kubes/output/shared/secret.yaml

```yaml
apiVersion: v1
kind: Secret
metadata:
  name: demo-secret-cfbd534f91
  labels:
    app: demo
  namespace: default
data:
  username: dXNlcg==
  password: cGFzcw==
```

## Suffix Hash

{% include dsl/rolling_deployment.md kind="Secret" %}

.kubes/resources/web/deployment.yaml:

```yaml
# ..
spec:
  template:
    spec:
      containers:
      - name: demo
        image: nginx
        envFrom:
        - secretRef:
            name: demo-secret
```

Produces:

.kubes/output/web/deployment.yaml:

```yaml
# ..
spec:
  template:
    spec:
      containers:
      - name: demo
        image: nginx
        envFrom:
        - secretRef:
            name: demo-secret-cfbd534f91
```

{% include dsl/suffix_hash.md %}

## Files Helper

You can use a `files` helper to load secrets values from one or more files.


.kubes/resources/shared/secret.rb

```ruby
name "demo-secret"
files("files/secrets.txt")
```

The `files/secrets.txt` should be in the same folder as the `secret.rb` definition.  Example:

.kubes/resources/shared/files/secret.txt

    SECRET1=value1
    SECRET2=value2

You do not have to worry about base64 encoding the values. Kubes automatically base64 encodes the values.

## DSL Methods

Here's a list of more common methods:

* data
* stringData
* type

{% include dsl/methods.md name="secret" %}

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
kubes-0.9.3 docs/_docs/dsl/resources/secret.md
kubes-0.9.2 docs/_docs/dsl/resources/secret.md
kubes-0.9.1 docs/_docs/dsl/resources/secret.md
kubes-0.9.0 docs/_docs/dsl/resources/secret.md
kubes-0.8.10 docs/_docs/dsl/resources/secret.md
kubes-0.8.9 docs/_docs/dsl/resources/secret.md
kubes-0.8.8 docs/_docs/dsl/resources/secret.md
kubes-0.8.7 docs/_docs/dsl/resources/secret.md
kubes-0.8.6 docs/_docs/dsl/resources/secret.md
kubes-0.8.5 docs/_docs/dsl/resources/secret.md
kubes-0.8.4 docs/_docs/dsl/resources/secret.md
kubes-0.8.3 docs/_docs/dsl/resources/secret.md
kubes-0.8.2 docs/_docs/dsl/resources/secret.md
kubes-0.8.1 docs/_docs/dsl/resources/secret.md
kubes-0.8.0 docs/_docs/dsl/resources/secret.md
kubes-0.7.10 docs/_docs/dsl/resources/secret.md
kubes-0.7.9 docs/_docs/dsl/resources/secret.md
kubes-0.7.8 docs/_docs/dsl/resources/secret.md
kubes-0.7.7 docs/_docs/dsl/resources/secret.md
kubes-0.7.6 docs/_docs/dsl/resources/secret.md