Skip to content

Commit

Permalink
Merge pull request #85 from port-labs/PORT-5997-k-8-s-installation-te…
Browse files Browse the repository at this point in the history
…mplate-does-not-support-event-listener-type-as-parameter

updated installation command to include the evnet listener type
  • Loading branch information
yairsimantov20 authored Jan 7, 2024
2 parents f636c2e + 12bd875 commit 7884a48
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions kubernetes/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ TARGET_NAMESPACE=${TARGET_NAMESPACE:-"port-k8s-exporter"}
DEPLOYMENT_NAME=${DEPLOYMENT_NAME:-"port-k8s-exporter"}
CLUSTER_NAME=${CLUSTER_NAME:-"my-cluster"}

# Event listener variables
EVENT_LISTENER_TYPE=${EVENT_LISTENER_TYPE:-"POLLING"}

if [[ "${EVENT_LISTENER_TYPE}" != "POLLING" ]] && [[ "${EVENT_LISTENER_TYPE}" != "KAFKA" ]]; then
echo "Invalid event listener type: '${EVENT_LISTENER_TYPE}'. Valid types are: 'POLLING' or 'KAFKA'."
exit 1
fi

# Polling event listener variables
EVENT_LISTENER_POLLING_RATE=${EVENT_LISTENER_POLLING_RATE:-}

# Kafka event listener variables
EVENT_LISTENER_KAFKA_BROKERS=${EVENT_LISTENER_KAFKA_BROKERS:-}
EVENT_LISTENER_KAFKA_SECURITY_PROTOCOL=${EVENT_LISTENER_KAFKA_SECURITY_PROTOCOL:-}
EVENT_LISTENER_KAFKA_AUTHENTICATION_MECHANISM=${EVENT_LISTENER_KAFKA_AUTHENTICATION_MECHANISM:-}

function cleanup {
rm -rf "${temp_dir}"
}
Expand Down Expand Up @@ -124,14 +140,33 @@ echo "*** The cluster will be referenced as '${CLUSTER_NAME}' in your Port Envir
echo ""
echo "The exporter will be deployed to namespace: '${TARGET_NAMESPACE}', under the deployment name '${DEPLOYMENT_NAME}'."
echo ""
helm upgrade --install ${DEPLOYMENT_NAME} ${HELM_REPO_NAME}/${HELM_K8S_CHART_NAME} \
helm_upgrade_command="helm upgrade --install ${DEPLOYMENT_NAME} ${HELM_REPO_NAME}/${HELM_K8S_CHART_NAME} \
--create-namespace --namespace ${TARGET_NAMESPACE} \
--set secret.secrets.portClientId=${PORT_CLIENT_ID} --set secret.secrets.portClientSecret=${PORT_CLIENT_SECRET} \
--set createDefaultResources=false \
--set-file configMap.config=${temp_dir}/template_config.yaml \
--set extraEnv[0].name=CLUSTER_NAME \
--set extraEnv[0].value=${CLUSTER_NAME} \
--set stateKey=${CLUSTER_NAME}
--set stateKey=${CLUSTER_NAME} \
--set eventListener.type=${EVENT_LISTENER_TYPE}"

if [ -n "${EVENT_LISTENER_KAFKA_BROKERS}" ]; then
helm_upgrade_command="${helm_upgrade_command} --set eventListener.brokers=${EVENT_LISTENER_KAFKA_BROKERS}"
fi

if [ -n "${EVENT_LISTENER_KAFKA_SECURITY_PROTOCOL}" ]; then
helm_upgrade_command="${helm_upgrade_command} --set eventListener.securityProtocol=${EVENT_LISTENER_KAFKA_SECURITY_PROTOCOL}"
fi

if [ -n "${EVENT_LISTENER_KAFKA_AUTHENTICATION_MECHANISM}" ]; then
helm_upgrade_command="${helm_upgrade_command} --set eventListener.authenticationMechanism=${EVENT_LISTENER_KAFKA_AUTHENTICATION_MECHANISM}"
fi

if [ -n "${EVENT_LISTENER_POLLING_RATE}" ]; then
helm_upgrade_command="${helm_upgrade_command} --set eventListener.pollingRate=${EVENT_LISTENER_POLLING_RATE}"
fi

eval "${helm_upgrade_command}"
echo ""

echo "Finished installation!"
Expand Down

0 comments on commit 7884a48

Please sign in to comment.