ConfigMaps allows you to separate configuration artifacts from image content to maintain the portability of containerized applications. Configmap can be created from file, directory or key string creation. You can also create it from a description file through kubectl create -f f f. There are four ways to create a configuration map:
Created from key-value strings, the official translation is to create ConfigMap from literal values.
syntax rule
situation
When using kubectl get to obtain resource information, you can specify the format of information output by -o (short for output). If yaml or json is specified, the complete information of the resource will be output. In practical work, if the output content is too small, we can't get the information we want, and the output content is too detailed, which is not conducive to rapid positioning. In fact, the output format of -o can be specified as go-template and then a template, so that we can get what we want through go-template. Go-template has nothing to do with kubernetes, it is a template engine built in go language. Go-template is not explained here, only the common syntax for obtaining resources in kubernetes is introduced. For more information, please refer to relevant materials for help. Remember, just change the grammar.
Create a configuration file
The syntax rules are as follows: when-from-file points to a directory, the key in ConfigMap is directly filled with files in each directory, the name of the key is the file name, and the value of the value is the content of this file. The following command reads all files in the /data directory.
ku bectl create config map cumulx-test-from-file =/data/
ku bectl create config map myjdbcconfigmap-from-file =/data/JDBC . properties
View configuration diagram details
Kubectl describes the configuration map myjdbcmap.
data/mariadbconfigmap.yml
configmap/mariadbsecret.yml
Configmap/mariadb。 Yml- It needs to be rearranged, and the mirror image information should be added.
Note that the port number of pod is changed to 3307, and the port number of target service is 3307.