mirror of https://github.com/k3s-io/k3s
Use proxy instead of load balancer
parent
93c0052263
commit
72183c064c
|
@ -8,4 +8,3 @@ labels:
|
|||
kubernetes.io/cluster-service: "true"
|
||||
selector:
|
||||
name: elasticsearch-logging
|
||||
createExternalLoadBalancer: true
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
.PHONY: build push
|
||||
|
||||
TAG = 1.0
|
||||
TAG = 1.1
|
||||
|
||||
build:
|
||||
docker build -t kubernetes/kibana:$(TAG) .
|
||||
|
|
|
@ -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 <<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 "$@"
|
||||
|
|
|
@ -8,4 +8,3 @@ labels:
|
|||
kubernetes.io/cluster-service: "true"
|
||||
selector:
|
||||
name: kibana-logging
|
||||
createExternalLoadBalancer: true
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue