Skip to content

Commit

Permalink
filter_kubernetes: Add ability to change kubelet_host
Browse files Browse the repository at this point in the history
Allow the user to set kubelet_host when use_kubelet is true.
Defaults to '127.0.0.1'.

Fixes #5143

Signed-off-by: Thomas Danielsson <thomas.danielsson@sharespine.com>
  • Loading branch information
tumd committed May 16, 2022
1 parent 39d4ddf commit 642f0fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugins/filter_kubernetes/kube_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct flb_kube *flb_kube_conf_create(struct flb_filter_instance *ins,
ctx->api_https = FLB_FALSE;
}
else if (ctx->use_kubelet) {
ctx->api_host = flb_strdup(FLB_KUBELET_HOST);
ctx->api_host = flb_strdup(ctx->kubelet_host);
ctx->api_port = ctx->kubelet_port;
ctx->api_https = FLB_TRUE;

Expand Down
4 changes: 1 addition & 3 deletions plugins/filter_kubernetes/kube_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@
#define FLB_API_PORT 443
#define FLB_API_TLS FLB_TRUE

/* Kubelet info */
#define FLB_KUBELET_HOST "127.0.0.1"

/*
* Default expected Kubernetes tag prefix, this is used mostly when source
* data comes from in_tail with custom tags like: kube.service.*
Expand Down Expand Up @@ -155,6 +152,7 @@ struct flb_kube {

int use_tag_for_meta;
int use_kubelet;
char *kubelet_host;
int kubelet_port;

int kube_meta_cache_ttl;
Expand Down
9 changes: 9 additions & 0 deletions plugins/filter_kubernetes/kubernetes.c
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,15 @@ static struct flb_config_map config_map[] = {
0, FLB_TRUE, offsetof(struct flb_kube, use_kubelet),
"use kubelet to get metadata instead of kube-server"
},
/*
* The kubelet host for /pods endpoint, default is 127.0.0.1
* Will only check when "use_kubelet" config is set to true
*/
{
FLB_CONFIG_MAP_STR, "kubelet_host", "127.0.0.1",
0, FLB_TRUE, offsetof(struct flb_kube, kubelet_host),
"kubelet host to connect with when using kubelet"
},
/*
* The kubelet port for /pods endpoint, default is 10250
* Will only check when "use_kubelet" config is set to true
Expand Down

0 comments on commit 642f0fa

Please sign in to comment.