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

Add ability to extend CASSANDRA_xxx style env configs #247

Closed
wants to merge 1 commit into from

Conversation

clintwood
Copy link

@clintwood clintwood commented Apr 7, 2022

This PR adds the ability to extend the limited set of CASSANDRA_xxx style env vars that update the cassandra.yaml via docker_entrypoint.sh

This is done by setting an env variable EXTEND_CONFIG with a space separated list of config keys that the docker_entrypoint.sh will add to it's limited list of keys to replace in cassandra.yaml.

One could add this to a docker-compose.yml e.g.:

    environment:
      # Extend the config to additionally use/recognise keys:
      #  enable_materialized_views
      #  enable_sasi_indexes
      #  enable_user_defined_functions
      - EXTEND_CONFIG=enable_materialized_views enable_sasi_indexes enable_user_defined_functions
      - CASSANDRA_CLUSTER_NAME=my-cluster
      # More known CASSANDRA_xxx config 
      - CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch
      # Extended CASSANDRA_xxx configs
      - CASSANDRA_ENABLE_MATERIALIZED_VIEWS=true
      - CASSANDRA_ENABLE_SASI_INDEXES=true
      - CASSANDRA_ENABLE_USER_DEFINED_FUNCTIONS=true
    networks:
    ...

The above would recognize the last 3 env variables and set these appropriately in the cassandra.yaml config file.

@yosifkit
Copy link
Member

yosifkit commented Apr 7, 2022

Stance is unchanged from #122 (comment):

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, [kubernetes ConfigMap,] etc).

@clintwood
Copy link
Author

@yosifkit I totally agree, however, it appears this repo is what is used to build cassandra images for docker hub which leaves us with no way to extend it. I guess I could add a volume in my compose file to point to an external directory with a cassandra.yaml file and use -Dcassandra.config=/path/to/cassandra.yaml but this is all over the place.

I've copied the Dockerfile and docker-entrypoint.sh to my local project but that's also not ideal.

Please feel free to close this PR.

@clintwood clintwood closed this Apr 7, 2022
@clintwood clintwood closed this Apr 7, 2022
@tianon
Copy link
Member

tianon commented Apr 7, 2022

You should be able to just overwrite the docker-entrypoint.sh script within the published images to get yourself custom behavior:

FROM cassandra:x.y
COPY docker-entrypoint.sh /usr/local/bin/

@clintwood
Copy link
Author

@tianon awesome yes - that will be a solution that will keep me up to date with fixes/releases as they happen - thank you

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