73 lines
2.9 KiB
Bash
Executable file
73 lines
2.9 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
echo ""
|
|
echo "... ] DEPLOYING MONITORING [ ..."
|
|
|
|
HOME=$( cd "$(dirname "$0")" && pwd )
|
|
source $HOME/config
|
|
|
|
if [ -f $HOME/config-coreapps ]; then
|
|
echo "config-coreapps file FOUND :)"
|
|
source $HOME/config-coreapps
|
|
export CEPH_MONITOR_1
|
|
export CEPH_MONITOR_2
|
|
export CEPH_MONITOR_3
|
|
else
|
|
echo "config-coreapps file is missing."
|
|
exit 1
|
|
fi
|
|
|
|
export KUBECONFIG=$ADMIN_KUBECONFIG
|
|
export HELM_CACHE_HOME=~/.cache/helm
|
|
export HELM_CONFIG_HOME=~/.config/helm
|
|
export HELM_DATA_HOME=~/.local/share/helm
|
|
|
|
kubectl create namespace monitoring
|
|
|
|
printf "\ndeploying zabbix-agent for host monitoring...\n"
|
|
kubectl -n monitoring create secret generic zabbix-psk-secret --from-literal=zabbix_agentd.psk=${ZABBIX_PSK}
|
|
kubectl -n monitoring create secret generic zabbix-psk-id-secret --from-literal=zabbix_psk_id=${ZABBIX_PSK_ID}
|
|
cat yaml/monitoring/zabbix-agent-daemonset.yaml | sed "s/k8x_zabbix_server/${ZABBIX_SERVER}/" | kubectl -n monitoring apply -f -
|
|
|
|
printf "\ndeploying prometheus for metrics aggregation...\n"
|
|
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
|
|
helm repo update
|
|
cat yaml/monitoring/prometheus-volumes.yaml | envsubst | kubectl apply -f -
|
|
helm install \
|
|
prometheus prometheus-community/prometheus \
|
|
--namespace monitoring \
|
|
-f yaml/monitoring/prometheus-values.yaml
|
|
|
|
printf "\ndeploying grafana for monitoring dashboard...\n"
|
|
helm repo add grafana https://grafana.github.io/helm-charts
|
|
helm repo update
|
|
cat yaml/monitoring/grafana-volumes.yaml | envsubst | kubectl apply -f -
|
|
helm install \
|
|
grafana grafana/grafana \
|
|
--namespace monitoring \
|
|
-f yaml/monitoring/grafana-values.yaml \
|
|
--set env.GF_SMTP_ENABLED=true,env.GF_SMTP_HOST=${GRAFANA_SMTP_HOST},env.GF_SMTP_FROM_ADDRESS=${GRAFANA_SMTP_FROM_ADDRESS},env.GF_SMTP_USER=${GRAFANA_SMTP_USER},env.GF_SMTP_PASSWORD=${GRAFANA_SMTP_PASSWORD},env.GF_SMTP_SKIP_VERIFY=true
|
|
printf '\ngrafana login:\nuser: admin \npass: ' ; kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
|
|
#kubectl -n monitoring create secret generic monitoring-http-secret --from-file=yaml/monitoring/auth
|
|
if $CERT_MODE; then
|
|
cat yaml/monitoring/grafana-cert.yaml | sed "s/k8x_domain/${CLUSTER_NAME}.${CLUSTER_DOMAIN}/" | kubectl -n monitoring apply -f -
|
|
cat yaml/monitoring/grafana-ingress-secure.yaml | sed "s/k8x_domain/${CLUSTER_NAME}.${CLUSTER_DOMAIN}/" | kubectl -n monitoring apply -f -
|
|
else
|
|
cat yaml/monitoring/grafana-ingress.yaml | sed "s/k8x_domain/${CLUSTER_NAME}.${CLUSTER_DOMAIN}/" | kubectl -n monitoring apply -f -
|
|
fi
|
|
|
|
exit 0
|
|
###
|
|
|
|
printf "\ndeploying loki for logs aggregation..."
|
|
cat yaml/monitoring/loki-volumes.yaml | envsubst | kubectl apply -f -
|
|
helm repo add loki https://grafana.github.io/loki/charts
|
|
helm repo update
|
|
helm install \
|
|
loki loki/loki \
|
|
--namespace monitoring \
|
|
-f yaml/monitoring/loki-values.yaml
|
|
helm install \
|
|
promtail loki/promtail \
|
|
--namespace monitoring \
|
|
--set "loki.serviceName=loki"
|