Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ The fifth rule `add_kubernetes` generates new fields with kubernetes information
matching the `input` value (`srcIP` in the example above) with kubernetes `nodes`, `pods` and `services` IPs.
All the kubernetes fields will be named by appending `output` value
(`srcK8S` in the example above) to the kubernetes metadata field names
(e.g., `Namespace`, `Name`, `Type`, `OwnerName`, `OwnerType` )
(e.g., `Namespace`, `Name`, `Type`, `HostIP`, `OwnerName`, `OwnerType` )

In addition, if the `parameters` value is not empty, fields with kubernetes labels
will be generated, and named by appending `parameters` value to the label keys.
Expand Down
2 changes: 2 additions & 0 deletions pkg/pipeline/transform/kubernetes/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ type Info struct {
Labels map[string]string
OwnerReferences []metav1.OwnerReference
Owner Owner
HostIP string
}

func (k *KubeData) GetInfo(ip string) (*Info, error) {
Expand All @@ -78,6 +79,7 @@ func (k *KubeData) GetInfo(ip string) (*Info, error) {
Namespace: pod.Namespace,
Labels: pod.Labels,
OwnerReferences: pod.OwnerReferences,
HostIP: pod.Status.HostIP,
}
case typeNode:
node := objs[0].(*v1.Node)
Expand Down
3 changes: 2 additions & 1 deletion pkg/pipeline/transform/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type InformerInterface interface {
}

func (indexMock *IndexerMock) ByIndex(indexName, indexedValue string) ([]interface{}, error) {
pod := fakePod("podName", "podNamespace", "podHost")
pod := fakePod("podName", "podNamespace", "podHostIP")
podInterface := interface{}(pod)
return []interface{}{podInterface}, nil
}
Expand Down Expand Up @@ -77,6 +77,7 @@ func TestKubeData_getInfo(t *testing.T) {
Type: "Pod",
Name: "podName",
Namespace: "podNamespace",
HostIP: "podHostIP",
Owner: Owner{Name: "podName", Type: "Pod"},
}
kubeData = KubeData{ipInformers: map[string]cache.SharedIndexInformer{}}
Expand Down
3 changes: 3 additions & 0 deletions pkg/pipeline/transform/transform_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ func (n *Network) Transform(inputEntry config.GenericMap) config.GenericMap {
outputEntries[rule.Parameters+"_"+labelKey] = labelValue
}
}
if kubeInfo.HostIP != "" {
outputEntries[rule.Output+"_HostIP"] = kubeInfo.HostIP
}
default:
log.Panicf("unknown type %s for transform.Network rule: %v", rule.Type, rule)
}
Expand Down