mirror of
https://github.com/coreos/prometheus-operator.git
synced 2026-02-05 06:45:27 +01:00
format: Introduce shellcheck [1] for shell script analysis
[1] https://github.com/koalaman/shellcheck
This commit is contained in:
@@ -9,7 +9,7 @@ set -o xtrace
|
||||
HELM_URL=https://storage.googleapis.com/kubernetes-helm
|
||||
HELM_TARBALL=helm-v2.7.2-linux-amd64.tar.gz
|
||||
NAMESPACE="helm-monitoring"
|
||||
CUR_DIR=$(dirname "$BASH_SOURCE")
|
||||
CUR_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||
wget -q ${HELM_URL}/${HELM_TARBALL}
|
||||
tar xzfv ${HELM_TARBALL}
|
||||
|
||||
@@ -22,23 +22,23 @@ kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceac
|
||||
helm init --service-account tiller --upgrade
|
||||
|
||||
# wait until all minkube pods, including tiller, are in reading state
|
||||
$(dirname "$BASH_SOURCE")/wait-pods-running-state.sh kube-system
|
||||
"${CUR_DIR}"/wait-pods-running-state.sh kube-system
|
||||
|
||||
kubectl create ns ${NAMESPACE}
|
||||
|
||||
# replace current http repository to the helm path
|
||||
sed -ie 's/ repository/# repository/g' $(pwd)/helm/*/requirements.yaml
|
||||
sed -ie 's/#e2e-repository/repository/g' $(pwd)/helm/*/requirements.yaml
|
||||
sed -ie 's/ repository/# repository/g' "$(pwd)"/helm/*/requirements.yaml
|
||||
sed -ie 's/#e2e-repository/repository/g' "$(pwd)"/helm/*/requirements.yaml
|
||||
|
||||
# package charts and install all
|
||||
$(dirname "$BASH_SOURCE")/helm-package.sh prometheus-operator
|
||||
$(dirname "$BASH_SOURCE")/helm-package.sh kube-prometheus
|
||||
# package charts and install all
|
||||
"${CUR_DIR}"/helm-package.sh prometheus-operator
|
||||
"${CUR_DIR}"/helm-package.sh kube-prometheus
|
||||
|
||||
helm install --namespace=${NAMESPACE} $(pwd)/helm/prometheus-operator --name prometheus-operator
|
||||
helm install --namespace=${NAMESPACE} $(pwd)/helm/kube-prometheus --name kube-prometheus
|
||||
helm install --namespace="${NAMESPACE}" "$(pwd)/helm/prometheus-operator" --name prometheus-operator
|
||||
helm install --namespace="${NAMESPACE}" "$(pwd)/helm/kube-prometheus" --name kube-prometheus
|
||||
|
||||
# check if all pods are ready
|
||||
$(dirname "$BASH_SOURCE")/wait-pods-running-state.sh ${NAMESPACE}
|
||||
"${CUR_DIR}"/wait-pods-running-state.sh ${NAMESPACE}
|
||||
|
||||
# reset helm changes
|
||||
git reset --hard
|
||||
git reset --hard
|
||||
|
||||
@@ -17,24 +17,26 @@ HELM_INDEX="${HELM_CHARTS_PACKAGED_DIR}/index.yaml"
|
||||
|
||||
wget ${HELM_URL}/${HELM_TARBALL}
|
||||
tar xzfv ${HELM_TARBALL}
|
||||
export PATH=${PATH}:$(pwd)/linux-amd64/
|
||||
PATH=${PATH}:$(pwd)/linux-amd64/
|
||||
export PATH
|
||||
|
||||
# Clean up tarball
|
||||
rm -f ${HELM_TARBALL}
|
||||
|
||||
# Package helm and dependencies
|
||||
mkdir -p ${HELM_CHARTS_PACKAGED_DIR}
|
||||
mkdir -p "${HELM_CHARTS_PACKAGED_DIR}"
|
||||
helm init --client-only
|
||||
helm repo add ${HELM_BUCKET_NAME} ${HELM_REPO_URL}
|
||||
|
||||
# check if charts has dependencies,
|
||||
for chart in ${HELM_PACKAGES}
|
||||
do
|
||||
# # update dependencies before package the chart
|
||||
cd ${HELM_CHARTS_DIRECTORY}/${chart}
|
||||
helm dep update
|
||||
helm package . -d ${HELM_CHARTS_PACKAGED_DIR}
|
||||
cd -
|
||||
do
|
||||
(
|
||||
# update dependencies before package the chart
|
||||
cd "${HELM_CHARTS_DIRECTORY}/${chart}"
|
||||
helm dep update
|
||||
helm package . -d "${HELM_CHARTS_PACKAGED_DIR}"
|
||||
)
|
||||
done
|
||||
|
||||
# donwload the current remote index.yaml
|
||||
@@ -42,4 +44,4 @@ if [ ! -f "${HELM_INDEX}" ]; then
|
||||
wget ${HELM_REPO_URL}index.yaml -O "${HELM_INDEX}"
|
||||
fi
|
||||
|
||||
helm repo index ${HELM_CHARTS_PACKAGED_DIR} --url ${HELM_REPO_URL} --debug --merge ${HELM_INDEX}
|
||||
helm repo index "${HELM_CHARTS_PACKAGED_DIR}" --url "${HELM_REPO_URL}" --debug --merge "${HELM_INDEX}"
|
||||
|
||||
@@ -6,18 +6,17 @@ set -o xtrace
|
||||
HELM_BUCKET_NAME="coreos-charts"
|
||||
SYNC_TO_S3=${1:-"false"}
|
||||
HELM_CHARTS_PACKAGED_DIR=${2:-"/tmp/helm-packaged"}
|
||||
AWS_REGION=${3:-"eu-west-1"}
|
||||
|
||||
#Check if the current chart has the same hash from the remote one
|
||||
for tgz in $(ls ${HELM_CHARTS_PACKAGED_DIR})
|
||||
for tgz in "${HELM_CHARTS_PACKAGED_DIR}"/*
|
||||
do
|
||||
if echo "${tgz}" | grep -vq "kube-prometheus"
|
||||
then # if remote file doesn't exist we can skip the comparison
|
||||
status_code=$(curl -s -o /dev/null -w "%{http_code}" https://s3-eu-west-1.amazonaws.com/${HELM_BUCKET_NAME}/stable/${tgz})
|
||||
status_code=$(curl -s -o /dev/null -w "%{http_code}" "https://s3-eu-west-1.amazonaws.com/${HELM_BUCKET_NAME}/stable/${tgz}")
|
||||
if [ "$status_code" == "200" ]
|
||||
then
|
||||
cur_hash=$(md5sum ${HELM_CHARTS_PACKAGED_DIR}/${tgz} | awk '{print $1}' )
|
||||
remote_hash=$(curl -s https://s3-eu-west-1.amazonaws.com/${HELM_BUCKET_NAME}/stable/${tgz} | md5sum | awk '{print $1}')
|
||||
cur_hash=$(md5sum "${HELM_CHARTS_PACKAGED_DIR}/${tgz}" | awk '{print $1}' )
|
||||
remote_hash=$(curl -s "https://s3-eu-west-1.amazonaws.com/${HELM_BUCKET_NAME}/stable/${tgz}" | md5sum | awk '{print $1}')
|
||||
if [ "${tgz}" != "index.yaml" ] && [ "$cur_hash" != "$remote_hash" ]
|
||||
then
|
||||
echo "ERROR: Current hash should be the same as the remote hash. Please bump the version of chart {$tgz}."
|
||||
@@ -28,9 +27,9 @@ do
|
||||
done
|
||||
|
||||
# sync charts
|
||||
if [ ${SYNC_TO_S3} = true ]
|
||||
if [ "${SYNC_TO_S3}" = true ]
|
||||
then
|
||||
aws s3 sync --acl public-read ${HELM_CHARTS_PACKAGED_DIR} s3://${HELM_BUCKET_NAME}/stable/
|
||||
aws s3 sync --acl public-read "${HELM_CHARTS_PACKAGED_DIR}" "s3://${HELM_BUCKET_NAME}/stable/"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -11,14 +11,13 @@ set -o xtrace
|
||||
NAMESPACE=$1
|
||||
|
||||
# Ensure all pods in the namespace entered a Running state
|
||||
SUCCESS=0
|
||||
PODS_FOUND=0
|
||||
POD_RETRY_COUNT=0
|
||||
RETRY=60
|
||||
RETRY_DELAY=10
|
||||
while [ "$POD_RETRY_COUNT" -lt "$RETRY" ]; do
|
||||
POD_RETRY_COUNT=$((POD_RETRY_COUNT+1))
|
||||
POD_STATUS=`kubectl get pods --no-headers --namespace $NAMESPACE`
|
||||
POD_STATUS=$(kubectl get pods --no-headers --namespace "${NAMESPACE}")
|
||||
if [ -z "$POD_STATUS" ];then
|
||||
echo "INFO: No pods found for this release, retrying after sleep"
|
||||
POD_RETRY_COUNT=$((POD_RETRY_COUNT+1))
|
||||
@@ -34,8 +33,8 @@ while [ "$POD_RETRY_COUNT" -lt "$RETRY" ]; do
|
||||
|
||||
CONTAINER_RETRY_COUNT=0
|
||||
while [ "$CONTAINER_RETRY_COUNT" -lt "$RETRY" ]; do
|
||||
UNREADY_CONTAINERS=`kubectl get pods --namespace $NAMESPACE \
|
||||
-o jsonpath="{.items[*].status.containerStatuses[?(@.ready!=true)].name}"`
|
||||
UNREADY_CONTAINERS=$(kubectl get pods --namespace "${NAMESPACE}" \
|
||||
-o jsonpath="{.items[*].status.containerStatuses[?(@.ready!=true)].name}")
|
||||
if [ -n "$UNREADY_CONTAINERS" ];then
|
||||
echo "INFO: Some containers are not yet ready; retrying after sleep"
|
||||
CONTAINER_RETRY_COUNT=$((CONTAINER_RETRY_COUNT+1))
|
||||
|
||||
Reference in New Issue
Block a user