Skip to content

Commit

Permalink
[Kubevirt] Remove EgressFirewall Creation in HCP namespace
Browse files Browse the repository at this point in the history
Starting from 4.14, the EgressFirewall is not needed any longer, since kubevirt platform consumes the kubevirt provider in RHCOS, thus an attempt to access the metadata server is not being initiated, as opposed to the legacy OpenStack RHCOS provider.
Therefore, EgressFirewall is not needed to be deployed on the mgmt/infra cluster for guests >= v4.14.

Signed-off-by: Oren Cohen <ocohen@redhat.com>
  • Loading branch information
orenc1 committed Sep 26, 2023
1 parent 45e61f9 commit 7238421
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 75 deletions.
5 changes: 0 additions & 5 deletions cmd/install/assets/hypershift_operator.go
Expand Up @@ -990,11 +990,6 @@ func (o HyperShiftOperatorClusterRole) Build() *rbacv1.ClusterRole {
Verbs: []string{"delete"},
ResourceNames: []string{hyperv1.GroupVersion.Group},
},
{
APIGroups: []string{"k8s.ovn.org"},
Resources: []string{"egressfirewalls"},
Verbs: []string{"*"},
},
},
}
return role
Expand Down
6 changes: 0 additions & 6 deletions hack/app-sre/saas_template.yaml
Expand Up @@ -262,12 +262,6 @@ objects:
- validatingwebhookconfigurations
verbs:
- delete
- apiGroups:
- k8s.ovn.org
resources:
- egressfirewalls
verbs:
- '*'
- apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand Down
Expand Up @@ -77,7 +77,6 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -4029,26 +4028,6 @@ type NodeClientCert struct {
Disabled bool `json:"disabled,omitempty"`
}

func reconcileVirtLauncherEgressFirewall(egressFirewall *unstructured.Unstructured) error {
egressFirewall.Object["spec"] = map[string]interface{}{
"egress": []interface{}{
map[string]interface{}{
"to": map[string]interface{}{
"cidrSelector": "169.254.169.254/32",
},
"type": "Deny",
"ports": []interface{}{
map[string]interface{}{
"port": int64(80),
"protocol": "TCP",
},
},
},
},
}
return nil
}

const (
oidcDocumentsFinalizer = "hypershift.io/aws-oidc-discovery"
serviceAccountSigningKeySecret = "sa-signing-key"
Expand Down
20 changes: 0 additions & 20 deletions hypershift-operator/controllers/hostedcluster/network_policies.go
Expand Up @@ -10,7 +10,6 @@ import (
configv1 "github.com/openshift/api/config/v1"
hyperv1 "github.com/openshift/hypershift/api/v1beta1"
"github.com/openshift/hypershift/hypershift-operator/controllers/manifests"
"github.com/openshift/hypershift/hypershift-operator/controllers/manifests/egressfirewall"
"github.com/openshift/hypershift/hypershift-operator/controllers/manifests/networkpolicy"
"github.com/openshift/hypershift/support/capabilities"
"github.com/openshift/hypershift/support/config"
Expand Down Expand Up @@ -108,25 +107,6 @@ func (r *HostedClusterReconciler) reconcileNetworkPolicies(ctx context.Context,
return fmt.Errorf("failed to reconcile virt launcher policy: %w", err)
}
}

var creds *hyperv1.KubevirtPlatformCredentials

if hcluster.Spec.Platform.Kubevirt != nil && hcluster.Spec.Platform.Kubevirt.Credentials != nil {
creds = hcluster.Spec.Platform.Kubevirt.Credentials
}

kvInfraCluster, err := r.KubevirtInfraClients.DiscoverKubevirtClusterClient(ctx, r.Client, hcluster.Spec.InfraID, creds, hcp.Namespace, hcluster.Namespace)
if err != nil {
return err
}
if hcluster.Spec.Networking.NetworkType == hyperv1.OVNKubernetes {
egressFirewall := egressfirewall.VirtLauncherEgressFirewall(kvInfraCluster.GetInfraNamespace())
if _, err := createOrUpdate(ctx, kvInfraCluster.GetInfraClient(), egressFirewall, func() error {
return reconcileVirtLauncherEgressFirewall(egressFirewall)
}); err != nil {
return fmt.Errorf("failed to reconcile firewall to deny metadata server egress: %w", err)
}
}
}

for _, svc := range hcluster.Spec.Services {
Expand Down

This file was deleted.

0 comments on commit 7238421

Please sign in to comment.