Skip to content

Opt-in for network-policies provided by hco-bundle for CNAO and its components pods #2341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions data/kube-secondary-dns/secondarydns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ spec:
metadata:
labels:
k8s-app: secondary-dns
hco.kubevirt.io/allow-access-cluster-services: ""
annotations:
kubectl.kubernetes.io/default-container: status-monitor
openshift.io/required-scc: "restricted-v2"
Expand Down
3 changes: 3 additions & 0 deletions data/kubemacpool/kubemacpool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ spec:
app: kubemacpool
control-plane: cert-manager
controller-tools.k8s.io: "1.0"
hco.kubevirt.io/allow-access-cluster-services: ""
spec:
affinity: {{ toYaml .Placement.Affinity | nindent 8 }}
containers:
Expand Down Expand Up @@ -245,6 +246,8 @@ spec:
app: kubemacpool
control-plane: mac-controller-manager
controller-tools.k8s.io: "1.0"
hco.kubevirt.io/allow-access-cluster-services: ""
hco.kubevirt.io/allow-prometheus-access: ""
spec:
affinity: {{ toYaml .Placement.Affinity | nindent 8 }}
containers:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ spec:
labels:
app: ipam-virt-workloads
control-plane: manager
hco.kubevirt.io/allow-access-cluster-services: ""
spec:
containers:
- args:
Expand Down
1 change: 1 addition & 0 deletions hack/components/bump-kube-secondary-dns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function __parametize_by_object() {
yaml-utils::set_param ${f} spec.template.spec.affinity '{{ toYaml .Placement.Affinity | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.tolerations '{{ toYaml .Placement.Tolerations | nindent 8 }}'
yaml-utils::set_param ${f} 'spec.template.metadata.annotations."openshift.io/required-scc"' '"restricted-v2"'
yaml-utils::set_param ${f} 'spec.template.metadata.labels."hco.kubevirt.io/allow-access-cluster-services"' '""'
yaml-utils::remove_single_quotes_from_yaml ${f}
;;
./ServiceAccount_secondary.yaml)
Expand Down
19 changes: 19 additions & 0 deletions hack/components/bump-kubemacpool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ patches:
target:
version: v1
kind: Namespace
- path: add-pod-template-label-allow-access-cluster-services_patch.yaml
target:
version: v1
kind: Deployment
- path: add-pod-template-label-allow-prometheus-access_patch.yaml
target:
version: v1
kind: Deployment
name: mac-controller-manager
EOF

cat <<EOF > config/cnao/cnao_kubemacpool_manager_patch.yaml
Expand Down Expand Up @@ -145,6 +154,16 @@ EOF
path: /metadata/labels
EOF

cat <<EOF > config/cnao/add-pod-template-label-allow-access-cluster-services_patch.yaml
- op: add
path: /spec/template/metadata/labels/hco.kubevirt.io~1allow-access-cluster-services
value: ""
EOF
cat <<EOF > config/cnao/add-pod-template-label-allow-prometheus-access_patch.yaml
- op: add
path: /spec/template/metadata/labels/hco.kubevirt.io~1allow-prometheus-access
value: ""
EOF

(
cd config/cnao
Expand Down
1 change: 1 addition & 0 deletions hack/components/bump-kubevirt-ipam-controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function __parametize_by_object() {
yaml-utils::set_param ${f} spec.template.spec.nodeSelector '{{ toYaml .Placement.NodeSelector | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.affinity '{{ toYaml .Placement.Affinity | nindent 8 }}'
yaml-utils::set_param ${f} spec.template.spec.tolerations '{{ toYaml .Placement.Tolerations | nindent 8 }}'
yaml-utils::set_param ${f} 'spec.template.metadata.labels."hco.kubevirt.io/allow-access-cluster-services"' '""'
yaml-utils::remove_single_quotes_from_yaml ${f}
;;
./Service_kubevirt-ipam-controller-webhook-service.yaml)
Expand Down
4 changes: 4 additions & 0 deletions pkg/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func GetDeployment(version string, operatorVersion string, namespace string, rep
Labels: map[string]string{
"name": Name,
names.PrometheusLabelKey: names.PrometheusLabelValue,
// opt-in to hco-bundle network-policy allowing egress to cluster services
"hco.kubevirt.io/allow-access-cluster-services": "",
// opt-in to hco-bundle network-policy allowing ingress to the metrics endpoint
"hco.kubevirt.io/allow-prometheus-access": "",
},
Annotations: map[string]string{
"description": "cluster-network-addons-operator manages the lifecycle of different Kubernetes network components on top of Kubernetes cluster",
Expand Down