Skip to content
Open
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
34 changes: 34 additions & 0 deletions deploy/09_networkpolicy-operand.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# NOTE: The operand DaemonSet uses hostNetwork: true and binds to 127.0.0.1,
# so NetworkPolicy has no effect on it (NetworkPolicy only applies to
# pod-network traffic). This resource is provided for documentation purposes
# and as a safeguard in case the networking mode changes in the future.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: run-once-duration-override-operand
namespace: openshift-run-once-duration-override-operator
spec:
podSelector:
matchLabels:
runoncedurationoverride: "true"
policyTypes:
- Ingress
- Egress
ingress:
# kube-apiserver -> webhook admission endpoint on port 9448 (TLS)
- ports:
- protocol: TCP
port: 9448
egress:
# DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
# Kubernetes API server (read-only: namespaces, webhook configs, flowcontrol)
- {}
30 changes: 30 additions & 0 deletions deploy/09_networkpolicy-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: run-once-duration-override-operator
namespace: openshift-run-once-duration-override-operator
spec:
podSelector:
matchLabels:
runoncedurationoverride.operator: "true"
policyTypes:
- Ingress
- Egress
ingress:
# kubelet health probes (readiness + liveness) on /healthz
- ports:
- protocol: TCP
port: 8080
egress:
# DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
# Kubernetes and OpenShift API server (watches, CRUD on operand resources)
- {}
10 changes: 10 additions & 0 deletions deploy/10_networkpolicy-default-deny-all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: openshift-run-once-duration-override-operator
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
10 changes: 10 additions & 0 deletions test/e2e/bindata/assets/networkpolicy-default-deny-all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-all
namespace: openshift-run-once-duration-override-operator
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
34 changes: 34 additions & 0 deletions test/e2e/bindata/assets/networkpolicy-operand.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# NOTE: The operand DaemonSet uses hostNetwork: true and binds to 127.0.0.1,
# so NetworkPolicy has no effect on it (NetworkPolicy only applies to
# pod-network traffic). This resource is provided for documentation purposes
# and as a safeguard in case the networking mode changes in the future.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: run-once-duration-override-operand
namespace: openshift-run-once-duration-override-operator
spec:
podSelector:
matchLabels:
runoncedurationoverride: "true"
policyTypes:
- Ingress
- Egress
ingress:
# kube-apiserver -> webhook admission endpoint on port 9448 (TLS)
- ports:
- protocol: TCP
port: 9448
egress:
# DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
# Kubernetes API server (read-only: namespaces, webhook configs, flowcontrol)
- {}
30 changes: 30 additions & 0 deletions test/e2e/bindata/assets/networkpolicy-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: run-once-duration-override-operator
namespace: openshift-run-once-duration-override-operator
spec:
podSelector:
matchLabels:
runoncedurationoverride.operator: "true"
policyTypes:
- Ingress
- Egress
ingress:
# kubelet health probes (readiness + liveness) on /healthz
- ports:
- protocol: TCP
port: 8080
egress:
# DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
# Kubernetes and OpenShift API server (watches, CRUD on operand resources)
- {}
21 changes: 21 additions & 0 deletions test/e2e/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,27 @@ func setupOperator(t testing.TB) (context.Context, context.CancelFunc, *k8sclien
return err
},
},
{
path: "assets/networkpolicy-operator.yaml",
readerAndApply: func(objBytes []byte) error {
_, _, err := resourceapply.ApplyNetworkPolicy(ctx, kubeClient.NetworkingV1(), eventRecorder, resourceread.ReadNetworkPolicyV1OrDie(objBytes), nil)
return err
},
},
{
path: "assets/networkpolicy-operand.yaml",
readerAndApply: func(objBytes []byte) error {
_, _, err := resourceapply.ApplyNetworkPolicy(ctx, kubeClient.NetworkingV1(), eventRecorder, resourceread.ReadNetworkPolicyV1OrDie(objBytes), nil)
return err
},
},
{
path: "assets/networkpolicy-default-deny-all.yaml",
readerAndApply: func(objBytes []byte) error {
_, _, err := resourceapply.ApplyNetworkPolicy(ctx, kubeClient.NetworkingV1(), eventRecorder, resourceread.ReadNetworkPolicyV1OrDie(objBytes), nil)
return err
},
},
}

// Apply all assets
Expand Down