Skip to content

Commit

Permalink
Merge pull request kubernetes#4959 from satnam6502/proxy
Browse files Browse the repository at this point in the history
Use proxy instead of load balancer for Elasticsearch and Kibana
  • Loading branch information
lavalamp committed Mar 2, 2015
2 parents 167d1b7 + 72183c0 commit f278fba
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 61 deletions.
1 change: 0 additions & 1 deletion cluster/addons/fluentd-elasticsearch/es-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ labels:
kubernetes.io/cluster-service: "true"
selector:
name: elasticsearch-logging
createExternalLoadBalancer: true
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cluster/addons/fluentd-elasticsearch/kibana-image/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: build push

TAG = 1.0
TAG = 1.1

build:
docker build -t kubernetes/kibana:$(TAG) .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -148,33 +129,4 @@ function (Settings) {
});
EOF

# Proxy all calls to ...:80/elasticsearch to the location
# defined by http://${PROXY_HOST}:${PROXY_PORT}
cat <<EOF > /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 "$@"
1 change: 0 additions & 1 deletion cluster/addons/fluentd-elasticsearch/kibana-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ labels:
kubernetes.io/cluster-service: "true"
selector:
name: kibana-logging
createExternalLoadBalancer: true
7 changes: 2 additions & 5 deletions cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit f278fba

Please sign in to comment.