-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcassandra-statefulset.yaml
126 lines (126 loc) · 3.64 KB
/
cassandra-statefulset.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Cassandra Headless Service
apiVersion: v1
kind: Service
metadata:
namespace: somenamespace
labels:
name: ugc
name: cassandra
spec:
clusterIP: None
ports:
- port: 9042
name: cql
- port: 7000
name: inter-node
- port: 7001
name: ssl-inter-node
selector:
app: cassandra
---
# Cassandra StatefulSet
apiVersion: "apps/v1beta1"
kind: StatefulSet
metadata:
namespace: somenamespace
labels:
name: ugc
name: cassandra
spec:
serviceName: cassandra
replicas: 3
template:
metadata:
labels:
app: cassandra
spec:
containers:
- name: cassandra
image: siganberg/cassandra_kube:latest
imagePullPolicy: Always
lifecycle:
postStart:
exec:
command:
- bash
- -c
- >
#-- Copy environment variables to the following path so CRON can access the values
printenv | grep -v "no_proxy" >> /etc/environment;
#-- Generate CRON schedule for the backup
echo "${CASSANDRA_BACKUP_CRON} root /cassandra-aws-backup.sh -b s3://${S3_BUCKET_NAME}/test/ -vcC -u ${CASSANDRA_USER} -p ${CASSANDRA_PASS} > /var/log/cassandra/backup.log 2>&1" > /etc/cron.d/cassandra_cron;
cron;
#-- Uncomment this section for restoration. This will stop cassandra process to auto start
#command:
# - /bin/bash
# - -c
# - while true; do sleep 30; done;
ports:
- containerPort: 7000
name: intra-node
- containerPort: 7001
name: tls-intra-node
- containerPort: 7199
name: jmx
- containerPort: 9042
name: cql
resources:
limits:
cpu: 0.5
env:
- name: MAX_HEAP_SIZE
value: 256M
- name: HEAP_NEWSIZE
value: 100M
- name: CASSANDRA_SEEDS
value: "cassandra-0.cassandra.somenamespace.svc.cluster.local"
- name: CASSANDRA_CLUSTER_NAME
value: "somenamespace"
- name: CASSANDRA_DC
value: "DC1"
- name: CASSANDRA_RACK
value: "Rack1"
- name: CASSANDRA_AUTO_BOOTSTRAP
value: "false"
- name: CASSANDRA_ENDPOINT_SNITCH
value: GossipingPropertyFileSnitch
- name: CASSANDRA_BACKUP_CRON
value: "0 1 * * *"
- name: CASSANDRA_USER
value: "cassandra"
- name: CASSANDRA_PASS
value: "somepassword"
- name: AWS_ACCESS_KEY_ID
value: "enter you aws access key"
- name: AWS_SECRET_ACCESS_KEY
value: "enter your aws your secret "
- name: S3_BUCKET_NAME
value: "s3bucket"
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
#-- comment readinessProbe during restoration.
readinessProbe:
exec:
command:
- /bin/bash
- -c
- /ready-probe.sh
initialDelaySeconds: 15
timeoutSeconds: 5
volumeMounts:
- mountPath : /var/lib/cassandra/data
name: cassandra-data
imagePullSecrets:
- name: harbor-authenticate
volumeClaimTemplates:
- metadata:
name: cassandra-data
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi