Skip to content

Instantly share code, notes, and snippets.

@rsds143
Last active February 23, 2021 10:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsds143/0e9263ed4287d888fab36eb3e4aec502 to your computer and use it in GitHub Desktop.
Save rsds143/0e9263ed4287d888fab36eb3e4aec502 to your computer and use it in GitHub Desktop.
getting started with k8s and Cassandra-operator
  • install docker desktop https://www.docker.com/products/docker-desktop
  • install k3d https://github.com/rancher/k3d#get you can just run curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash`
  • create cluster: k3d cluster create
  • install operator manifest kubectl create -f https://raw.githubusercontent.com/datastax/cass-operator/v1.5.1/docs/user/cass-operator-manifests-v1.19.yaml
  • download a cassandra data center yaml wget https://gist.githubusercontent.com/rsds143/0e9263ed4287d888fab36eb3e4aec502/raw/f919172c64452a2277b7523d680a9e12916d0d39/cassandra-dc.yaml
  • run kubectl create -f cassandra-dc.yaml --namespace cass-operator
  • wait for cassandra to come up kubectl logs cluster1-dc1-default-sts-0 --namespace cass-operator server-system-logger
  • get username export CQLUSER=$(kubectl get secret cluster1-superuser -o json -n cass-operator | grep \"username\" | sed -E 's/\"(.+)\": \"(.+)\"/\2/' | base64 -d)
  • get password export CQLPASS=$(kubectl get secret cluster1-superuser -o json -n cass-operator | grep \"password\" | sed -E 's/\"(.+)\": \"(.+)\"/\2/' | sed -E 's/,*$//g' | base64 -d )
  • log into cqlsh kubectl exec -it -n cass-operator cluster1-dc1-default-sts-0 -- cqlsh -u $CQLUSER -p $CQLPASS
  • enjoy your cassandra cluster
#!/bin/bash
echo "installing k3d"
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
echo "creating k3d cluster"
k3d cluster create
echo "installing cassandra operator"
kubectl create -f https://raw.githubusercontent.com/datastax/cass-operator/v1.5.1/docs/user/cass-operator-manifests-v1.19.yaml
echo "installing cassandra data center"
curl -O https://gist.githubusercontent.com/rsds143/0e9263ed4287d888fab36eb3e4aec502/raw/f919172c64452a2277b7523d680a9e12916d0d39/cassandra-dc.yaml
kubectl create -f cassandra-dc.yaml --namespace cass-operator
echo "Sleeping for 120 seconds…"
sleep 120
echo "getting username and password"
echo "trying to login"
export CQLUSER=$(kubectl get secret cluster1-superuser -o json -n cass-operator | grep \"username\" | sed -E 's/\"(.+)\": \"(.+)\"/\2/' | base64 -d)
export CQLPASS=$(kubectl get secret cluster1-superuser -o json -n cass-operator | grep \"password\" | sed -E 's/\"(.+)\": \"(.+)\"/\2/' | sed -E 's/,*$//g' | base64 -d )
kshell() {
kubectl exec -it -n cass-operator cluster1-dc1-default-sts-0 -- cqlsh -u $CQLUSER -p $CQLPASS
}
kshell
apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
metadata:
name: dc1
spec:
clusterName: cluster1
serverType: cassandra
serverVersion: 3.11.7
managementApiAuth:
insecure: {}
size: 1
storageConfig:
cassandraDataVolumeClaimSpec:
storageClassName: local-path
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
config:
cassandra-yaml:
authenticator: org.apache.cassandra.auth.PasswordAuthenticator
authorizer: org.apache.cassandra.auth.CassandraAuthorizer
role_manager: org.apache.cassandra.auth.CassandraRoleManager
jvm-options:
initial_heap_size: 800M
max_heap_size: 800M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment