Skip to content

Commit 4ed2176

Browse files
Merge pull request #356 from openshift-bot/synchronize-upstream
NO-ISSUE: Synchronize From Upstream Repositories
2 parents 0f6e9d9 + c417bc8 commit 4ed2176

File tree

19 files changed

+441
-89
lines changed

19 files changed

+441
-89
lines changed

codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ coverage:
1010
default:
1111
target: auto
1212
threshold: 2%
13+
patch:
14+
default:
15+
target: auto
16+
threshold: 1%
1317
paths:
1418
- "api/"
1519
- "cmd/"

commitchecker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
expectedMergeBase: f5dc9a98ae9939e9706b813fa1b45faf74688d2b
1+
expectedMergeBase: 532c306780513a0e5ffb2d96a9eca0b882cc5a7d
22
upstreamBranch: main
33
upstreamOrg: operator-framework
44
upstreamRepo: operator-controller
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# NetworkPolicy in OLMv1
2+
3+
## Overview
4+
5+
OLMv1 uses [Kubernetes NetworkPolicy](https://kubernetes.io/docs/concepts/services-networking/network-policies/) to secure communication between components, restricting network traffic to only what's necessary for proper functionality.
6+
7+
* The catalogd NetworkPolicy is implemented [here](https://github.com/operator-framework/operator-controller/blob/main/config/base/catalogd/manager/network_policy.yaml).
8+
* The operator-controller is implemented [here](https://github.com/operator-framework/operator-controller/blob/main/config/base/operator-controller/manager/network_policy.yaml).
9+
10+
This document explains the details of `NetworkPolicy` implementation for the core components.
11+
12+
13+
## Implementation Overview
14+
15+
NetworkPolicy is implemented for both catalogd and operator-controller components to:
16+
17+
* Restrict incoming (ingress) traffic to only required ports and services
18+
* Control outgoing (egress) traffic patterns
19+
20+
Each component has a dedicated NetworkPolicy that applies to its respective pod through label selectors:
21+
22+
* For catalogd: `control-plane=catalogd-controller-manager`
23+
* For operator-controller: `control-plane=operator-controller-controller-manager`
24+
25+
### Catalogd NetworkPolicy
26+
27+
- Ingress Rules
28+
Catalogd exposes three services, and its NetworkPolicy allows ingress traffic to the following TCP ports:
29+
30+
* 7443: Metrics server for Prometheus metrics
31+
* 8443: Catalogd HTTPS server for catalog metadata API
32+
* 9443: Webhook server for Mutating Admission Webhook implementation
33+
34+
All other ingress traffic to the catalogd pod is blocked.
35+
36+
- Egress Rules
37+
Catalogd needs to communicate with:
38+
39+
* The Kubernetes API server
40+
* Image registries specified in ClusterCatalog objects
41+
42+
Currently, all egress traffic from catalogd is allowed, to support communication with arbitrary image registries that aren't known at install time.
43+
44+
### Operator-Controller NetworkPolicy
45+
46+
- Ingress Rules
47+
Operator-controller exposes one service, and its NetworkPolicy allows ingress traffic to:
48+
49+
* 8443: Metrics server for Prometheus metrics
50+
51+
All other ingress traffic to the operator-controller pod is blocked.
52+
53+
- Egress Rules
54+
Operator-controller needs to communicate with:
55+
56+
* The Kubernetes API server
57+
* Catalogd's HTTPS server (on port 8443)
58+
* Image registries specified in bundle metadata
59+
60+
Currently, all egress traffic from operator-controller is allowed to support communication with arbitrary image registries that aren't known at install time.
61+
62+
## Security Considerations
63+
64+
The current implementation focuses on securing ingress traffic while allowing all egress traffic. This approach:
65+
66+
* Prevents unauthorized incoming connections
67+
* Allows communication with arbitrary image registries
68+
* Establishes a foundation for future refinements to egress rules
69+
70+
While allowing all egress does present some security risks, this implementation provides significant security improvements over having no network policies at all.
71+
72+
## Troubleshooting Network Issues
73+
74+
If you encounter network connectivity issues after deploying OLMv1, consider the following:
75+
76+
* Verify NetworkPolicy support: Ensure your cluster has a CNI plugin that supports NetworkPolicy. If your Kubernetes cluster is using a Container Network Interface (CNI) plugin that doesn't support NetworkPolicy, then the NetworkPolicy resources you create will be completely ignored and have no effect whatsoever on traffic flow.
77+
* Check pod labels: Confirm that catalogd and operator-controller pods have the correct labels for NetworkPolicy selection:
78+
79+
```bash
80+
# Verify catalogd pod labels
81+
kubectl get pods -n olmv1-system --selector=control-plane=catalogd-controller-manager
82+
83+
# Verify operator-controller pod labels
84+
kubectl get pods -n olmv1-system --selector=control-plane=operator-controller-controller-manager
85+
86+
# Compare with actual pod names
87+
kubectl get pods -n olmv1-system | grep -E 'catalogd|operator-controller'
88+
```
89+
* Inspect logs: Check component logs for connection errors
90+
91+
For more comprehensive information on NetworkPolicy, see:
92+
93+
- How NetworkPolicy is implemented with [network plugins](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) via the Container Network Interface (CNI)
94+
- Installing [Network Policy Providers](https://kubernetes.io/docs/tasks/administer-cluster/network-policy-provider/) documentation.

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11
2121
github.com/operator-framework/api v0.31.0
2222
github.com/operator-framework/helm-operator-plugins v0.8.0
23-
github.com/operator-framework/operator-registry v1.54.0
23+
github.com/operator-framework/operator-registry v1.55.0
2424
github.com/prometheus/client_golang v1.22.0
2525
github.com/spf13/cobra v1.9.1
2626
github.com/stretchr/testify v1.10.0
@@ -235,7 +235,7 @@ require (
235235
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb // indirect
236236
google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect
237237
google.golang.org/genproto/googleapis/rpc v0.0.0-20250428153025-10db94c68c34 // indirect
238-
google.golang.org/grpc v1.72.0 // indirect
238+
google.golang.org/grpc v1.72.1 // indirect
239239
google.golang.org/protobuf v1.36.6 // indirect
240240
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
241241
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ github.com/operator-framework/helm-operator-plugins v0.8.0 h1:0f6HOQC5likkf0b/Ov
406406
github.com/operator-framework/helm-operator-plugins v0.8.0/go.mod h1:Sc+8bE38xTCgCChBUvtq/PxatEg9fAypr7S5iAw8nlA=
407407
github.com/operator-framework/operator-lib v0.17.0 h1:cbz51wZ9+GpWR1ZYP4CSKSSBxDlWxmmnseaHVZZjZt4=
408408
github.com/operator-framework/operator-lib v0.17.0/go.mod h1:TGopBxIE8L6E/Cojzo26R3NFp1eNlqhQNmzqhOblaLw=
409-
github.com/operator-framework/operator-registry v1.54.0 h1:/OGQnBlfVQglq8VzGJPIkqWMXOVSo+eu7owCgOqoBpU=
410-
github.com/operator-framework/operator-registry v1.54.0/go.mod h1:ll5r97EB+V2rVA58rdj8Hxmbo/osnw3f6D4Xq6bpWcE=
409+
github.com/operator-framework/operator-registry v1.55.0 h1:iXlv53fYyg2VtLqSDEalXD72/5Uzc7Rfx17j35+8plA=
410+
github.com/operator-framework/operator-registry v1.55.0/go.mod h1:8htDRYKWZ6UWjGMXbBdwwHefsJknodOiGLnpjxgAflw=
411411
github.com/otiai10/copy v1.14.1 h1:5/7E6qsUMBaH5AnQ0sSLzzTg1oTECmcCmT6lvF45Na8=
412412
github.com/otiai10/copy v1.14.1/go.mod h1:oQwrEDDOci3IM8dJF0d8+jnbfPDllW6vUjNc3DoZm9I=
413413
github.com/otiai10/mint v1.6.3 h1:87qsV/aw1F5as1eH1zS/yqHY85ANKVMgkDrf9rcxbQs=
@@ -742,8 +742,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
742742
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
743743
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
744744
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
745-
google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM=
746-
google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
745+
google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA=
746+
google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM=
747747
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
748748
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
749749
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -807,8 +807,8 @@ k8s.io/utils v0.0.0-20241210054802-24370beab758 h1:sdbE21q2nlQtFh65saZY+rRM6x6aJ
807807
k8s.io/utils v0.0.0-20241210054802-24370beab758/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
808808
oras.land/oras-go v1.2.5 h1:XpYuAwAb0DfQsunIyMfeET92emK8km3W4yEzZvUbsTo=
809809
oras.land/oras-go v1.2.5/go.mod h1:PuAwRShRZCsZb7g8Ar3jKKQR/2A/qN+pkYxIOd/FAoo=
810-
oras.land/oras-go/v2 v2.5.0 h1:o8Me9kLY74Vp5uw07QXPiitjsw7qNXi8Twd+19Zf02c=
811-
oras.land/oras-go/v2 v2.5.0/go.mod h1:z4eisnLP530vwIOUOJeBIj0aGI0L1C3d53atvCBqZHg=
810+
oras.land/oras-go/v2 v2.6.0 h1:X4ELRsiGkrbeox69+9tzTu492FMUu7zJQW6eJU+I2oc=
811+
oras.land/oras-go/v2 v2.6.0/go.mod h1:magiQDfG6H1O9APp+rOsvCPcW1GD2MM7vgnKY0Y+u1o=
812812
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.1 h1:uOuSLOMBWkJH0TWa9X6l+mj5nZdm6Ay6Bli8HL8rNfk=
813813
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.1/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
814814
sigs.k8s.io/controller-runtime v0.20.4 h1:X3c+Odnxz+iPTRobG4tp092+CvBU9UK0t/bRf+n0DGU=

test/e2e/cluster_extension_install_test.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,6 @@ func TestClusterExtensionInstallRegistry(t *testing.T) {
377377
assert.NotEmpty(ct, clusterExtension.Status.Install.Bundle)
378378
}
379379
}, pollDuration, pollInterval)
380-
381-
t.Log("By verifying that no templating occurs for registry+v1 bundle manifests")
382-
cm := corev1.ConfigMap{}
383-
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
384-
require.Contains(t, cm.Annotations, "shouldNotTemplate")
385-
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
386380
})
387381
}
388382
}
@@ -718,7 +712,7 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
718712

719713
// patch imageRef tag on test-catalog image with v2 image
720714
t.Log("By patching the catalog ImageRef to point to the v2 catalog")
721-
updatedCatalogImage := fmt.Sprintf("%s/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
715+
updatedCatalogImage := fmt.Sprintf("%s/e2e/test-catalog:v2", os.Getenv("LOCAL_REGISTRY_HOST"))
722716
err := patchTestCatalog(context.Background(), testCatalogName, updatedCatalogImage)
723717
require.NoError(t, err)
724718
require.EventuallyWithT(t, func(ct *assert.CollectT) {
@@ -730,15 +724,23 @@ func TestClusterExtensionInstallReResolvesWhenCatalogIsPatched(t *testing.T) {
730724
}
731725
}, pollDuration, pollInterval)
732726

733-
t.Log("By eventually reporting a successful resolution and bundle path")
727+
t.Log("By eventually installing the package successfully")
734728
require.EventuallyWithT(t, func(ct *assert.CollectT) {
735729
assert.NoError(ct, c.Get(context.Background(), types.NamespacedName{Name: clusterExtension.Name}, clusterExtension))
736-
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeProgressing)
730+
cond := apimeta.FindStatusCondition(clusterExtension.Status.Conditions, ocv1.TypeInstalled)
737731
if assert.NotNil(ct, cond) {
738732
assert.Equal(ct, metav1.ConditionTrue, cond.Status)
739733
assert.Equal(ct, ocv1.ReasonSucceeded, cond.Reason)
734+
assert.Contains(ct, cond.Message, "Installed bundle")
735+
assert.Contains(ct, clusterExtension.Status.Install.Bundle.Version, "2.0.0")
740736
}
741737
}, pollDuration, pollInterval)
738+
739+
t.Log("By verifying that no templating occurs for registry+v1 bundle manifests")
740+
cm := corev1.ConfigMap{}
741+
require.NoError(t, c.Get(context.Background(), types.NamespacedName{Namespace: ns.Name, Name: "test-configmap"}, &cm))
742+
require.Contains(t, cm.Annotations, "shouldNotTemplate")
743+
require.Contains(t, cm.Annotations["shouldNotTemplate"], "{{ $labels.namespace }}")
742744
}
743745

744746
func TestClusterExtensionInstallReResolvesWhenNewCatalog(t *testing.T) {

testdata/images/bundles/test-operator/v1.0.0/manifests/bundle.configmap.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@ apiVersion: v1
22
kind: ConfigMap
33
metadata:
44
name: test-configmap
5-
annotations:
6-
shouldNotTemplate: >
7-
The namespace is {{ $labels.namespace }}. The templated
8-
$labels.namespace is NOT expected to be processed by OLM's
9-
rendering engine for registry+v1 bundles.
105
data:
116
version: "v1.0.0"
127
name: "test-configmap"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: test-configmap
5+
annotations:
6+
shouldNotTemplate: >
7+
The namespace is {{ $labels.namespace }}. The templated
8+
$labels.namespace is NOT expected to be processed by OLM's
9+
rendering engine for registry+v1 bundles.
10+
data:
11+
version: "v2.0.0"
12+
name: "test-configmap"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.16.1
7+
name: olme2etests.olm.operatorframework.io
8+
spec:
9+
group: olm.operatorframework.io
10+
names:
11+
kind: OLME2ETest
12+
listKind: OLME2ETestList
13+
plural: olme2etests
14+
singular: olme2etest
15+
scope: Cluster
16+
versions:
17+
- name: v1
18+
served: true
19+
storage: true
20+
schema:
21+
openAPIV3Schema:
22+
type: object
23+
properties:
24+
spec:
25+
type: object
26+
properties:
27+
testField:
28+
type: string

0 commit comments

Comments
 (0)