Getting your own Cassandra environment setup with open remote connections on Openshift can be achieved in 3 steps:
Line 1: This Dockerfile uses the base image of the most stable version(3.11.8) of Cassandra from Docker hub
Line 3–4: I have updated the group level permissions of the cassandra configuration folder(/etc/cassandra) to root to make it accessible when Cassandra is started on Openshift.
The Cassandra documentation suggests that default cassandra configs can be overridden by defining environment variables. I tried that in different ways and failed miserably. So I decided to go to default configurations and update them there so that when Cassandra starts, it reads my updated configurations right there.
Line 6–8: They are the linux way of removing a line with certain words from the original configuration yaml file. We “grep” the word we are looking for and then remove the line that contains the word .We then write the entire file to a tempfile and then rename the temp into the original cassandra.yaml file. Line 6 and 7 represent removing the existing rpc_address and broadcast_rpc_address lines from the file. We need to remove these because they are set to “localhost” which means no other host outside the container can connect to it. Line 8 is to remove the default no-password-required authenticator configuration from the original yaml.
Line 10–12: After removing these lines, we append the right values for these variables. Line 10 and 11 set rpc_address and broadcast_address to the right values as per the original cassandra documentation to open it up to remote connections. Line 12 enables password authentication. The default username and password are set to “cassandra”. Adding new roles and resetting the password is not included in this article.
Line 14: This is to open JMX connections from outside by adding LOCAL_JMX=no to the top of the cassandra-env.sh file.
Once the Dockerfile is created, we can leverage basic Docker commands or when you are lazy like me — put them in scripts and run them when needed.
But first, hookup docker with your registry by following the instructions from the settings of your repository. For Quay, Open the repository and goto settings and find the Docker Login option and copy paste the below command into your commandline.