Skip to content

Commit ea8e57b

Browse files
authored
enable operator network policies on all OpenShift/k8s versions by default (#1251)
* enable operator network policies on all OpenShift versions by default Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> * networkpolicy: use metrics port instead of name Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de> --------- Signed-off-by: Benedikt Bongartz <bongartz@klimlive.de>
1 parent 2c4bb15 commit ea8e57b

File tree

6 files changed

+7
-15
lines changed

6 files changed

+7
-15
lines changed

bundle/community/manifests/tempo-operator-manager-config_v1_configmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ data:
4949
metrics:
5050
createServiceMonitors: false
5151
createPrometheusRules: false
52+
networkPolicies: true
5253
kind: ConfigMap
5354
metadata:
5455
labels:

config/overlays/community/controller_manager_config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ featureGates:
4646
metrics:
4747
createServiceMonitors: false
4848
createPrometheusRules: false
49+
networkPolicies: true

internal/manifests/networking/policies.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func policyIngressToMetrics(instanceName, namespace string, labels map[string]st
129129
Ports: []networkingv1.NetworkPolicyPort{
130130
{
131131
Protocol: ptr.To(corev1.ProtocolTCP),
132-
Port: ptr.To(intstr.FromString("metrics")),
132+
Port: ptr.To(intstr.FromInt(8443)),
133133
},
134134
},
135135
},

internal/manifests/operator/manifests.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package operator
33
import (
44
"sigs.k8s.io/controller-runtime/pkg/client"
55

6-
"k8s.io/apimachinery/pkg/util/version"
7-
86
configv1alpha1 "github.com/grafana/tempo-operator/api/config/v1alpha1"
97
"github.com/grafana/tempo-operator/internal/manifests/networking"
108
"github.com/grafana/tempo-operator/internal/manifests/operator/prometheus"
@@ -18,17 +16,7 @@ func BuildAll(featureGates configv1alpha1.FeatureGates, namespace, k8sVersion st
1816
manifests = append(manifests, prometheus.ServiceMonitor(featureGates, namespace))
1917
}
2018

21-
discovered, err := version.Parse(k8sVersion)
22-
if err != nil {
23-
return nil, err
24-
}
25-
26-
const minVersion = "1.32" // NOTE: Start support on OpenShift 4.19.
27-
minimum := version.MustParse(minVersion)
28-
// NOTE: This feature is always enabled on OpenShift.
29-
isOpenShift := featureGates.OpenShift.ServingCertsService
30-
31-
if featureGates.NetworkPolicies && (!isOpenShift || discovered.AtLeast(minimum)) {
19+
if featureGates.NetworkPolicies {
3220
manifests = append(manifests, networking.GenerateOperatorPolicies(namespace)...)
3321
}
3422

tests/e2e/networking/00-asserts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ spec:
5959
- namespaceSelector: {}
6060
podSelector: {}
6161
ports:
62-
- port: metrics
62+
- port: 8443
6363
protocol: TCP
6464
podSelector:
6565
matchLabels:

tests/e2e/networking/chainsaw-test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ metadata:
55
creationTimestamp: null
66
name: operator-networking
77
spec:
8+
timeouts:
9+
assert: 120s
810
steps:
911
- name: step-00
1012
try:

0 commit comments

Comments
 (0)