Skip to content

Commit f5762d7

Browse files
author
Yannic Nevado Hidalgo
committed
some stuff for create and reset cluster, storageclasses and cassandra statefulset setup
1 parent 7b7d053 commit f5762d7

File tree

6 files changed

+146
-1
lines changed

6 files changed

+146
-1
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
apiVersion: apps/v1
2+
kind: StatefulSet
3+
metadata:
4+
name: cassandra
5+
labels:
6+
app: cassandra
7+
spec:
8+
serviceName: cassandra
9+
replicas: 2
10+
selector:
11+
matchLabels:
12+
app: cassandra
13+
template:
14+
metadata:
15+
labels:
16+
app: cassandra
17+
spec:
18+
terminationGracePeriodSeconds: 1800
19+
containers:
20+
- name: cassandra
21+
image: gcr.io/google-samples/cassandra:v13
22+
imagePullPolicy: Always
23+
ports:
24+
- containerPort: 7000
25+
name: intra-node
26+
- containerPort: 7001
27+
name: tls-intra-node
28+
- containerPort: 7199
29+
name: jmx
30+
- containerPort: 9042
31+
name: cql
32+
resources:
33+
limits:
34+
cpu: "500m"
35+
memory: 1Gi
36+
requests:
37+
cpu: "500m"
38+
memory: 1Gi
39+
securityContext:
40+
capabilities:
41+
add:
42+
- IPC_LOCK
43+
lifecycle:
44+
preStop:
45+
exec:
46+
command:
47+
- /bin/sh
48+
- -c
49+
- nodetool drain
50+
env:
51+
- name: MAX_HEAP_SIZE
52+
value: 512M
53+
- name: HEAP_NEWSIZE
54+
value: 100M
55+
- name: CASSANDRA_SEEDS
56+
value: "cassandra-0.cassandra.default.svc.cluster.local"
57+
- name: CASSANDRA_CLUSTER_NAME
58+
value: "K8Demo"
59+
- name: CASSANDRA_DC
60+
value: "DC1-K8Demo"
61+
- name: CASSANDRA_RACK
62+
value: "Rack1-K8Demo"
63+
- name: POD_IP
64+
valueFrom:
65+
fieldRef:
66+
fieldPath: status.podIP
67+
readinessProbe:
68+
exec:
69+
command:
70+
- /bin/bash
71+
- -c
72+
- /ready-probe.sh
73+
initialDelaySeconds: 15
74+
timeoutSeconds: 5
75+
# These volume mounts are persistent. They are like inline claims,
76+
# but not exactly because the names need to match exactly one of
77+
# the stateful pod volumes.
78+
volumeMounts:
79+
- name: cassandra-data
80+
mountPath: /cassandra_data
81+
# These are converted to volume claims by the controller
82+
# and mounted at the paths mentioned above.
83+
# do not use these in production until ssd GCEPersistentDisk or other ssd pd
84+
volumeClaimTemplates:
85+
- metadata:
86+
name: cassandra-data
87+
spec:
88+
accessModes: [ "ReadWriteOnce" ]
89+
storageClassName: standard
90+
resources:
91+
requests:
92+
storage: 1Gi

create_operator_setup.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
kubectl create -f manifests/configmap.yaml --namespace zalando-postgres
6+
7+
kubectl create -f manifests/operator-service-account-rbac.yaml --namespace zalando-postgres
8+
9+
kubectl create -f manifests/postgres-operator.yaml --namespace zalando-postgres
10+
11+
sleep 5
12+
13+
kubectl get pod -l name=postgres-operator --namespace zalando-postgres
14+
15+
kubectl create -f manifests/minimal-postgres-manifest.yaml --namespace zalando-postgres

manifests/minimal-postgres-manifest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
# name of the pod
99
# podtemplate is statefulset -> every instance has the same name with own ordinalindex
1010
name: acid-minimal-cluster
11-
# namespace in k82 where the pods will be created
11+
# namespace in k8s where the pods will be created
1212
namespace: zalando-postgres
1313
spec:
1414
# required parameter from patroni

reset_postgres_operator_setup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
kubectl delete clusterroles zalando-postgres-operator -n zalando-postgres
6+
7+
kubectl delete clusterrolebindings zalando-postgres-operator -n zalando-postgres
8+
9+
kubectl delete serviceaccounts zalando-postgres-operator -n zalando-postgres
10+
11+
kubectl delete secrets foo-user.acid-minimal-cluster.credentials postgres.acid-minimal-cluster.credentials standby.acid-minimal-cluster.credentials zalando.acid-minimal-cluster.credentials -n zalando-postgres
12+
13+
kubectl delete configmaps postgres-operator -n zalando-postgres
14+
15+
kubectl delete postgresql acid-minimal-cluster --namespace zalando-postgres
16+
17+
kubectl delete service acid-minimal-cluster acid-minimal-cluster-repl -n zalando-postgres
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
kind: StorageClass
2+
apiVersion: storage.k8s.io/v1
3+
metadata:
4+
name: standard
5+
annotations:
6+
storageclass.beta.kubernetes.io/is-default-class: "true"
7+
provisioner: driver.longhorn.io
8+
parameters:
9+
numberOfReplicas: "2"
10+
staleReplicaTimeout: "30"
11+
fromBackup: ""
12+
recurringJobs: '[{"name":"backup", "task":"backup", "cron":"5 2 * * *", "retain":7},{"name":"week", "task":"backup", "cron":"15 2 * * 0", "retain":5},{"name":"month", "task":"backup", "cron":"25 2 1 * *", "retain":6}]'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
kind: StorageClass
2+
apiVersion: storage.k8s.io/v1
3+
metadata:
4+
name: reduced-redundancy
5+
provisioner: driver.longhorn.io
6+
parameters:
7+
numberOfReplicas: "1"
8+
staleReplicaTimeout: "30"
9+
fromBackup: ""

0 commit comments

Comments
 (0)