Skip to content
This repository was archived by the owner on Jan 16, 2023. It is now read-only.

Commit 746c3d9

Browse files
author
Jeremy Tang
committed
Merge pull request #15 in DEV/k8s-argus from DEV-47062-add-distinguishing-property-to to develop
* commit 'd65374e91f1b332ba3749e7144addf7ebe23ba62': DEV-47062 Add distinguishing property to host network pods
2 parents 1d790d0 + d65374e commit 746c3d9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

pkg/device/builder/builder.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ func (b *Builder) System(name, value string) types.DeviceOption {
6363
return setProperty("system."+name, value)
6464
}
6565

66+
// Custom implements types.DeviceBuilder.
67+
func (b *Builder) Custom(name, value string) types.DeviceOption {
68+
return setProperty(name, value)
69+
}
70+
6671
func setProperty(name, value string) types.DeviceOption {
6772
return func(device *lm.RestDevice) {
6873
if value != "" {

pkg/types/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,6 @@ type DeviceBuilder interface {
7575
Auto(string, string) DeviceOption
7676
// System adds a system property to the device.
7777
System(string, string) DeviceOption
78+
// System adds a custom property to the device.
79+
Custom(string, string) DeviceOption
7880
}

pkg/watch/pod/pod.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (w *Watcher) move(pod *v1.Pod) {
133133

134134
func (w *Watcher) args(pod *v1.Pod, category string) []types.DeviceOption {
135135
categories := utilities.BuildSystemCategoriesFromLabels(category, pod.Labels)
136-
return []types.DeviceOption{
136+
options := []types.DeviceOption{
137137
w.Name(getPodDNSName(pod)),
138138
w.ResourceLabels(pod.Labels),
139139
w.DisplayName(pod.Name),
@@ -145,6 +145,10 @@ func (w *Watcher) args(pod *v1.Pod, category string) []types.DeviceOption {
145145
w.Auto("uid", string(pod.UID)),
146146
w.System("ips", pod.Status.PodIP),
147147
}
148+
if pod.Spec.HostNetwork {
149+
options = append(options, w.Custom("kubernetes.pod.hostNetwork", "true"))
150+
}
151+
return options
148152
}
149153

150154
func getPodDNSName(pod *v1.Pod) string {

0 commit comments

Comments
 (0)