Step 3 of the 12 Factor app is to store config in the environment. For Keystone, the set of configuration options is controlled by the keystone.conf file. In an earlier attempt at containerizing the scripts used to configure Keystone, I had passed an environment variable in to the script that would then be written to the configuration file. I realize now that I want the whole keystone.conf external to the application. This allow me to set any of the configuration options without changing the code in the container. More importantly, it allows me to make the configuration information immutable inside the container, so that the applications cannot be hacked to change their own configuration options.
I was running the pod and mounting the local copy I had of the keystone.conf file using this command line:
podman run --mount type=bind,source=/home/ayoung/devel/container-keystone/keystone-db-init/keystone.conf,destination=/etc/keystone/keystone.conf:Z --add-host keystone-mariadb:10.89.0.47 --network maria-bridge -it localhost/keystone-db-init
It was returning with no output. To diagnose, I added on /bin/bash to the end of the command so I could poke around inside the running container before it exited.
podman run --mount /home/ayoung/devel/container-keystone/keystone-db-init/keystone.conf:/etc/keystone/keystone.conf --add-host keystone-mariadb:10.89.0.47 --network maria-bridge -it localhost/keystone-db-init /bin/bash
Once inside, I was able to look at the keystone log file. A Stack trasce made me realize that I was not able to actually read the file /etc/keystone/keystone.conf. Using ls I would show up like this:
-?????????? ? ? ? ? ? keystone.conf:
It took a lot of trial and error to recitify it including:
- adding a parallel entry to my hosts /etc/password and /etc/groups file for the keystone user and group
- Ensuring that the file was owned by keystone outside the container
- switching to the -v option to create the bind mount, as that allowed me to use the :Z option as well.
- addingthe -u keystone option to the command line
The end command looked like this:
podman run -v /home/ayoung/devel/container-keystone/keystone-db-init/keystone.conf:/etc/keystone/keystone.conf:Z -u keystone --add-host keystone-mariadb:10.89.0.47 --network maria-bridge -it localhost/keystone-db-init
Once I had it correct, I could use the /bin/bash executable to again poke around inside the container. From the inside, I could run:
$ keystone-manage db_version 109 $ mysql -h keystone-mariadb -ukeystone -pkeystone keystone -e "show databases;" +--------------------+ | Database | +--------------------+ | information_schema | | keystone | +--------------------+
Next up is to try this with OpenShift.