Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cass-operator to deploy cassandra for dev cluster #968

Merged
merged 2 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ UPX_OPTIONS ?= -9

K8S_EXTERNAL_SCYLLA_MANIFEST ?= k8s/external/scylla/scyllacluster.yaml

K8S_KUBECTL_VERSION ?= $(eval K8S_KUBECTL_VERSION := $(shell kubectl version --short))$(K8S_KUBECTL_VERSION)
K8S_SERVER_VERSION ?= $(eval K8S_SERVER_VERSION := $(shell echo "$(K8S_KUBECTL_VERSION)" | sed -e "s/.*Server.*\(v[0-9]\.[0-9]*\)\..*/\1/g"))$(K8S_SERVER_VERSION)

COMMA := ,
SHELL = bash

Expand Down
12 changes: 10 additions & 2 deletions Makefile.d/k8s.mk
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ k8s/vald/deploy/cassandra: \
--set defaults.image.tag=$(VERSION) \
--output-dir $(TEMP_DIR) \
charts/vald
kubectl apply -f $(TEMP_DIR)/vald/templates/jobs/db/initialize/cassandra
kubectl apply -f $(TEMP_DIR)/vald/templates/manager/backup
kubectl apply -f $(TEMP_DIR)/vald/templates/manager/compressor
kubectl apply -f $(TEMP_DIR)/vald/templates/manager/index
Expand All @@ -140,6 +141,7 @@ k8s/vald/delete/cassandra: \
--set defaults.image.tag=$(VERSION) \
--output-dir $(TEMP_DIR) \
charts/vald
kubectl delete -f $(TEMP_DIR)/vald/templates/jobs/db/initialize/cassandra
kubectl delete -f $(TEMP_DIR)/vald/templates/manager/backup
kubectl delete -f $(TEMP_DIR)/vald/templates/manager/compressor
kubectl delete -f $(TEMP_DIR)/vald/templates/manager/index
Expand Down Expand Up @@ -237,14 +239,20 @@ k8s/external/redis/initialize:
.PHONY: k8s/external/cassandra/deploy
## deploy cassandra to k8s
k8s/external/cassandra/deploy:
kubectl apply -f k8s/jobs/db/initialize/cassandra/configmap.yaml
kubectl apply -f https://raw.githubusercontent.com/datastax/cass-operator/master/docs/user/cass-operator-manifests-$(K8S_SERVER_VERSION).yaml
sleep 2
kubectl apply -n cass-operator -f k8s/jobs/db/initialize/cassandra/secret.yaml
kubectl wait -n cass-operator --for=condition=ready pod -l name=cass-operator --timeout=600s
kubectl apply -f k8s/external/cassandra
sleep 20
kubectl wait -n cass-operator --for=condition=ready pod -l statefulset.kubernetes.io/pod-name=cluster0-dc0-default-sts-0 --timeout=600s

.PHONY: k8s/external/cassandra/delete
## delete cassandra from k8s
k8s/external/cassandra/delete:
kubectl delete -n cass-operator -f k8s/jobs/db/initialize/cassandra/secret.yaml
kubectl delete -f k8s/external/cassandra
kubectl delete configmap cassandra-initdb
kubectl delete -f https://raw.githubusercontent.com/datastax/cass-operator/master/docs/user/cass-operator-manifests-$(K8S_SERVER_VERSION).yaml

.PHONY: k8s/external/cassandra/initialize
## initialize cassandra on k8s
Expand Down
30 changes: 18 additions & 12 deletions charts/vald/values-cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ manager:
image: cassandra:latest
cassandra:
hosts:
- cassandra-0.default.svc.cluster.local
- cassandra-1.default.svc.cluster.local
- cassandra-2.default.svc.cluster.local
- cluster0-dc0-service.cass-operator.svc.cluster.local
options:
- "-uroot"
- "-p${CASSANDRA_PASSWORD}"
Expand All @@ -55,9 +53,7 @@ manager:
enabled: true
config:
hosts:
- cassandra-0.cassandra.default.svc.cluster.local
- cassandra-1.cassandra.default.svc.cluster.local
- cassandra-2.cassandra.default.svc.cluster.local
- cluster0-dc0-service.cass-operator.svc.cluster.local

meta:
image:
Expand All @@ -68,9 +64,7 @@ meta:
image: cassandra:latest
cassandra:
hosts:
- cassandra-0.default.svc.cluster.local
- cassandra-1.default.svc.cluster.local
- cassandra-2.default.svc.cluster.local
- cluster0-dc0-service.cass-operator.svc.cluster.local
options:
- "-uroot"
- "-p${CASSANDRA_PASSWORD}"
Expand All @@ -93,6 +87,18 @@ meta:
enabled: true
config:
hosts:
- cassandra-0.cassandra.default.svc.cluster.local
- cassandra-1.cassandra.default.svc.cluster.local
- cassandra-2.cassandra.default.svc.cluster.local
- cluster0-dc0-service.cass-operator.svc.cluster.local

initializer:
cassandra:
enabled: true
env:
- name: CASSANDRA_HOST
value: cluster0-dc0-service.cass-operator.svc.cluster.local
configmap:
enabled: true
secret:
enabled: true
data:
username: cm9vdA==
password: cGFzc3dvcmQ=
60 changes: 60 additions & 0 deletions k8s/external/cassandra/cassandracluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#
# Copyright (C) 2019-2021 vdaas.org vald team <vald@vdaas.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: cassandra-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: cassandra.datastax.com/v1beta1
kind: CassandraDatacenter
metadata:
name: dc0
namespace: cass-operator
spec:
clusterName: cluster0
serverType: cassandra
serverVersion: 3.11.7
managementApiAuth:
insecure: {}
size: 1
superuserSecretName: cassandra-secret
storageConfig:
cassandraDataVolumeClaimSpec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
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: 400M
max_heap_size: 400M
80 changes: 0 additions & 80 deletions k8s/external/cassandra/statefulset.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions k8s/external/cassandra/svc.yaml

This file was deleted.