Last active
April 1, 2020 10:00
-
-
Save alexcpn/6a919b500211b5c253a4e28010325a1d to your computer and use it in GitHub Desktop.
Cassandra in Kuberenetes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: cassandra | |
namespace: green | |
labels: | |
app: cassandra | |
spec: | |
serviceName: cassandra | |
replicas: 3 | |
selector: | |
matchLabels: | |
app: cassandra | |
template: | |
metadata: | |
labels: | |
app: cassandra | |
spec: | |
terminationGracePeriodSeconds: 1800 | |
initContainers: | |
- name: copy | |
image: busybox:1.28 | |
command: ["/bin/sh", "-c", "cp /config/cassandra.yaml /config/cassandra/"] | |
volumeMounts: | |
- name: tmp-config | |
mountPath: /config/cassandra/ | |
- name: cassandraconfig | |
mountPath: /config/ | |
containers: | |
- name: cassandra | |
#image: gcr.io/google-samples/cassandra:v13 | |
image: cassandra:3.0 | |
imagePullPolicy: Always | |
#command: [ "/bin/sh","-c","su cassandra && mkdir -p /etc/cassandra/ && cp /config/cassandra/cassandra.yaml /etc/cassandra/" ] | |
ports: | |
- containerPort: 7000 | |
name: intra-node | |
- containerPort: 7001 | |
name: tls-intra-node | |
- containerPort: 7199 | |
name: jmx | |
- containerPort: 9042 | |
name: cql | |
resources: | |
limits: | |
cpu: "500m" | |
memory: 4Gi | |
requests: | |
cpu: "500m" | |
memory: 4Gi | |
securityContext: | |
capabilities: | |
add: | |
- IPC_LOCK | |
lifecycle: | |
postStart: | |
exec: | |
command: | |
- /bin/sh | |
- -c | |
- "echo \"authenticator: PasswordAuthenticator\" >> /etc/cassandra/cassandra.yaml" | |
# - "cp /config/cassandra/cassandra.yaml /tmp/" | |
preStop: | |
exec: | |
command: | |
- /bin/sh | |
- -c | |
- nodetool drain | |
env: | |
- name: MAX_HEAP_SIZE | |
value: 1G | |
- name: HEAP_NEWSIZE | |
value: 100M | |
- name: CASSANDRA_SEEDS | |
value: "cassandra-0.cassandra.green.svc.cluster.local" | |
- name: CASSANDRA_CLUSTER_NAME | |
value: "green" | |
- name: CASSANDRA_DC | |
value: "ee1-green" | |
- name: CASSANDRA_RACK | |
value: "Rack1-green" | |
- name: POD_IP | |
valueFrom: | |
fieldRef: | |
fieldPath: status.podIP | |
#readinessProbe: | |
# exec: | |
# command: | |
# - /bin/bash | |
# - -c | |
# - /ready-probe.sh | |
#initialDelaySeconds: 15 | |
#timeoutSeconds: 15 | |
volumeMounts: | |
- name: cassandradata | |
mountPath: /cassandra_data | |
- name: tmp-config | |
mountPath: /config/cassandra/ | |
#- name: cassandraconfig | |
# mountPath: /etc/cassandra/cassandra.yaml | |
# subPath: cassandra.yaml | |
volumes: | |
- name: cassandraconfig | |
configMap: | |
name: cassandraconfig | |
- name: tmp-config | |
emptyDir: {} | |
# 1 Creating a volume to move date from init container to main container without making mount ReadOnly | |
# These are converted to volume claims by the controller | |
# and mounted at the paths mentioned above. | |
volumeClaimTemplates: | |
- metadata: | |
name: cassandradata | |
spec: | |
accessModes: [ "ReadWriteOnce" ] | |
storageClassName: rook-ceph-block | |
resources: | |
requests: | |
storage: 5Gi | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Service | |
metadata: | |
labels: | |
app: cassandra | |
name: cassandra | |
namespace: green | |
spec: | |
clusterIP: None | |
ports: | |
- port: 9042 | |
selector: | |
app: cassandra |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment