mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
es discovery support args apiserver-host and kubeconfig
This commit is contained in:
parent
bcccbc3d0b
commit
b0c57c081e
@ -16,7 +16,7 @@
|
||||
|
||||
# The current value of the tag to be used for building and
|
||||
# pushing an image to gcr.io
|
||||
TAG = v5.4.0
|
||||
TAG = v5.4.0-1
|
||||
|
||||
build: elasticsearch_logging_discovery
|
||||
docker build --pull -t gcr.io/google_containers/elasticsearch:$(TAG) .
|
||||
|
@ -26,10 +26,27 @@ import (
|
||||
"github.com/golang/glog"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
clientapi "k8s.io/client-go/tools/clientcmd/api"
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
)
|
||||
|
||||
func buildConfigFromEnvs(masterURL, kubeconfigPath string) (*restclient.Config, error) {
|
||||
if kubeconfigPath == "" && masterURL == "" {
|
||||
kubeconfig, err := restclient.InClusterConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return kubeconfig, nil
|
||||
}
|
||||
|
||||
return clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
|
||||
&clientcmd.ClientConfigLoadingRules{ExplicitPath: kubeconfigPath},
|
||||
&clientcmd.ConfigOverrides{ClusterInfo: clientapi.Cluster{Server: masterURL}}).ClientConfig()
|
||||
}
|
||||
|
||||
func flattenSubsets(subsets []api.EndpointSubset) []string {
|
||||
ips := []string{}
|
||||
for _, ss := range subsets {
|
||||
@ -42,9 +59,10 @@ func flattenSubsets(subsets []api.EndpointSubset) []string {
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
glog.Info("Kubernetes Elasticsearch logging discovery")
|
||||
|
||||
cc, err := restclient.InClusterConfig()
|
||||
cc, err := buildConfigFromEnvs(os.Getenv("APISERVER_HOST"), os.Getenv("KUBE_CONFIG_FILE"))
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to make client: %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user