Skip to content

Commit 687df5c

Browse files
cosmo0920AndrewChubatiuk
authored andcommitted
filter_kubernetes: Provide for restoring behavior option for kublet TLS
Signed-off-by: Hiroshi Hatake <[email protected]>
1 parent 72b0785 commit 687df5c

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

plugins/filter_kubernetes/kube_conf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct flb_kube {
8080
int dummy_meta;
8181
int tls_debug;
8282
int tls_verify;
83+
int tls_verify_hostname;
8384
int kube_token_ttl;
8485
flb_sds_t meta_preload_cache_dir;
8586

plugins/filter_kubernetes/kube_meta.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,7 @@ static int wait_for_dns(struct flb_kube *ctx)
16811681

16821682
static int flb_kubelet_network_init(struct flb_kube *ctx, struct flb_config *config)
16831683
{
1684+
int ret;
16841685
int io_type = FLB_IO_TCP;
16851686
int api_https = FLB_TRUE;
16861687
ctx->kubelet_upstream = NULL;
@@ -1709,6 +1710,14 @@ static int flb_kubelet_network_init(struct flb_kube *ctx, struct flb_config *con
17091710
return -1;
17101711
}
17111712

1713+
if (ctx->tls_verify_hostname == FLB_TRUE) {
1714+
ret = flb_tls_set_verify_hostname(ctx->kubelet_tls, ctx->tls_verify_hostname);
1715+
if (ret == -1) {
1716+
flb_plg_debug(ctx->ins, "kubelet network tls set up failed for hostname verification");
1717+
return -1;
1718+
}
1719+
}
1720+
17121721
io_type = FLB_IO_TLS;
17131722
}
17141723

@@ -1726,12 +1735,13 @@ static int flb_kubelet_network_init(struct flb_kube *ctx, struct flb_config *con
17261735

17271736
/* Remove async flag from upstream */
17281737
flb_stream_disable_async_mode(&ctx->kubelet_upstream->base);
1729-
1738+
17301739
return 0;
17311740
}
17321741

17331742
static int flb_kube_network_init(struct flb_kube *ctx, struct flb_config *config)
17341743
{
1744+
int ret;
17351745
int io_type = FLB_IO_TCP;
17361746
int kubelet_network_init_ret = 0;
17371747

@@ -1753,6 +1763,14 @@ static int flb_kube_network_init(struct flb_kube *ctx, struct flb_config *config
17531763
return -1;
17541764
}
17551765

1766+
if (ctx->tls_verify_hostname == FLB_TRUE) {
1767+
ret = flb_tls_set_verify_hostname(ctx->tls, ctx->tls_verify_hostname);
1768+
if (ret == -1) {
1769+
flb_plg_debug(ctx->ins, "network tls set up failed for hostname verification");
1770+
return -1;
1771+
}
1772+
}
1773+
17561774
io_type = FLB_IO_TLS;
17571775
}
17581776

plugins/filter_kubernetes/kubernetes.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,13 @@ static struct flb_config_map config_map[] = {
800800
"set optional TLS virtual host"
801801
},
802802

803+
/* TLS: set tls.hostame_verification feature */
804+
{
805+
FLB_CONFIG_MAP_BOOL, "tls.verify_hostname", "off",
806+
0, FLB_TRUE, offsetof(struct flb_kube, tls_verify_hostname),
807+
"enable or disable to verify hostname"
808+
},
809+
803810
/* Merge structured record as independent keys */
804811
{
805812
FLB_CONFIG_MAP_BOOL, "merge_log", "false",

0 commit comments

Comments
 (0)