Skip to content

Commit

Permalink
Merge pull request #691 from 2456868764/mirror-local-env-setup
Browse files Browse the repository at this point in the history
add local env setup from mirror helm repo
  • Loading branch information
qmhu authored Feb 20, 2023
2 parents 3597bbf + ca0369f commit e658046
Showing 1 changed file with 60 additions and 10 deletions.
70 changes: 60 additions & 10 deletions hack/local-env-setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,88 @@ set -o errexit
set -o nounset
set -o pipefail

function help()
{
cat <<EOF
The crane local environment setup
Usage: local-env-setup.sh <[Options]>
Options:
-h --help help for setup
-m --mirror setup crane from helm mirror repo
EOF

}

FROM_MIRROR=false

while [ $# -gt 0 ]
do
case $1 in
-h|--help) help ; exit 1;;
-m|--mirror) FROM_MIRROR=true ;;
(-*) echo "$0: error - unrecognized option $1" 1>&2; help; exit 1;;
(*) break;;
esac
shift
done


CRANE_KUBECONFIG="${HOME}/.kube/config_crane"
CRANE_CLUSTER_NAME="crane"

PROMETHEUS_HELM_NAME="prometheus-community"
PROMETHEUS_HELM_URL="https://prometheus-community.github.io/helm-charts"
PROMETHEUS_VALUE_URL="https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml"
GRAFANA_HELM_NAME="grafana"
GRAFANA_HELM_URL="https://grafana.github.io/helm-charts"
GRAFANA_VALUE_URL="https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml"
CRANE_HELM_NAME="crane"
CRANE_HELM_URL="https://gocrane.github.io/helm-charts"

# check if setup is from mirror repo

if [ "$FROM_MIRROR" = true ]; then
PROMETHEUS_HELM_NAME="prometheus-community-gocrane"
PROMETHEUS_HELM_URL="https://finops-helm.pkg.coding.net/gocrane/prometheus-community"
PROMETHEUS_VALUE_URL="https://gitee.com/finops/helm-charts/raw/main/integration/prometheus/override_values.yaml"
GRAFANA_HELM_NAME="grafana-gocrane"
GRAFANA_HELM_URL="https://finops-helm.pkg.coding.net/gocrane/grafana"
GRAFANA_VALUE_URL="https://gitee.com/finops/helm-charts/raw/main/integration/grafana/override_values.yaml"
CRANE_HELM_NAME="crane-mirror"
CRANE_HELM_URL="https://finops-helm.pkg.coding.net/gocrane/gocrane"
fi

echo "Step1: Create local cluster: " ${CRANE_KUBECONFIG}
kind delete cluster --name="${CRANE_CLUSTER_NAME}" 2>&1
kind create cluster --kubeconfig "${CRANE_KUBECONFIG}" --name "${CRANE_CLUSTER_NAME}" --image kindest/node:v1.21.1
export KUBECONFIG="${CRANE_KUBECONFIG}"
echo "Step1: Create local cluster finished."

echo "Step2: Installing Prometheus "
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add ${PROMETHEUS_HELM_NAME} ${PROMETHEUS_HELM_URL}
helm install prometheus -n crane-system \
--set pushgateway.enabled=false \
--set prometheus-pushgateway.enabled=false \
--set alertmanager.enabled=false \
--set server.persistentVolume.enabled=false \
-f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/prometheus/override_values.yaml \
--create-namespace prometheus-community/prometheus
-f ${PROMETHEUS_VALUE_URL} \
--create-namespace ${PROMETHEUS_HELM_NAME}/prometheus
echo "Step2: Installing Prometheus finished."

echo "Step3: Installing Grafana "
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add ${GRAFANA_HELM_NAME} ${GRAFANA_HELM_URL}
helm install grafana \
-f https://raw.githubusercontent.com/gocrane/helm-charts/main/integration/grafana/override_values.yaml \
-f ${GRAFANA_VALUE_URL} \
-n crane-system \
--create-namespace grafana/grafana
--create-namespace ${GRAFANA_HELM_NAME}/grafana
echo "Step3: Installing Grafana finished."

echo "Step4: Installing Crane "
helm repo add crane https://gocrane.github.io/helm-charts
helm repo add ${CRANE_HELM_NAME} ${CRANE_HELM_URL}
helm repo update
helm install crane -n crane-system --set craneAgent.enable=false --create-namespace crane/crane
helm install fadvisor -n crane-system --create-namespace crane/fadvisor
helm install crane -n crane-system --set craneAgent.enable=false --create-namespace ${CRANE_HELM_NAME}/crane
helm install fadvisor -n crane-system --create-namespace ${CRANE_HELM_NAME}/fadvisor
echo "Step4: Installing Crane finished."

kubectl get deploy -n crane-system
Expand Down

0 comments on commit e658046

Please sign in to comment.