Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

CORTX-30140: Zookeeper managed as cortx Helm Chart dependency #236

Merged
merged 2 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion charts/cortx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ helm uninstall cortx
| kafka.serviceAccount.automountServiceAccountToken | bool | `false` | Allow auto mounting of the service account token |
| kafka.serviceAccount.create | bool | `true` | Enable the creation of a ServiceAccount for Kafka pods |
| kafka.transactionStateLogMinIsr | int | `2` | Overridden min.insync.replicas config for the transaction topic |
| kafka.zookeeper.enabled | bool | `false` | Enable installation of the Zookeeper chart |
| kafka.zookeeper.containerSecurityContext.allowPrivilegeEscalation | bool | `false` | Allow extra privileges in Zookeeper containers |
| kafka.zookeeper.enabled | bool | `true` | Enable installation of the Zookeeper chart |
| kafka.zookeeper.serviceAccount.automountServiceAccountToken | bool | `false` | Allow auto mounting of the service account token |
| kafka.zookeeper.serviceAccount.create | bool | `true` | Enable the creation of a ServiceAccount for Zookeeper pods |
| serviceAccount.annotations | object | `{}` | Custom annotations for the CORTX ServiceAccount |
| serviceAccount.automountServiceAccountToken | bool | `false` | Allow auto mounting of the service account token |
| serviceAccount.create | bool | `true` | Enable the creation of a ServiceAccount for CORTX pods |
Expand Down
10 changes: 9 additions & 1 deletion charts/cortx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,12 @@ kafka:
# ref: https://github.com/bitnami/charts/blob/master/bitnami/zookeeper/values.yaml
zookeeper:
# -- Enable installation of the Zookeeper chart
enabled: false
enabled: true
serviceAccount:
# -- Enable the creation of a ServiceAccount for Zookeeper pods
create: true
# -- Allow auto mounting of the service account token
automountServiceAccountToken: false
containerSecurityContext:
# -- Allow extra privileges in Zookeeper containers
allowPrivilegeEscalation: false
78 changes: 18 additions & 60 deletions k8_cortx_cloud/deploy-cortx-cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ function deployCortx()
local kafka_registry="${registry}"
local kafka_repository="${repository}"

local zookeeper_image
zookeeper_image=$(parseSolution 'solution.images.zookeeper' | cut -f2 -d'>')
splitDockerImage "${zookeeper_image}"
local zookeeper_tag="${tag}"
local zookeeper_registry="${registry}"
local zookeeper_repository="${repository}"

helm install cortx ../charts/cortx \
--set global.storageClass=${storage_class} \
--set consul.server.image="${consul_image}" \
Expand All @@ -406,7 +413,6 @@ function deployCortx()
--set kafka.image.registry="${kafka_registry}" \
--set kafka.image.repository="${kafka_repository}" \
--set kafka.replicaCount="${num_kafka_replicas}" \
--set kafka.externalZookeeper.servers="zookeeper" \
--set kafka.defaultReplicationFactor="${num_kafka_replicas}" \
--set kafka.offsetsTopicReplicationFactor="${num_kafka_replicas}" \
--set kafka.transactionStateLogReplicationFactor="${num_kafka_replicas}" \
Expand All @@ -415,6 +421,16 @@ function deployCortx()
--set kafka.resources.limits.memory="$(extractBlock 'solution.common.resource_allocation.kafka.resources.limits.memory')" \
--set kafka.resources.limits.cpu="$(extractBlock 'solution.common.resource_allocation.kafka.resources.limits.cpu')" \
--set kafka.persistence.size="$(extractBlock 'solution.common.resource_allocation.kafka.storage_request_size')" \
--set kafka.zookeeper.image.tag="${zookeeper_tag}" \
--set kafka.zookeeper.image.registry="${zookeeper_registry}" \
--set kafka.zookeeper.image.repository="${zookeeper_repository}" \
--set kafka.zookeeper.replicaCount="${num_kafka_replicas}" \
--set kafka.zookeeper.resources.requests.memory="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.requests.memory')" \
--set kafka.zookeeper.resources.requests.cpu="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.requests.cpu')" \
--set kafka.zookeeper.resources.limits.memory="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.limits.memory')" \
--set kafka.zookeeper.resources.limits.cpu="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.limits.cpu')" \
--set kafka.zookeeper.persistence.size="$(extractBlock 'solution.common.resource_allocation.zookeeper.storage_request_size')" \
--set kafka.zookeeper.persistence.dataLogDir.size="$(extractBlock 'solution.common.resource_allocation.zookeeper.data_log_dir_request_size')" \
--namespace "${namespace}" \
--wait \
|| exit $?
Expand All @@ -432,7 +448,6 @@ function deployCortx()
kubectl rollout restart daemonset/cortx-consul-client --namespace "${namespace}"

##TODO This needs to be maintained during upgrades etc...

}

function splitDockerImage()
Expand All @@ -448,62 +463,6 @@ function splitDockerImage()
tag="${tag_arr[1]}"
}

function deployZookeeper()
{
local image

printf "######################################################\n"
printf "# Deploy Zookeeper \n"
printf "######################################################\n"
image=$(parseSolution 'solution.images.zookeeper')
image=$(echo "${image}" | cut -f2 -d'>')
splitDockerImage "${image}"
printf "\nRegistry: %s\nRepository: %s\nTag: %s\n" "${registry}" "${repository}" "${tag}"

helm install zookeeper bitnami/zookeeper \
--version 9.1.0 \
--set image.tag="${tag}" \
--set image.registry="${registry}" \
--set image.repository="${repository}" \
--set replicaCount="${num_kafka_replicas}" \
--set global.storageClass=${storage_class} \
--set resources.requests.memory="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.requests.memory')" \
--set resources.requests.cpu="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.requests.cpu')" \
--set resources.limits.memory="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.limits.memory')" \
--set resources.limits.cpu="$(extractBlock 'solution.common.resource_allocation.zookeeper.resources.limits.cpu')" \
--set persistence.size="$(extractBlock 'solution.common.resource_allocation.zookeeper.storage_request_size')" \
--set persistence.dataLogDir.size="$(extractBlock 'solution.common.resource_allocation.zookeeper.data_log_dir_request_size')" \
--set serviceAccount.create=true \
--set serviceAccount.name="cortx-zookeeper" \
--set serviceAccount.automountServiceAccountToken=false \
--set containerSecurityContext.allowPrivilegeEscalation=false \
--namespace "${namespace}" \
--wait \
|| exit $?

printf "\nWait for Zookeeper to be ready before starting kafka"
while true; do
count=0
while IFS= read -r line; do
IFS=" " read -r -a pod_status <<< "${line}"
IFS="/" read -r -a ready_status <<< "${pod_status[2]}"
if [[ "${pod_status[3]}" != "Running" || "${ready_status[0]}" != "${ready_status[1]}" ]]; then
count=$((count+1))
break
fi
done <<< "$(kubectl get pods -A | grep 'zookeeper')"

if [[ ${count} -eq 0 ]]; then
break
else
printf "."
fi
sleep 1s
done
printf "\n\n"
sleep 2s
}

function waitForThirdParty()
{
printf "\nWait for CORTX 3rd party to be ready"
Expand All @@ -516,7 +475,7 @@ function waitForThirdParty()
count=$((count+1))
break
fi
done <<< "$(kubectl get pods --namespace="${namespace}" --no-headers | grep '^cortx-consul\|^cortx-kafka\|zookeeper')"
done <<< "$(kubectl get pods --namespace="${namespace}" --no-headers | grep '^cortx-consul\|^cortx-kafka\|^cortx-zookeeper')"

if [[ ${count} -eq 0 ]]; then
break
Expand Down Expand Up @@ -1231,7 +1190,6 @@ if [[ "${num_worker_nodes}" -gt "${max_kafka_inst}" ]]; then
fi

deployRancherProvisioner
deployZookeeper
deployCortx
waitForThirdParty

Expand Down
15 changes: 4 additions & 11 deletions k8_cortx_cloud/destroy-cortx-cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,6 @@ function deleteCortxConfigmap()
#############################################################
# Destroy CORTX 3rd party functions
#############################################################
function deleteZookeeper()
{
printf "########################################################\n"
printf "# Delete Zookeeper #\n"
printf "########################################################\n"
uninstallHelmChart zookeeper "${namespace}"
}

function deleteOpenLdap()
{
## Backwards compatibility check
Expand Down Expand Up @@ -295,6 +287,9 @@ function deleteDeprecated()
deleteOpenLdap
uninstallHelmChart consul "${namespace}"
uninstallHelmChart kafka "${namespace}"
uninstallHelmChart zookeeper "${namespace}"

waitFor3rdPartyToTerminate
}

function waitFor3rdPartyToTerminate()
Expand All @@ -306,7 +301,7 @@ function waitFor3rdPartyToTerminate()
while IFS= read -r line; do
count=$(( count + 1 ))
done < <(kubectl get pods --namespace "${namespace}" --no-headers | \
grep -e zookeeper -e openldap -e '^consul' -e '^kafka')
grep -e '^zookeeper' -e openldap -e '^consul' -e '^kafka')

(( count == 0 )) && break || printf "."
sleep 1s
Expand Down Expand Up @@ -395,9 +390,7 @@ deleteCortxConfigmap
#############################################################
# Delete CORTX 3rd party resources
#############################################################
deleteZookeeper
deleteDeprecated
waitFor3rdPartyToTerminate

# Delete remaining CORTX Cloud resources
uninstallHelmChart cortx "${namespace}"
Expand Down
111 changes: 50 additions & 61 deletions k8_cortx_cloud/status-cortx-cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -940,24 +940,23 @@ else
fi

alert_msg "### Zookeeper"
zookeeper_selector="app.kubernetes.io/component=zookeeper"
# Check StatefulSet
num_items=1
count=0
msg_info "| Checking StatefulSet |"
while IFS= read -r line; do
IFS=" " read -r -a status <<< "${line}"
IFS="/" read -r -a ready_status <<< "${status[1]}"
if [[ "${status[0]}" != "" ]]; then
printf "%s..." "${status[0]}"
if [[ "${ready_status[0]}" != "${ready_status[1]}" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
printf "%s..." "${status[0]}"
if [[ "${ready_status[0]}" != "${ready_status[1]}" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
done < <(kubectl get statefulsets --namespace="${namespace}" | grep 'zookeeper')
done < <(kubectl get statefulsets --namespace="${namespace}" --selector=${zookeeper_selector} --no-headers)

if [[ ${num_items} -eq ${count} ]]; then
msg_overall_passed
Expand All @@ -971,19 +970,17 @@ num_items=${num_replicas}
count=0
msg_info "| Checking Pods |"
while IFS= read -r line; do
IFS=" " read -r -a status <<< "${line}"
IFS=" " read -r -a status <<< "${line}"
IFS="/" read -r -a ready_status <<< "${status[1]}"
if [[ "${status[0]}" != "" ]]; then
printf "%s..." "${status[0]}"
if [[ "${status[2]}" != "Running" || "${ready_status[0]}" != "${ready_status[1]}" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
printf "%s..." "${status[0]}"
if [[ "${status[2]}" != "Running" || "${ready_status[0]}" != "${ready_status[1]}" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
done < <(kubectl get pods --namespace="${namespace}" | grep 'zookeeper-')
done < <(kubectl get pods --namespace="${namespace}" --selector=${zookeeper_selector} --no-headers)

if [[ ${num_items} -eq ${count} ]]; then
msg_overall_passed
Expand All @@ -998,17 +995,15 @@ count=0
msg_info "| Checking Services: Cluster IP |"
while IFS= read -r line; do
IFS=" " read -r -a status <<< "${line}"
if [[ "${status[0]}" != "" ]]; then
printf "%s..." "${status[0]}"
if [[ "${status[1]}" != "ClusterIP" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
printf "%s..." "${status[0]}"
if [[ "${status[1]}" != "ClusterIP" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
done < <(kubectl get services --namespace="${namespace}" | grep 'zookeeper' | grep -v 'zookeeper-headless')
done < <(kubectl get services --namespace="${namespace}" --selector=${zookeeper_selector} --no-headers | grep -v cortx-zookeeper-headless)

if [[ ${num_items} -eq ${count} ]]; then
msg_overall_passed
Expand All @@ -1023,17 +1018,15 @@ count=0
msg_info "| Checking Services: Headless |"
while IFS= read -r line; do
IFS=" " read -r -a status <<< "${line}"
if [[ "${status[0]}" != "" ]]; then
printf "%s..." "${status[0]}"
if [[ "${status[1]}" != "ClusterIP" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
printf "%s..." "${status[0]}"
if [[ "${status[1]}" != "ClusterIP" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
done < <(kubectl get services --namespace="${namespace}" | grep 'zookeeper-headless')
done < <(kubectl get services --namespace="${namespace}" --selector=${zookeeper_selector} --no-headers | grep cortx-zookeeper-headless)

if [[ ${num_items} -eq ${count} ]]; then
msg_overall_passed
Expand All @@ -1048,31 +1041,27 @@ num_pvs_pvcs=$(( num_replicas * 2 ))
msg_info "| Checking Storage: Local [PVCs/PVs] |"
while IFS= read -r line; do
IFS=" " read -r -a status <<< "${line}"
if [[ "${status[0]}" != "" ]]; then
printf "PVC: %s..." "${status[0]}"
if [[ "${status[1]}" != "Bound" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
printf "PVC: %s..." "${status[0]}"
if [[ "${status[1]}" != "Bound" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
done < <(kubectl get pvc --namespace="${namespace}" | grep 'zookeeper-')
done < <(kubectl get pvc --namespace="${namespace}" --selector=${zookeeper_selector} --no-headers)

while IFS= read -r line; do
IFS=" " read -r -a status <<< "${line}"
if [[ "${status[0]}" != "" ]]; then
printf "PV: %s..." "${status[5]}"
if [[ "${status[4]}" != "Bound" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
printf "PV: %s..." "${status[5]}"
if [[ "${status[4]}" != "Bound" ]]; then
msg_failed
failcount=$((failcount+1))
else
msg_passed
count=$((count+1))
fi
done < <(kubectl get pv | grep 'zookeeper-')
done < <(kubectl get pv --no-headers | grep "${namespace}/data-.*zookeeper-")

if [[ ${num_pvs_pvcs} -eq ${count} ]]; then
msg_overall_passed
Expand Down