Skip to content

Commit

Permalink
Merge pull request #61 from SmartColumbusOS/crashloop-fix
Browse files Browse the repository at this point in the history
Update Strimzi and Kafka Versions
  • Loading branch information
LtChae authored Sep 18, 2019
2 parents cc5d419 + dbf8606 commit 519a618
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
streaming_service-*.tar

.DS_Store
.DS_Store

replicas.txt
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def deployStrimzi() {
sh "kubectl apply -f k8s/namespace.yaml"
sh "helm init --service-account tiller"
sh "helm repo add strimzi http://strimzi.io/charts/"
sh "helm upgrade --install strimzi-kafka-operator strimzi/strimzi-kafka-operator --version 0.08.0 -f strimzi-config.yml --namespace strimzi"
sh "helm upgrade --install strimzi-kafka-operator strimzi/strimzi-kafka-operator --version 0.13.0 -f strimzi-config.yml --namespace strimzi"
}

def deployKafka(environment) {
Expand Down
1 change: 1 addition & 0 deletions chart/templates/kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: "{{ .Values.kafka.strimziCluster }}"
spec:
kafka:
version: {{ .Values.kafka.version }}
replicas: {{ .Values.kafka.defaultReplicas }}
listeners:
plain: {}
Expand Down
1 change: 1 addition & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
kafka:
version: 2.1.1
broker: streaming-service-kafka-bootstrap.streaming-prime:9092
strimziCluster: streaming-service
storageSize: 100Gi
Expand Down
26 changes: 26 additions & 0 deletions scripts/scale-down.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
rm -f replicas.txt

scaleAppToIn () {
kubectl scale --replicas=$2 deployment/$1 -n $3
}

recordReplicas () {
replicas=`kubectl get deployment $1 -n $2 -o=jsonpath='{.status.replicas}'`
echo "$1 has $replicas replicas"
echo "$1 $2 $replicas" >> replicas.txt
}

echo
echo "Recording current replicas:"
recordReplicas andi admin
for app in reaper valkyrie forklift streisand flair odo
do
recordReplicas $app streaming-services
done

echo
echo "Scaling apps down to 0:"
while IFS=" " read -r app namespace replicas remainder
do
scaleAppToIn $app 0 $namespace
done < "replicas.txt"
10 changes: 10 additions & 0 deletions scripts/scale-up.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
scaleAppToIn () {
kubectl scale --replicas=$2 deployment/$1 -n $3
}

echo
echo "Scaling apps up to previous replicas:"
while IFS=" " read -r app namespace replicas remainder
do
scaleAppToIn $app $replicas $namespace
done < "replicas.txt"
35 changes: 35 additions & 0 deletions scripts/update-kafka-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -e

echo
echo "Deleting old Stateful Sets:"
kubectl delete sts streaming-service-public-kafka -n streaming-public --cascade=false
kubectl delete sts streaming-service-kafka -n streaming-prime --cascade=false

start_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"

echo
echo "Waiting for Strimzi to recreate the Stateful Sets:"
until kubectl get sts streaming-service-kafka -n streaming-prime 2> /dev/null
do
printf "."
sleep 10s
done
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
echo "Prime STS Recreated in $elapsed seconds"

until kubectl get sts streaming-service-public-kafka -n streaming-public 2> /dev/null
do
printf "."
sleep 10s
done
end_time="$(date -u +%s)"
elapsed="$(($end_time-$start_time))"
echo "Public STS Recreated in $elapsed seconds"

/bin/bash ./scale_down.sh

kubectl annotate statefulset streaming-service-kafka strimzi.io/manual-rolling-update=true -n streaming-prime
kubectl annotate statefulset streaming-service-public-kafka strimzi.io/manual-rolling-update=true -n streaming-public

0 comments on commit 519a618

Please sign in to comment.