mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #85944 from SataQiu/fix-es-20191205
Addons: elasticsearch supports automatically setting the advertise address
This commit is contained in:
commit
a233e0115b
@ -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
|
||||
|
@ -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} .
|
||||
|
@ -9,4 +9,3 @@ http.port: ${HTTP_PORT}
|
||||
|
||||
path.data: /data
|
||||
|
||||
network.host: 0.0.0.0
|
||||
|
@ -19,6 +19,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -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)
|
||||
|
@ -51,7 +51,7 @@ 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
|
||||
@ -59,16 +59,16 @@ spec:
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user