Skip to content

Commit

Permalink
filter_kubernetes: register metadata
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
edsiper committed Oct 22, 2021
1 parent c130edb commit b8de477
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions plugins/filter_kubernetes/kube_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <fluent-bit/flb_upstream.h>
#include <fluent-bit/flb_http_client.h>
#include <fluent-bit/flb_pack.h>
#include <fluent-bit/flb_env.h>
#include <fluent-bit/tls/flb_tls.h>

#include <sys/types.h>
Expand Down Expand Up @@ -229,6 +230,23 @@ static int refresh_token_if_needed(struct flb_kube *ctx)
return 0;
}

static void expose_k8s_meta(struct flb_kube *ctx)
{
char *tmp;
struct flb_env *env;

env = ctx->config->env;

flb_env_set(env, "k8s", "enabled");
flb_env_set(env, "k8s.namespace", ctx->namespace);
flb_env_set(env, "k8s.pod_name", ctx->podname);

tmp = (char *) flb_env_get(env, "NODE_NAME");
if (tmp) {
flb_env_set(env, "k8s.node_name", tmp);
}
}

/* Load local information from a POD context */
static int get_local_pod_info(struct flb_kube *ctx)
{
Expand Down Expand Up @@ -273,6 +291,7 @@ static int get_local_pod_info(struct flb_kube *ctx)
return FLB_FALSE;
}

expose_k8s_meta(ctx);
return FLB_TRUE;
}

Expand Down

0 comments on commit b8de477

Please sign in to comment.