Skip to content

Commit 45bcf4c

Browse files
Enforce PSA Restricted Level for CatalogSources (Drop Support for Catalogs Built with opm < v1.21.0)
- enforce PSA restricted level - remove tests for Catalogs built with opm < v1.21.0 to ensure compatibility with those that needs baseline permissions
1 parent 8723097 commit 45bcf4c

File tree

3 files changed

+5
-50
lines changed

3 files changed

+5
-50
lines changed

deploy/chart/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rbacApiVersion: rbac.authorization.k8s.io
22
namespace: operator-lifecycle-manager
33
# see https://kubernetes.io/docs/concepts/security/pod-security-admission/ for more details
44
namespace_psa:
5-
enforceLevel: baseline
5+
enforceLevel: restricted
66
enforceVersion: latest
77
auditLevel: restricted
88
auditVersion: latest
@@ -12,7 +12,7 @@ catalog_namespace: operator-lifecycle-manager
1212
operator_namespace: operators
1313
# see https://kubernetes.io/docs/concepts/security/pod-security-admission/ for more details
1414
operator_namespace_psa:
15-
enforceLevel: baseline
15+
enforceLevel: restricted
1616
enforceVersion: latest
1717
minKubeVersion: 1.11.0
1818
writeStatusName: '""'

deploy/upstream/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ catalog_namespace: olm
99
operator_namespace: operators
1010
# see https://kubernetes.io/docs/concepts/security/pod-security-admission/ for more details
1111
operator_namespace_psa:
12-
enforceLevel: baseline
12+
enforceLevel: restricted
1313
enforceVersion: latest
1414
imagestream: false
1515
writeStatusName: '""'

test/e2e/catalog_e2e_test.go

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,53 +1626,8 @@ var _ = Describe("Starting CatalogSource e2e tests", Label("CatalogSource"), fun
16261626
return nil
16271627
}).Should(BeNil())
16281628
})
1629-
When("A CatalogSource built with opm v1.21.0 (<v1.23.2)is created with spec.GrpcPodConfig.SecurityContextConfig set to restricted", func() {
1630-
var sourceName string
1631-
BeforeEach(func() {
1632-
sourceName = genName("catalog-")
1633-
source := &v1alpha1.CatalogSource{
1634-
TypeMeta: metav1.TypeMeta{
1635-
Kind: v1alpha1.CatalogSourceKind,
1636-
APIVersion: v1alpha1.CatalogSourceCRDAPIVersion,
1637-
},
1638-
ObjectMeta: metav1.ObjectMeta{
1639-
Name: sourceName,
1640-
Namespace: generatedNamespace.GetName(),
1641-
Labels: map[string]string{"olm.catalogSource": sourceName},
1642-
},
1643-
Spec: v1alpha1.CatalogSourceSpec{
1644-
SourceType: v1alpha1.SourceTypeGrpc,
1645-
Image: "quay.io/olmtest/old-opm-catsrc:v1.21.0",
1646-
GrpcPodConfig: &v1alpha1.GrpcPodConfig{
1647-
SecurityContextConfig: v1alpha1.Restricted,
1648-
},
1649-
},
1650-
}
1651-
1652-
Eventually(func() error {
1653-
_, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
1654-
return err
1655-
}).Should(Succeed())
1656-
})
1657-
It("The registry pod fails to become come up because of lack of permission", func() {
1658-
Eventually(func() (bool, error) {
1659-
podList, err := c.KubernetesInterface().CoreV1().Pods(generatedNamespace.GetName()).List(context.TODO(), metav1.ListOptions{})
1660-
if err != nil {
1661-
return false, err
1662-
}
1663-
for _, pod := range podList.Items {
1664-
if pod.ObjectMeta.OwnerReferences != nil && pod.ObjectMeta.OwnerReferences[0].Name == sourceName {
1665-
if pod.Status.ContainerStatuses != nil && pod.Status.ContainerStatuses[0].State.Terminated != nil {
1666-
return true, nil
1667-
}
1668-
}
1669-
}
1670-
return false, nil
1671-
}).Should(BeTrue())
1672-
})
1673-
})
16741629
})
1675-
When("The namespace is labled as Pod Security Admission policy enforce:baseline", func() {
1630+
When("The namespace is labled as Pod Security Admission policy enforce:restricted", func() {
16761631
BeforeEach(func() {
16771632
var err error
16781633
testNS := &corev1.Namespace{}
@@ -1685,7 +1640,7 @@ var _ = Describe("Starting CatalogSource e2e tests", Label("CatalogSource"), fun
16851640
}).Should(BeNil())
16861641

16871642
testNS.ObjectMeta.Labels = map[string]string{
1688-
"pod-security.kubernetes.io/enforce": "baseline",
1643+
"pod-security.kubernetes.io/enforce": "restricted",
16891644
"pod-security.kubernetes.io/enforce-version": "latest",
16901645
}
16911646

0 commit comments

Comments
 (0)