docs: Decode K8s secrets with base64decode function

Use kubectl's base64decode template function (added in K8s 1.11) to
decode values in Secrets. Removes external call to `base64` utility on
the host system.
This commit is contained in:
Blake Covarrubias 2021-09-23 18:47:40 -07:00 committed by Blake Covarrubias
parent eb00b45ef4
commit 94d3849472
4 changed files with 5 additions and 7 deletions

View File

@ -73,7 +73,7 @@ $ export CONSUL_HTTP_SSL_VERIFY=false
If ACLs are enabled also set: If ACLs are enabled also set:
```shell-session ```shell-session
$ export CONSUL_HTTP_TOKEN=$(kubectl get secret consul-bootstrap-acl-token -o jsonpath={.data.token} | base64 --decode) $ export CONSUL_HTTP_TOKEN=$(kubectl get secret consul-bootstrap-acl-token --template='{{.data.token | base64decode }}')
``` ```
## Register external services with Consul ## Register external services with Consul

View File

@ -113,7 +113,7 @@ Then you have likely enabled ACLs. You need to specify your ACL token when
running the `license get` command. First, assign the ACL token to the `CONSUL_HTTP_TOKEN` environment variable: running the `license get` command. First, assign the ACL token to the `CONSUL_HTTP_TOKEN` environment variable:
```shell-session ```shell-session
$ export CONSUL_HTTP_TOKEN=$(kubectl get secrets/hashicorp-consul-bootstrap-acl-token --template={{.data.token}} | base64 --decode) $ export CONSUL_HTTP_TOKEN=$(kubectl get secrets/hashicorp-consul-bootstrap-acl-token --template='{{.data.token | base64decode }}')
``` ```
Now the token will be used when running Consul commands: Now the token will be used when running Consul commands:

View File

@ -197,7 +197,7 @@ to see all resources and make modifications.
To retrieve the bootstrap token that has full permissions, run: To retrieve the bootstrap token that has full permissions, run:
```shell-session ```shell-session
$ kubectl get secrets/consul-bootstrap-acl-token --template={{.data.token}} | base64 --decode $ kubectl get secrets/consul-bootstrap-acl-token --template='{{.data.token | base64decode }}'
e7924dd1-dc3f-f644-da54-81a73ba0a178% e7924dd1-dc3f-f644-da54-81a73ba0a178%
``` ```

View File

@ -35,15 +35,13 @@ The following sections detail how to export this data.
1. Retrieve the certificate authority cert: 1. Retrieve the certificate authority cert:
```sh ```sh
kubectl get secrets/consul-ca-cert --template='{{index .data "tls.crt" }}' | kubectl get secrets/consul-ca-cert --template='{{index .data "tls.crt" | base64decode }}' > consul-agent-ca.pem
base64 --decode > consul-agent-ca.pem
``` ```
1. And the certificate authority signing key: 1. And the certificate authority signing key:
```sh ```sh
kubectl get secrets/consul-ca-key --template='{{index .data "tls.key" }}' | kubectl get secrets/consul-ca-key --template='{{index .data "tls.key" | base64decode }}' > consul-agent-ca-key.pem
base64 --decode > consul-agent-ca-key.pem
``` ```
1. With the `consul-agent-ca.pem` and `consul-agent-ca-key.pem` files you can 1. With the `consul-agent-ca.pem` and `consul-agent-ca-key.pem` files you can