Skip to content

Commit

Permalink
Merge branch 'master' into member-info-in-spc-status_controller-part
Browse files Browse the repository at this point in the history
  • Loading branch information
metlos authored Dec 18, 2024
2 parents 9e59d91 + da112c1 commit 16a6d71
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
13 changes: 13 additions & 0 deletions deploy/nstemplatetiers/appstudio-env/ns_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ objects:
podSelector: {}
policyTypes:
- Ingress
- apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-from-dev-sandbox-managed-ns
namespace: ${SPACE_NAME}-env
spec:
ingress:
- from:
- namespaceSelector:
matchLabels:
dev-sandbox/policy-group: ingress
policyTypes:
- Ingress
parameters:
- name: SPACE_NAME
required: true
Expand Down
13 changes: 13 additions & 0 deletions deploy/nstemplatetiers/appstudio/ns_tenant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ objects:
podSelector: {}
policyTypes:
- Ingress
- apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-from-dev-sandbox-managed-ns
namespace: ${SPACE_NAME}-tenant
spec:
ingress:
- from:
- namespaceSelector:
matchLabels:
dev-sandbox/policy-group: ingress
policyTypes:
- Ingress
# ServiceAccount and RoleBindings for running Pipelines.
# appstudio-pipelines-runner-clusterrole is deployed by the pipeline-service component.
- apiVersion: v1
Expand Down
19 changes: 12 additions & 7 deletions testsupport/tiers/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (a *baseTierChecks) GetNamespaceObjectChecks(nsType string) []namespaceObje
case "stage":
otherNamespaceKind = "dev"
}
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromOtherNamespace(otherNamespaceKind), numberOfNetworkPolicies(10))
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromOtherNamespace(otherNamespaceKind), numberOfNetworkPolicies(11))

return checks
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func (a *base1nsTierChecks) GetNamespaceObjectChecks(_ string) []namespaceObject
crtadminViewRoleBinding(),
}
checks = append(checks, commonNetworkPolicyChecks()...)
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), numberOfNetworkPolicies(9))
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), numberOfNetworkPolicies(10))
return checks
}

Expand Down Expand Up @@ -381,6 +381,7 @@ func commonNetworkPolicyChecks() []namespaceObjectsCheck {
networkPolicyAllowFromIngress(),
networkPolicyAllowFromOlmNamespaces(),
networkPolicyAllowFromConsoleNamespaces(),
networkPolicyIngressAllowFromDevSandboxPolicyGroup(),
}
}

Expand Down Expand Up @@ -465,7 +466,7 @@ func (a *appstudioTierChecks) GetNamespaceObjectChecks(_ string) []namespaceObje
resourceQuotaComputeBuild("120", "128Gi", "60", "64Gi"),
}
checks = append(checks, commonAppstudioTierChecks()...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(6))...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(7))...)
return checks
}

Expand Down Expand Up @@ -558,7 +559,7 @@ func (a *appstudiolargeTierChecks) GetNamespaceObjectChecks(_ string) []namespac
resourceQuotaStorage("50Gi", "400Gi", "50Gi", "180"),
}
checks = append(checks, commonAppstudioTierChecks()...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(6))...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(7))...)
return checks
}

Expand Down Expand Up @@ -596,7 +597,7 @@ func (a *appstudioEnvTierChecks) GetNamespaceObjectChecks(_ string) []namespaceO
appstudioWorkSpaceNameLabel(),
}

checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(6))...)
checks = append(checks, append(commonNetworkPolicyChecks(), networkPolicyAllowFromCRW(), numberOfNetworkPolicies(7))...)
return checks
}

Expand Down Expand Up @@ -656,7 +657,7 @@ func (a *intelMediumTierChecks) GetNamespaceObjectChecks(_ string) []namespaceOb
crtadminViewRoleBinding(),
}
checks = append(checks, commonNetworkPolicyChecks()...)
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), numberOfNetworkPolicies(9))
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), numberOfNetworkPolicies(10))
return checks
}

Expand Down Expand Up @@ -736,7 +737,7 @@ func getNamespaceObjectChecksForIntelLarge(memoryLimit string) []namespaceObject
crtadminViewRoleBinding(),
}
checks = append(checks, commonNetworkPolicyChecks()...)
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), numberOfNetworkPolicies(9))
checks = append(checks, networkPolicyAllowFromCRW(), networkPolicyAllowFromVirtualizationNamespaces(), networkPolicyAllowFromRedHatODSNamespaceToMariaDB(), networkPolicyAllowFromRedHatODSNamespaceToModelMesh(), numberOfNetworkPolicies(10))
return checks
}

Expand Down Expand Up @@ -1242,6 +1243,10 @@ func networkPolicyIngressFromPolicyGroup(name, group string) namespaceObjectsChe
return assertNetworkPolicyIngressForNamespaces(name, metav1.LabelSelector{}, "network.openshift.io/policy-group", group)
}

func networkPolicyIngressAllowFromDevSandboxPolicyGroup() namespaceObjectsCheck {
return assertNetworkPolicyIngressForNamespaces("allow-from-dev-sandbox-managed-ns", metav1.LabelSelector{}, "dev-sandbox/policy-group", "ingress")
}

func assertNetworkPolicyIngressForNamespaces(name string, podSelector metav1.LabelSelector, labelNameValuePairs ...string) namespaceObjectsCheck {
return func(t *testing.T, ns *corev1.Namespace, memberAwait *wait.MemberAwaitility, userName string) {
require.Equal(t, 0, len(labelNameValuePairs)%2, "labelNameValuePairs must be a list of key-value pairs")
Expand Down

0 comments on commit 16a6d71

Please sign in to comment.