From 72183c064c3879639a2747b2f90707798d037e07 Mon Sep 17 00:00:00 2001 From: Satnam Singh Date: Mon, 2 Mar 2015 10:31:07 -0800 Subject: [PATCH] Use proxy instead of load balancer --- .../fluentd-elasticsearch/es-service.yaml | 1 - .../kibana-controller.yaml | 2 +- .../kibana-image/Makefile | 2 +- .../kibana-image/run_kibana_nginx.sh | 56 ++----------------- .../fluentd-elasticsearch/kibana-service.yaml | 1 - cluster/gce/util.sh | 7 +-- 6 files changed, 8 insertions(+), 61 deletions(-) diff --git a/cluster/addons/fluentd-elasticsearch/es-service.yaml b/cluster/addons/fluentd-elasticsearch/es-service.yaml index d3c9ef7a18bb4..3517768ac4c36 100644 --- a/cluster/addons/fluentd-elasticsearch/es-service.yaml +++ b/cluster/addons/fluentd-elasticsearch/es-service.yaml @@ -8,4 +8,3 @@ labels: kubernetes.io/cluster-service: "true" selector: name: elasticsearch-logging -createExternalLoadBalancer: true diff --git a/cluster/addons/fluentd-elasticsearch/kibana-controller.yaml b/cluster/addons/fluentd-elasticsearch/kibana-controller.yaml index dfd7adc7a3295..229fd35970b8e 100644 --- a/cluster/addons/fluentd-elasticsearch/kibana-controller.yaml +++ b/cluster/addons/fluentd-elasticsearch/kibana-controller.yaml @@ -12,7 +12,7 @@ desiredState: id: kibana-viewer containers: - name: kibana-logging - image: kubernetes/kibana:1.0 + image: kubernetes/kibana:1.1 ports: - name: kibana-port containerPort: 80 diff --git a/cluster/addons/fluentd-elasticsearch/kibana-image/Makefile b/cluster/addons/fluentd-elasticsearch/kibana-image/Makefile index 66bba0e8dd989..0cfc8b47e95d4 100755 --- a/cluster/addons/fluentd-elasticsearch/kibana-image/Makefile +++ b/cluster/addons/fluentd-elasticsearch/kibana-image/Makefile @@ -1,6 +1,6 @@ .PHONY: build push -TAG = 1.0 +TAG = 1.1 build: docker build -t kubernetes/kibana:$(TAG) . diff --git a/cluster/addons/fluentd-elasticsearch/kibana-image/run_kibana_nginx.sh b/cluster/addons/fluentd-elasticsearch/kibana-image/run_kibana_nginx.sh index 873b939a5eb4e..d66642507b82d 100755 --- a/cluster/addons/fluentd-elasticsearch/kibana-image/run_kibana_nginx.sh +++ b/cluster/addons/fluentd-elasticsearch/kibana-image/run_kibana_nginx.sh @@ -43,28 +43,6 @@ set -o errexit set -o nounset set -o pipefail -# Report all environment variables containing 'elasticsearch' -set | grep -i elasticsearch -# Set the default value for the Elasticsearch host as seen by the client -# Javascript code for Kibana. -: ${ES_HOST:='"+window.location.hostname+"'} -echo ES_HOST=$ES_HOST -# Set the default port for Elasticsearch host as seen by the client -# Javascript for Kibana. -: ${ES_PORT:=5601} -echo ES_PORT=$ES_PORT -# Set the default host IP and port for Elasticsearch as seen by the proxy -# code in the configuration for nginx. If a Kubernetes Elasticsearch -# service called 'elasticsearch' is defined, use that. Otherwise, use -# a local instance of Elasticsearch on port 9200. -PROXY_HOST=${ELASTICSEARCH_LOGGING_SERVICE_HOST:-127.0.0.1} -echo PROXY_HOST=${PROXY_HOST} -PROXY_PORT=${ELASTICSEARCH_SERVICE_LOGGING_PORT:-9200} -echo PROXY_PORT=${PROXY_PORT} - -# Create a config.hs that defines the Elasticsearch server to be -# at http://${ES_HOST}:${ES_PORT}/elasticsearch from the perspective of -# the client Javascript code. cat << EOF > /usr/share/nginx/html/config.js /** @scratch /configuration/config.js/1 * @@ -97,7 +75,10 @@ function (Settings) { * +elasticsearch: {server: "http://localhost:9200", withCredentials: true}+ * */ - elasticsearch: "http://${ES_HOST}:${ES_PORT}/elasticsearch", + + + elasticsearch: "https://"+window.location.hostname+"/api/v1beta1/proxy/services/elasticsearch-logging", + /** @scratch /configuration/config.js/5 * @@ -148,33 +129,4 @@ function (Settings) { }); EOF -# Proxy all calls to ...:80/elasticsearch to the location -# defined by http://${PROXY_HOST}:${PROXY_PORT} -cat < /etc/nginx/sites-available/default -server { - listen 80 default_server; - listen [::]:80 default_server ipv6only=on; - - root /usr/share/nginx/html; - index index.html index.htm; - - # Make site accessible from http://localhost/ - server_name localhost; - - location ~ /elasticsearch/?(.*)$ { - proxy_http_version 1.1; - proxy_set_header Upgrade \$http_upgrade; - proxy_read_timeout 1d; - proxy_set_header Connection "upgrade"; - proxy_pass http://${PROXY_HOST}:${PROXY_PORT}/\$1; - } - - location / { - # First attempt to serve request as file, then - # as directory, then fall back to displaying a 404. - try_files \$uri \$uri/ =404; - } -} -EOF - exec nginx -c /etc/nginx/nginx.conf "$@" diff --git a/cluster/addons/fluentd-elasticsearch/kibana-service.yaml b/cluster/addons/fluentd-elasticsearch/kibana-service.yaml index dd1442b1aed35..346f13a9cfc16 100644 --- a/cluster/addons/fluentd-elasticsearch/kibana-service.yaml +++ b/cluster/addons/fluentd-elasticsearch/kibana-service.yaml @@ -8,4 +8,3 @@ labels: kubernetes.io/cluster-service: "true" selector: name: kibana-logging -createExternalLoadBalancer: true diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 86cfbba3ba29b..ba64fa4b3ea16 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -898,12 +898,9 @@ function setup-logging-firewall { sleep 10 done - local -r region="${ZONE:0:${#ZONE}-2}" - local -r es_ip=$(gcloud compute forwarding-rules --project "${PROJECT}" describe --region "${region}" "${INSTANCE_PREFIX}"-elasticsearch-logging | grep IPAddress | awk '{print $2}') - local -r kibana_ip=$(gcloud compute forwarding-rules --project "${PROJECT}" describe --region "${region}" "${INSTANCE_PREFIX}"-kibana-logging | grep IPAddress | awk '{print $2}') echo - echo -e "${color_green}Cluster logs are ingested into Elasticsearch running at ${color_yellow}http://${es_ip}:9200" - echo -e "${color_green}Kibana logging dashboard will be available at ${color_yellow}http://${kibana_ip}:5601${color_norm}" + echo -e "${color_green}Cluster logs are ingested into Elasticsearch running at ${color_yellow}https://https://${KUBE_MASTER_IP}/api/v1beta1/proxy/services/elasticsearch-logging/" + echo -e "${color_green}Kibana logging dashboard will be available at ${color_yellow}https://${KUBE_MASTER_IP}/api/v1beta1/proxy/services/kibana-logging/${color_norm} (note the trailing slash)" echo }