diff --git a/pkg/collector/daemonset.go b/pkg/collector/daemonset.go index ef48b05933..93ecce6491 100644 --- a/pkg/collector/daemonset.go +++ b/pkg/collector/daemonset.go @@ -32,7 +32,10 @@ func DaemonSet(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem annotations := Annotations(otelcol) podAnnotations := PodAnnotations(otelcol) - + dnsPolicy := corev1.DNSClusterFirst + if otelcol.Spec.HostNetwork { + dnsPolicy = corev1.DNSClusterFirstWithHostNet + } return appsv1.DaemonSet{ ObjectMeta: metav1.ObjectMeta{ Name: naming.Collector(otelcol), @@ -55,6 +58,7 @@ func DaemonSet(cfg config.Config, logger logr.Logger, otelcol v1alpha1.OpenTelem Volumes: Volumes(cfg, otelcol), Tolerations: otelcol.Spec.Tolerations, HostNetwork: otelcol.Spec.HostNetwork, + DNSPolicy: dnsPolicy, SecurityContext: otelcol.Spec.PodSecurityContext, }, },