Skip to content
Closed
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
24 changes: 15 additions & 9 deletions kind/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ aarch64* | arm64*)
;;
esac

# check os
if [[ "$OSTYPE" == "darwin"* ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know sed on mac has different behaviors with linux. hence if the change is not impact with linux(for our CI), it looks go to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it won't affect other Linux distributions

SED="gsed"
else
SED="sed"
fi
function _get_prometheus_operator_images {
grep -R "image:" kube-prometheus/manifests/*prometheus-* | awk '{print $3}'
grep -R "image:" kube-prometheus/manifests/*prometheusOperator* | awk '{print $3}'
grep -R "prometheus-config-reloader=" kube-prometheus/manifests/ | sed 's/.*=//g'
if [ ${GRAFANA_ENABLE,,} == "true" ]; then
if [ ${GRAFANA_ENABLE} == "true" ] || [ ${GRAFANA_ENABLE} == "True" ] ; then
grep -R "image:" kube-prometheus/manifests/*grafana* | awk '{print $3}'
fi
}
Expand All @@ -83,7 +89,7 @@ function _load_prometheus_operator_images_to_local_registry {

function _deploy_prometheus_operator {
git clone -b ${PROMETHEUS_OPERATOR_VERSION} --depth 1 https://github.com/prometheus-operator/kube-prometheus.git
sed -i -e "s/replicas: 2/replicas: ${PROMETHEUS_REPLICAS}/g" kube-prometheus/manifests/prometheus-prometheus.yaml
$SED -i -e "s/replicas: 2/replicas: ${PROMETHEUS_REPLICAS}/g" kube-prometheus/manifests/prometheus-prometheus.yaml
_load_prometheus_operator_images_to_local_registry
kubectl create -f kube-prometheus/manifests/setup
kubectl wait \
Expand All @@ -96,7 +102,7 @@ function _deploy_prometheus_operator {
for file in $(ls kube-prometheus/manifests/prometheus-*); do
kubectl create -f $file
done
if [ ${GRAFANA_ENABLE,,} == "true" ]; then
if [ ${GRAFANA_ENABLE} == "true" ] || [ ${GRAFANA_ENABLE} == "True" ]; then
for file in $(ls kube-prometheus/manifests/grafana-*); do
kubectl create -f $file
done
Expand Down Expand Up @@ -126,7 +132,7 @@ function _fetch_kind() {
mkdir -p ${KIND_DIR}
KIND="${KIND_DIR}"/.kind
if [ -f $KIND ]; then
current_kind_version=$($KIND --version |& awk '{print $3}')
current_kind_version=$($KIND --version | awk '{print $3}')
fi
if [[ $current_kind_version != $KIND_VERSION ]]; then
echo "Downloading kind v$KIND_VERSION"
Expand Down Expand Up @@ -162,12 +168,12 @@ function _prepare_config() {
echo "Building manifests..."

cp $KIND_MANIFESTS_DIR/kind.yml ${KIND_DIR}/kind.yml
sed -i -e "s/$_registry_name/${REGISTRY_NAME}/g" ${KIND_DIR}/kind.yml
sed -i -e "s/$_registry_port/${REGISTRY_PORT}/g" ${KIND_DIR}/kind.yml
$SED -i -e "s/$_registry_name/${REGISTRY_NAME}/g" ${KIND_DIR}/kind.yml
$SED -i -e "s/$_registry_port/${REGISTRY_PORT}/g" ${KIND_DIR}/kind.yml

cp $KIND_MANIFESTS_DIR/local-registry.yml ${KIND_DIR}/local-registry.yml
sed -i -e "s/$_registry_name/${REGISTRY_NAME}/g" ${KIND_DIR}/local-registry.yml
sed -i -e "s/$_registry_port/${REGISTRY_PORT}/g" ${KIND_DIR}/local-registry.yml
$SED -i -e "s/$_registry_name/${REGISTRY_NAME}/g" ${KIND_DIR}/local-registry.yml
$SED -i -e "s/$_registry_port/${REGISTRY_PORT}/g" ${KIND_DIR}/local-registry.yml

}

Expand Down Expand Up @@ -198,7 +204,7 @@ function _setup_kind() {
_wait_containers_ready kube-system
_run_registry

if [ ${PROMETHEUS_ENABLE,,} == "true" ]; then
if [ ${PROMETHEUS_ENABLE} == "true" ] || [ ${PROMETHEUS_ENABLE} == "True" ]; then
_deploy_prometheus_operator
fi
}
Expand Down