Skip to content

Commit

Permalink
addons: elasticsearch supports automatically setting the advertise ad…
Browse files Browse the repository at this point in the history
…dress
  • Loading branch information
SataQiu committed Dec 14, 2019
1 parent b92d200 commit 09032be
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cluster/addons/fluentd-elasticsearch/es-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ COPY elasticsearch_logging_discovery.go go.mod go.sum /
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -ldflags "-w" -o /elasticsearch_logging_discovery /elasticsearch_logging_discovery.go


FROM docker.elastic.co/elasticsearch/elasticsearch-oss:7.3.2
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:7.4.2

VOLUME ["/data"]
EXPOSE 9200 9300
Expand Down
2 changes: 1 addition & 1 deletion cluster/addons/fluentd-elasticsearch/es-image/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

PREFIX = quay.io/fluentd_elasticsearch
IMAGE = elasticsearch
TAG = v7.3.2
TAG = v7.4.2

build:
docker build --tag ${PREFIX}/${IMAGE}:${TAG} .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ http.port: ${HTTP_PORT}

path.data: /data

network.host: 0.0.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"flag"
"fmt"
"net"
"os"
"strconv"
"strings"
Expand Down Expand Up @@ -63,11 +64,32 @@ func flattenSubsets(subsets []corev1.EndpointSubset) []string {
return ips
}

func getAdvertiseAddress() (string, error) {
addrs, err := net.InterfaceAddrs()
if err != nil {
return "", err
}

for _, addr := range addrs {
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
return ipnet.IP.String(), nil
}
}

return "", fmt.Errorf("no non-loopback address is available")
}

func main() {
flag.Parse()

klog.Info("Kubernetes Elasticsearch logging discovery")

advertiseAddress, err := getAdvertiseAddress()
if err != nil {
klog.Fatalf("Failed to get valid advertise address: %v", err)
}
fmt.Printf("network.host: \"%s\"\n\n", advertiseAddress)

cc, err := buildConfigFromEnvs(os.Getenv("APISERVER_HOST"), os.Getenv("KUBE_CONFIG_FILE"))
if err != nil {
klog.Fatalf("Failed to make client: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions cluster/addons/fluentd-elasticsearch/es-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@ metadata:
namespace: kube-system
labels:
k8s-app: elasticsearch-logging
version: v7.3.2
version: v7.4.2
addonmanager.kubernetes.io/mode: Reconcile
spec:
serviceName: elasticsearch-logging
replicas: 2
selector:
matchLabels:
k8s-app: elasticsearch-logging
version: v7.3.2
version: v7.4.2
template:
metadata:
labels:
k8s-app: elasticsearch-logging
version: v7.3.2
version: v7.4.2
spec:
serviceAccountName: elasticsearch-logging
containers:
- image: quay.io/fluentd_elasticsearch/elasticsearch:v7.3.2
- image: quay.io/fluentd_elasticsearch/elasticsearch:v7.4.2
name: elasticsearch-logging
imagePullPolicy: Always
resources:
Expand Down

0 comments on commit 09032be

Please sign in to comment.