Skip to content

Commit 4103b9d

Browse files
committed
chore(EnvVar Configuration): Updated documentation.
1 parent 7dfe07c commit 4103b9d

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ link:structural/Ambassador/README.adoc[Ambassador]::
6363
=== Configuration Patterns
6464

6565
link:configuration/EnvVarConfiguration/README.adoc[EnvVar Configuration]::
66-
A simple example of how to use environment variables literally and from ConfigMaps and Secrets for our random-generator service. [*]
66+
A simple example of how to use environment variables literally and from ConfigMaps and Secrets for our random-generator service.
6767
link:configuration/ConfigurationResource/README.adoc[Configuration Resource]::
6868
Example how to configure the random-generator Spring Boot application with a ConfigMap [*]
6969
link:configuration/ImmutableConfiguration/README.adoc[Immutable Configuration]::

configuration/EnvVarConfiguration/README.adoc

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11
== Envvar Configuration
22

3-
IMPORTANT: The instructions have not been written/finished, but the resource file has been verified. Instructions will be added soon.
3+
This example assumes that you have a Kubernetes cluster to your avail.
4+
Please check link:../../INSTALL.adoc#minikube[INSTALL] for various installation options.
5+
6+
First, lets create a ConfigMap and a Secert with one entry, respecively:
47

58
[source, bash]
69
----
710
kubectl create configmap random-generator-config --from-literal=pattern=EnvVarConfiguration
811
912
kubectl create secret generic random-generator-secret --from-literal=seed=11232156346
13+
----
1014

15+
We use both resource for defining environment variable in a simple Pod declaration for our sample https://github.com/k8spatterns/random-generator[random-generator REST service]:
1116

12-
kubectl create -f pod.yml
17+
[source, bash]
18+
----
19+
kubectl create -f https://k8spatterns.io/EnvVarConfiguration/pod.yml
20+
----
1321

14-
kubectl create -f service.yml
22+
If you look into this resource description, you see how our ConfigMap and Secret is used to set two environment variables `PATTERN` and `SEED` which are then also exposed via the random-generator rest service.
1523

24+
In order to access this rest service let's expose the Pod via
1625

26+
[source, bash]
27+
----
28+
kubectl create -f https://k8spatterns.io/EnvVarConfiguration/service.yml
29+
----
30+
31+
For simplicity reasons, this service exposed the service port via a `nodePort`.
32+
Assuming, that your are using Minikube you can now access this service from your dekstop with:
33+
34+
[source, bash]
35+
----
1736
port=$(kubectl get svc random-generator -o jsonpath={.spec.ports[0].nodePort})
1837
curl -s http://$(minikube ip):$port/info | jq .
19-
20-
{
21-
"memory.free": 24,
22-
"seed": 11232156346,
23-
"memory.used": 46,
24-
"cpu.procs": 1,
25-
"memory.max": 481,
26-
"logFile": "/tmp/random.log",
27-
"pattern": "EnvVarConfiguration",
28-
"id": "b5942022-5925-4672-9c26-8cf255b5ccf0",
29-
"version": "1.0"
30-
}
3138
----
3239

40+
If you are not using Minikube, just insert the external facing IP address of one of your cluster's node for the host address.
3341

42+
* Do you se, how the environment variables are exposed ?
43+
* What happens when you change the data of the ConfigMap or Secret (e.g. with `kubectl edit cm random-generator-config`) ? Is this changed value reflected in the response of your curl request /
44+
* What would you have to do, to get this value returned in the HTTP response ?
3445
3546
=== More Information
3647

0 commit comments

Comments
 (0)