Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow cassandra to be configured via config map on K8s #129

Closed
wants to merge 1 commit into from
Closed

Conversation

abinet
Copy link

@abinet abinet commented Jan 2, 2018

We use cassandra images on K8s and need some additional configuration changes in cassandra.yaml file.
It is standard approach on K8s to use config map for this purpose which has all the configuration settings and being mounted into the pod.

But in case when docker-entrypoint.sh changes cassandra.yaml during startup replacing some values with the environment variables mounting cannot be used.

The idea is to use the mounted file as a template and let docker-entrypoint.sh to change the copy of the original configuration stored in CASSANDRA_CONFIG_TEMPLATE_FOLDER/cassandra.yaml. When CASSANDRA_CONFIG_TEMPLATE_FOLDER is not set, script uses the old behavior and modifies configuration directly.

So I can share original configuration to multiple containers:

docker run -d -e CASSANDRA_NUM_TOKENS=100 -e CASSANDRA_CLUSTER_NAME=mycluster -e CASSANDRA_CONFIG_TEMPLATE_FOLDER=/templates -v ${PWD}/cassandra.yaml:/templates/cassandra.yaml:ro cassandra

docker run -d -e CASSANDRA_NUM_TOKENS=100 -e CASSANDRA_CLUSTER_NAME=mycluster -e CASSANDRA_CONFIG_TEMPLATE_FOLDER=/templates -v ${PWD}/cassandra.yaml:/templates/cassandra.yaml:ro cassandra

...
docker run -d -e CASSANDRA_NUM_TOKENS=100 -e CASSANDRA_CLUSTER_NAME=mycluster -e CASSANDRA_CONFIG_TEMPLATE_FOLDER=/templates -v ${PWD}/cassandra.yaml:/templates/cassandra.yaml:ro cassandra

…o allow cassandra configuration via config map
@abinet
Copy link
Author

abinet commented Jan 2, 2018

This PR addresses the issues like:

#58
#110

@yosifkit
Copy link
Member

yosifkit commented Jan 3, 2018

Why is this required over doing it on the command line with a shell script?

$ docker run -d -e CASSANDRA_NUM_TOKENS=100 -e CASSANDRA_CLUSTER_NAME=mycluster -v ${PWD}/cassandra.yaml:/templates/cassandra.yaml:ro cassandra sh -c 'cp /templates/cassandra.yaml $CASSANDRA_CONFIG/cassandra.yaml && exec /docker-entrypoint.sh cassandra -f'

@abinet
Copy link
Author

abinet commented Jan 3, 2018

Sure, you can do this via command line
My solution just provides a shortcut for a very common use case.

@tianon
Copy link
Member

tianon commented Oct 3, 2018

I'm sorry, but honestly if we're going to do anything more with environment variables it would likely be in the opposite direction (which we won't do due to the backwards compatibility implications) -- modifying a YAML file via shell script is very fragile, and setting complex configuration in this way is not great. For custom configuration, the only/best recommendation is to provide an appropriate cassandra.yaml file to your running instance (via a new image with FROM / COPY in a short Dockerfile, via Docker Configs, via bind mount, etc).

Closing in favor of #160 + docker-library/docs#1317.

@tianon tianon closed this Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants