You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/patterns.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -933,7 +933,7 @@ Passing configuration data through environment variables can be an option. Howev
933
933
### Configuration Templates
934
934
Config Maps and Secrets are a common way of passing configurations data to containerized applications. Sometimes, however, these configuration data are only available at the starting time and cannot be placed into static configuration maps or secrets. In such cases, configuration data can be placed into Configuration Templates and processed before the startup of the container, for example by a dedicated Init Container.
935
935
936
-
In the following example, we're going to create a distributed data store cluster based on Consul. This cluster, requires a minimum of three pods running a Consul server. The cluster is made when each server instance can connect togheter. For this example, we're going to use a Steful Set controller because this is the natural choiche of kuberentes to run distributed stateful applications.
936
+
In the following example, we're going to create a distributed data store cluster based on Consul. This cluster, requires a minimum of three pods running a Consul server. The cluster is made when each server instance can connect togheter. For this example, we're going to use a Steful Set controller because this is the natural choice run distributed stateful applications in kubernetes.
937
937
938
938
The configuration template we're using to setup the Consul cluster is the following ``consul.json`` file
939
939
@@ -952,7 +952,7 @@ The configuration template we're using to setup the Consul cluster is the follow
952
952
}
953
953
```
954
954
955
-
The template above contains the ``retry_join`` property. The value for this property must be the list of the three consul server names required to form the cluster. Unfortunately, these names are not known in advance, because they depend on the namespaces where the pods are running. For this reason, we put a placeholder ``consul.default.svc.cluster.local`` and use an init container to change the placeholder before the main consul container server starts.
955
+
The template above contains the ``retry_join`` property. The value for this property must be the list of all the three server names required to form the cluster. Unfortunately, these names are not known in advance, because they depend on the namespace where the pods are running. For this reason, we put a placeholder ``consul.default.svc.cluster.local`` and use an init container to change the placeholder with the real name before the main container starts.
956
956
957
957
The following snippet reports the init container and the main container
958
958
@@ -1000,14 +1000,14 @@ The following snippet reports the init container and the main container
1000
1000
...
1001
1001
```
1002
1002
1003
-
The init container implements a simple configuration template processor based on unix ``sed`` utility. In addition to the init and the main containers, this pod also defines two volumes: one volume for the configuration template, backed by a config map. The other volume is an empty shared volume which is used to share the processed templates between the init container and the main container.
1003
+
The init container implements a simple configuration template processor based on the Unix ``sed`` utility. In addition to the init and the main container, this pod also defines two volumes: one volume for the configuration template, backed by a config map. The other volume is an empty shared volume which is used to share the processed data between the init container and the main container.
1004
1004
1005
1005
With this setup, the following steps are performed during startup of this pod:
1006
1006
1007
1007
1. The init container starts and gathers the namespace from the API server
1008
1008
2. The init container reads the configuration template from mounted config map volume and runs the processor
1009
1009
3. The processor changes the placeholder with the real namespace and stores the result into the empty shared volume
1010
-
4. The init container exits after it has finished leaving the real configuration file into the shared volume
1010
+
4. The init container exits after it has finished leaving the real configuration into the shared volume
1011
1011
5. The main consul container starts and loads the configuration file from the shared volume
1012
1012
1013
1013
The complete example can be found [here](./stateful.md).
0 commit comments