filter_kubernetes: register metadata
#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>
@@ -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)
{
@@ -273,6 +291,7 @@ static int get_local_pod_info(struct flb_kube *ctx)
return FLB_FALSE;
}
+ expose_k8s_meta(ctx);
return FLB_TRUE;
}
