website: clarify that downward API works in any pod spec

pull/4733/head
Mitchell Hashimoto 2018-10-01 10:35:09 -07:00
parent 99c51c9f86
commit bd6ec230c3
No known key found for this signature in database
GPG Key ID: A3A9A8F4F25C3E56
1 changed files with 38 additions and 1 deletions

View File

@ -130,7 +130,10 @@ For Consul installed via the Helm chart, a client agent is installed on
each Kubernetes node. This is explained in the [architecture](/docs/platform/k8s/run.html#client-agents)
section. To access the agent, you may use the
[downward API](https://kubernetes.io/docs/tasks/inject-data-application/downward-api-volume-expose-pod-information/).
An example pod specification is shown below:
An example pod specification is shown below. In addition to pods, anything
with a pod template can also access the downward API and can therefore also
access Consul: StatefulSets, Deployments, Jobs, etc.
```yaml
apiVersion: v1
@ -155,6 +158,40 @@ spec:
restartPolicy: Never
```
An example `Deployment` is also shown below to show how the host IP can
be accessed from nested pod specifications:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: consul-example-deployment
spec:
replicas: 1
selector:
matchLabels:
app: consul-example
template:
metadata:
labels:
app: consul-example
spec:
containers:
- name: example
image: "consul:latest"
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
command:
- "/bin/sh"
- "-ec"
- |
export CONSUL_HTTP_ADDR="${HOST_IP}:8500"
consul kv put hello world
```
### Upgrading Consul on Kubernetes
To upgrade Consul on Kubernetes, we follow the same pattern as