Skip to content

Commit 58ad7ee

Browse files
biswajit-9776hansinikarunarathne
authored andcommitted
Added tests to tests/gh-actions to enable baseline and restricted PSS (kubeflow#2819)
* Patched PSS labels to multi_tenancy Signed-off-by: biswajit-9776 <[email protected]> * Added script in gh-actions to patch PSS/static/baseline/pacthes Signed-off-by: biswajit-9776 <[email protected]> * Added PSS scripts for both baseline and restricted labels of static namespaces and renamed directories Signed-off-by: biswajit-9776 <[email protected]> * Added tests to enable PSS in gh-actions Signed-off-by: biswajit-9776 <[email protected]> * Added workflow test for PSS labels Signed-off-by: biswajit-9776 <[email protected]> * Fixed indentation Signed-off-by: biswajit-9776 <[email protected]> --------- Signed-off-by: biswajit-9776 <[email protected]>
1 parent c092e5a commit 58ad7ee

File tree

9 files changed

+60
-6
lines changed

9 files changed

+60
-6
lines changed

.github/workflows/pss_test.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Appy PSS labels to namespaces
2+
on:
3+
pull_request:
4+
paths:
5+
- .github/workflows/*
6+
- tests/gh-actions/kind-cluster.yaml
7+
- apps/profiles/upstream/**
8+
- common/dex/**
9+
- common/cert-manager/**
10+
- common/oidc-client/oauth2-proxy/**
11+
- common/istio*/**
12+
- tests/gh-actions/install_istio_with_ext_auth.sh
13+
- tests/gh-actions/install_multitenancy.sh
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Install KinD
23+
run: ./tests/gh-actions/install_kind.sh
24+
25+
- name: Create KinD Cluster
26+
run: kind create cluster --config tests/gh-actions/kind-cluster.yaml
27+
28+
- name: Install kustomize
29+
run: ./tests/gh-actions/install_kustomize.sh
30+
31+
- name: Install kubectl
32+
run: ./tests/gh-actions/install_kubectl.sh
33+
34+
- name: Applying Pod Security Standards baseline levels for static namespaces
35+
run: ./tests/gh-actions/enable_baseline_PSS.sh

contrib/security/PSS/static/baseline/kustomization.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Component
33

44
patches:
55
- path: patches/kubeflow-labels.yaml
6-
- path: patches/istio-labels.yaml
6+
- path: patches/istio-system-labels.yaml
77
- path: patches/cert-manager-labels.yaml
8-
- path: patches/dex-labels.yaml
9-
- path: patches/oauth2-proxy-labels.yaml
8+
- path: patches/auth-labels.yaml
9+
- path: patches/oauth2-proxy-labels.yaml

contrib/security/PSS/static/restricted/kustomization.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ kind: Component
33

44
patches:
55
- path: patches/kubeflow-labels.yaml
6-
- path: patches/istio-labels.yaml
6+
- path: patches/istio-system-labels.yaml
77
- path: patches/cert-manager-labels.yaml
8-
- path: patches/dex-labels.yaml
8+
- path: patches/auth-labels.yaml
99
- path: patches/oauth2-proxy-labels.yaml
10-
- path: patches/istio-labels.yaml
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
NAMESPACES=("istio-system" "auth" "cert-manager" "oauth2-proxy" "kubeflow")
4+
5+
for NAMESPACE in "${NAMESPACES[@]}"; do
6+
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
7+
echo "Patching the PSS-baseline labels for namespace $NAMESPACE..."
8+
kubectl patch namespace $NAMESPACE --patch-file ./contrib/security/PSS/static/baseline/patches/${NAMESPACE}-labels.yaml
9+
fi
10+
done
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
NAMESPACES=("istio-system" "auth" "cert-manager" "oauth2-proxy" "kubeflow")
4+
5+
for NAMESPACE in "${NAMESPACES[@]}"; do
6+
if kubectl get namespace "$NAMESPACE" >/dev/null 2>&1; then
7+
echo "Patching the PSS-restricted labels for namespace $NAMESPACE..."
8+
kubectl patch namespace $NAMESPACE --patch-file ./contrib/security/PSS/static/restricted/patches/${NAMESPACE}-labels.yaml
9+
fi
10+
done

0 commit comments

Comments
 (0)