Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dashboard-metrics-scraper on development container #4046

Merged
merged 1 commit into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,3 @@ coverage/
# npm debug log:
npm-debug.log

# kubeconfig for cluster made by kind:
kind.kubeconfig*
maciaszczykm marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ kubernetes-dashboard:frontend_build_dir = dist/frontend/en
kubernetes-dashboard:dashboard_binary_path = dist/amd64/dashboard
kubernetes-dashboard:dashboard_locale_config = dist/amd64/locale_conf.json
kubernetes-dashboard:bind_address = 127.0.0.1
kubernetes-dashboard:sidecar_host = http://localhost:8000
5 changes: 5 additions & 0 deletions aio/develop/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ RUN curl -sSL https://download.docker.com/linux/static/stable/x86_64/docker-18.0
rm -rf /tmp/docker/ && \
chmod +x /usr/bin/docker

# Install kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl

# Install golangci for ckecking or fixing go format.
# `npm ci` installs golangci, but this installation is needed
# for running `npm run check` singlely, like
Expand Down
25 changes: 18 additions & 7 deletions aio/develop/npm-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
if [[ -n "${K8S_DASHBOARD_NPM_CMD}" ]] ; then
# Run npm command
echo "Run npm '${K8S_DASHBOARD_NPM_CMD}'"
npm ${K8S_DASHBOARD_NPM_CMD} --kubernetes-dashboard:bind_address=${K8S_DASHBOARD_BIND_ADDRESS}
npm ${K8S_DASHBOARD_NPM_CMD} \
--kubernetes-dashboard:bind_address=${K8S_DASHBOARD_BIND_ADDRESS} \
--kubernetes-dashboard:sidecar_host=${K8S_DASHBOARD_SIDECAR_HOST}
else
# Install dashboard.
echo "Install dashboard"
Expand All @@ -32,16 +34,25 @@ else
echo "Start cluster"
sudo npm run cluster:start
# Copy kubeconfig from /root/.kube/config
sudo cat /root/.kube/config > kind.kubeconfig
sudo chown ${LOCAL_UID}:${LOCAL_GID} kind.kubeconfig
sudo cat /root/.kube/config > /tmp/kind.kubeconfig
sudo chown ${LOCAL_UID}:${LOCAL_GID} /tmp/kind.kubeconfig
# Edit kubeconfig for kind
KIND_CONTAINER_NAME="k8s-cluster-ci-control-plane"
KIND_ADDR=$(sudo docker inspect -f='{{.NetworkSettings.IPAddress}}' ${KIND_CONTAINER_NAME})
sed -e "s/localhost:[0-9]\+/${KIND_ADDR}:6443/g" kind.kubeconfig > kind.kubeconfig.new
cat kind.kubeconfig.new > kind.kubeconfig
rm -f kind.kubeconfig.new
sed -e "s/localhost:[0-9]\+/${KIND_ADDR}:6443/g" /tmp/kind.kubeconfig > ~/.kube/config
# Deploy recommended.yaml to deploy dashboard-metrics-scraper sidecar
echo "Deploy dashboard-metrics-scraper into kind cluster"
kubectl apply -f aio/deploy/recommended.yaml
# Kill and run `kubectl proxy`
KUBECTL_PID=$(ps -A|grep 'kubectl'|tr -s ' '|cut -d ' ' -f 2)
echo "Kill kubectl ${KUBECTL_PID}"
kill ${KUBECTL_PID}
nohup kubectl proxy --address 127.0.0.1 --port 8000 >/tmp/kubeproxy.log 2>&1 &
export K8S_DASHBOARD_SIDECAR_HOST="http://localhost:8000/api/v1/namespaces/kubernetes-dashboard/services/dashboard-metrics-scraper:/proxy/"
fi
# Start dashboard.
echo "Start dashboard"
npm start --kubernetes-dashboard:bind_address=${K8S_DASHBOARD_BIND_ADDRESS}
npm start \
--kubernetes-dashboard:bind_address=${K8S_DASHBOARD_BIND_ADDRESS} \
--kubernetes-dashboard:sidecar_host=${K8S_DASHBOARD_SIDECAR_HOST}
fi
4 changes: 4 additions & 0 deletions aio/develop/run-npm-on-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ fi
# Bind addres for dashboard
K8S_DASHBOARD_BIND_ADDRESS=${K8S_DASHBOARD_BIND_ADDRESS:-"127.0.0.1"}

# Metrics Scraper sidecar host for dashboard
K8S_DASHBOARD_SIDECAR_HOST=${K8S_DASHBOARD_SIDECAR_HOST:-"http://localhost:8000"}

# Build and run container for dashboard
DASHBOARD_IMAGE_NAME=${K8S_DASHBOARD_CONTAINER_NAME:-"k8s-dashboard-dev-image"}
K8S_DASHBOARD_SRC=${K8S_DASHBOARD_SRC:-"${CD}"}
Expand Down Expand Up @@ -75,6 +78,7 @@ docker run \
-e K8S_DASHBOARD_CMD="${K8S_DASHBOARD_CMD}" \
-e K8S_OWN_CLUSTER=${K8S_OWN_CLUSTER} \
-e K8S_DASHBOARD_BIND_ADDRESS=${K8S_DASHBOARD_BIND_ADDRESS} \
-e K8S_DASHBOARD_SIDECAR_HOST=${K8S_DASHBOARD_SIDECAR_HOST} \
-e K8S_DASHBOARD_DEBUG=${K8S_DASHBOARD_DEBUG} \
-e LOCAL_UID="${LOCAL_UID}" \
-e LOCAL_GID="${LOCAL_GID}" \
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
},
"license": "Apache-2.0",
"scripts": {
"start": "concurrently \"npm run start:backend\" \"npm run start:frontend --kubernetes-dashboard:bind_address=$npm_package_config_bind_address\"",
"start": "concurrently \"npm run start:backend --kubernetes-dashboard:sidecar_host=$npm_package_config_sidecar_host\" \"npm run start:frontend --kubernetes-dashboard:bind_address=$npm_package_config_bind_address\"",
floreks marked this conversation as resolved.
Show resolved Hide resolved
"start:https": "concurrently \"npm run start:backend:https\" \"npm run start:frontend:https\"",
"start:frontend": "npm run postversion && ng serve --aot --progress=false --proxy-config aio/proxy.conf.json --host=$npm_package_config_bind_address",
"start:frontend:https": "node aio/scripts/version.js && ng serve --progress=false --aot --proxy-config aio/https-proxy.conf.json --ssl --host=$npm_package_config_bind_address",
"start:backend": "gulp serve --kubeconfig $npm_package_config_kubeconfig",
"start:backend:https": "gulp serve --kubeconfig $npm_package_config_kubeconfig --autoGenerateCerts true",
"start:prod": "npm run build && ./$npm_package_config_dashboard_binary_path --kubeconfig $npm_package_config_kubeconfig --locale-config $npm_package_config_dashboard_locale_config --auto-generate-certificates --bind-address $npm_package_config_bind_address",
"start:backend": "gulp serve --kubeconfig $npm_package_config_kubeconfig --sidecarServerHost $npm_package_config_sidecar_host",
"start:backend:https": "gulp serve --kubeconfig $npm_package_config_kubeconfig --autoGenerateCerts true --sidecarServerHost $npm_package_config_sidecar_host",
"start:prod": "npm run build && ./$npm_package_config_dashboard_binary_path --kubeconfig $npm_package_config_kubeconfig --locale-config $npm_package_config_dashboard_locale_config --auto-generate-certificates --bind-address $npm_package_config_bind_address --sidecar-host $npm_package_config_sidecar_host",
"build": "./aio/scripts/build.sh",
"build:cross": "./aio/scripts/build.sh -c",
"build:frontend": "npm run clean && ng build --aot --prod --outputPath=$npm_package_config_frontend_build_dir",
Expand Down