Git Product home page Git Product logo

cassandra-docker's Introduction

cassandra-docker

Dockerfile source for cassandra docker image.

Upstream

This source repo was originally copied from: https://github.com/docker-library/cassandra

Disclaimer

This is not an official Google product.

About

This image contains an installation of Cassandra 3

For more information, see the Official Image Marketplace Page.

Pull command (first install gcloud):

gcloud docker -- pull marketplace.gcr.io/google/cassandra3

Dockerfile for this image can be found here.

Table of Contents

Using Kubernetes

Consult Marketplace container documentation for additional information about setting up your Kubernetes environment.

Run a Cassandra server

This section describes how to spin up Cassandra service using this image.

Start a single Cassandra container

Copy the following content to pod.yaml file, and run kubectl create -f pod.yaml.

apiVersion: v1
kind: Pod
metadata:
  name: some-cassandra
  labels:
    name: some-cassandra
spec:
  containers:
    - image: marketplace.gcr.io/google/cassandra3
      name: cassandra

Run the following to expose the ports. Depending on your cluster setup, this might expose your service to the Internet with an external IP address. For more information, consult Kubernetes documentation.

kubectl expose pod some-cassandra --name some-cassandra-7000 \
  --type LoadBalancer --port 7000 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-7001 \
  --type LoadBalancer --port 7001 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-7199 \
  --type LoadBalancer --port 7199 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-9042 \
  --type LoadBalancer --port 9042 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-9160 \
  --type LoadBalancer --port 9160 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-9404 \
  --type LoadBalancer --port 9404 --protocol TCP

For information about how to retain your Cassandra data across restarts, see Add persistence.

Connect with Cassandra client (cqlsh)

You can run cqlsh directly within the container.

kubectl exec -it some-cassandra -- cqlsh

Add persistence

Run with persistent data volumes

We can mount Cassandra data directory /var/lib/cassandra on a persistent volume. This way the installation remains intact across container restarts.

Copy the following content to pod.yaml file, and run kubectl create -f pod.yaml.

apiVersion: v1
kind: Pod
metadata:
  name: some-cassandra
  labels:
    name: some-cassandra
spec:
  containers:
    - image: marketplace.gcr.io/google/cassandra3
      name: cassandra
      volumeMounts:
        - name: cassandra-data
          mountPath: /var/lib/cassandra
  volumes:
    - name: cassandra-data
      persistentVolumeClaim:
        claimName: cassandra-data
---
# Request a persistent volume from the cluster using a Persistent Volume Claim.
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: cassandra-data
  annotations:
    volume.alpha.kubernetes.io/storage-class: default
spec:
  accessModes: [ReadWriteOnce]
  resources:
    requests:
      storage: 5Gi

Run the following to expose the ports. Depending on your cluster setup, this might expose your service to the Internet with an external IP address. For more information, consult Kubernetes documentation.

kubectl expose pod some-cassandra --name some-cassandra-7000 \
  --type LoadBalancer --port 7000 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-7001 \
  --type LoadBalancer --port 7001 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-7199 \
  --type LoadBalancer --port 7199 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-9042 \
  --type LoadBalancer --port 9042 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-9160 \
  --type LoadBalancer --port 9160 --protocol TCP
kubectl expose pod some-cassandra --name some-cassandra-9404 \
  --type LoadBalancer --port 9404 --protocol TCP

Using Docker

Consult Marketplace container documentation

for additional information about setting up your Docker environment.

Run a Cassandra server

This section describes how to spin up Cassandra service using this image.

Start a single Cassandra container

Use the following content for the docker-compose.yml file, then run docker-compose up.

version: '2'
services:
  cassandra:
    container_name: some-cassandra
    image: marketplace.gcr.io/google/cassandra3
    ports:
      - '7000:7000'
      - '7001:7001'
      - '7199:7199'
      - '9042:9042'
      - '9160:9160'
      - '9404:9404'

Or you can use docker run directly:

docker run \
  --name some-cassandra \
  -p 7000:7000 \
  -p 7001:7001 \
  -p 7199:7199 \
  -p 9042:9042 \
  -p 9160:9160 \
  -p 9404:9404 \
  -d \
  marketplace.gcr.io/google/cassandra3

For information about how to retain your Cassandra data across restarts, see Add persistence.

Connect with Cassandra client (cqlsh)

You can run cqlsh directly within the container.

docker exec -it some-cassandra cqlsh

Add persistence

Run with persistent data volumes

We can mount Cassandra data directory /var/lib/cassandra on a persistent volume. This way the installation remains intact across container restarts.

Assume that /path/to/your/cassandra is the persistent directory on the host.

Use the following content for the docker-compose.yml file, then run docker-compose up.

version: '2'
services:
  cassandra:
    container_name: some-cassandra
    image: marketplace.gcr.io/google/cassandra3
    ports:
      - '7000:7000'
      - '7001:7001'
      - '7199:7199'
      - '9042:9042'
      - '9160:9160'
      - '9404:9404'
    volumes:
      - /path/to/your/cassandra:/var/lib/cassandra

Or you can use docker run directly:

docker run \
  --name some-cassandra \
  -p 7000:7000 \
  -p 7001:7001 \
  -p 7199:7199 \
  -p 9042:9042 \
  -p 9160:9160 \
  -p 9404:9404 \
  -v /path/to/your/cassandra:/var/lib/cassandra \
  -d \
  marketplace.gcr.io/google/cassandra3

References

Ports

These are the ports exposed by the container image.

Port Description
TCP 7000 Cassandra inter-node cluster communication.
TCP 7001 Cassandra SSL inter-node cluster communication.
TCP 7199 Cassandra JMX monitoring port.
TCP 9042 Cassandra client port.
TCP 9160 Cassandra Thrift client port.
TCP 9404 Prometheus plugin port.

Environment Variables

These are the environment variables understood by the container image.

Variable Description
CASSANDRA_LISTEN_ADDRESS Specifies which IP address to listen on for incoming connections. Defaults to auto, which will use the IP address of the container.

This variable sets the listen_address option in cassandra.yaml.
CASSANDRA_BROADCAST_ADDRESS Specifies which IP address to advertise to other nodes. Defaults to the value of CASSANDRA_LISTEN_ADDRESS.

This variable sets the broadcast_address and broadcast_rpc_address options in cassandra.yaml.
CASSANDRA_RPC_ADDRESS Specifies which address to bind the thrift rpc server to. Defaults to 0.0.0.0 wildcard address.

This variable sets the rpc_address option in cassandra.yaml.
CASSANDRA_START_RPC Specifies starting the thrift rpc server if set to true.

This variable sets the start_rpc option in cassandra.yaml.
CASSANDRA_SEEDS Specifies a comma-separated list of IP addresses used by gossip for bootstrapping new nodes joining a cluster. The value of CASSANDRA_BROADCAST_ADDRESS is automatically added to the list so that the server can also talk to itself.

This variable sets the seeds value of the seed_provider option in cassandra.yaml.
CASSANDRA_CLUSTER_NAME Specifies the name of the cluster. This value must be the same for all nodes in the same cluster.

This variable sets the cluster_name option in cassandra.yaml.
CASSANDRA_NUM_TOKENS Specifies number of tokens for this node.

This variable sets the num_tokens option of cassandra.yaml.
CASSANDRA_DC Specifies the datacenter name of this node.

This variable sets the dc option in cassandra-rackdc.properties.
CASSANDRA_RACK Specifies the rack name of this node.

This variable sets the rack option in cassandra-rackdc.properties.
CASSANDRA_ENDPOINT_SNITCH Specifies the snitch implementation this node will use.

This variable sets the endpoint_snitch option in cassandra.yml.
CASSANDRA_PROMETHEUS_ENABLED Specifies if Prometheus metrics should be visible.

If set to true, this variable adds JMX Exporter as a Java agent in $JVM_OPTS variable. Metrics are available under local endpoint http://localhost:9404/metrics.
CASSANDRA_CGROUP_MEMORY_LIMIT Specifies if heap size should be limited by cgroup constraints

If set to true, this variable add -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=2 to $JVM_OPTS variable. This will restrict maximum heap size to cgroup limit.

Volumes

These are the filesystem paths used by the container image.

Path Description
/var/lib/cassandra All Cassandra files are installed here.

cassandra-docker's People

Contributors

aav66 avatar adrianmaniek avatar armandomiani avatar eugenekorolevich avatar farajn9 avatar ganochenkodg avatar harnas-google avatar huyhg avatar jprzychodzen avatar marzinkievitz avatar ovk6 avatar tomasz-safuryn avatar wgrzelak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cassandra-docker's Issues

How to set seed?

I am using this image in a DaemonSet, in order to run one Cassandra on every node in my cluster. They come up ok, but they each stand alone, and do not form a cluster.

https://github.com/kubernetes/kubernetes/tree/master/examples/storage/cassandra has a way of setting the seed from a k8s API. Does this image use some other way of doing it?

Basically, I can't tell if this is supported but not documented well, or if this image is meant to only run a 1 node cassandra "cluster".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.