Skip to content
Merged
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
6 changes: 5 additions & 1 deletion qa-tests-backend/scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ set -euo pipefail

deploy_default_psp() {
info "Deploy Default PSP for stackrox namespace"
"${ROOT}/scripts/ci/create-default-psp.sh"
if [[ "$POD_SECURITY_POLICIES" != "false" ]]; then
"${ROOT}/scripts/ci/create-default-psp.sh"
else
info "POD_SECURITY_POLICIES is false, skip Deploy Default PSP for stackrox namespace"
fi
}

get_ECR_docker_pull_password() {
Expand Down
1 change: 1 addition & 0 deletions qa-tests-backend/scripts/run-compatibility.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ compatibility_test() {
fi

setup_deployment_env false false
setup_podsecuritypolicies_config
remove_existing_stackrox_resources
setup_default_TLS_certs

Expand Down
1 change: 1 addition & 0 deletions qa-tests-backend/scripts/run-part-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ config_part_1() {

setup_gcp
setup_deployment_env false false
setup_podsecuritypolicies_config
remove_existing_stackrox_resources
setup_default_TLS_certs "$ROOT/$DEPLOY_DIR/default_TLS_certs"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import objects.Secret
import objects.SecretKeyRef
import util.Helpers
import util.Timer
import util.Env

@Slf4j
class Kubernetes implements OrchestratorMain {
Expand Down Expand Up @@ -1654,7 +1655,8 @@ class Kubernetes implements OrchestratorMain {
}

protected defaultPspForNamespace(String namespace) {
PodSecurityPolicy psp = new PodSecurityPolicyBuilder().withNewMetadata()
if (Env.get("POD_SECURITY_POLICIES") != "false") {
PodSecurityPolicy psp = new PodSecurityPolicyBuilder().withNewMetadata()
.withName("allow-all-for-test")
.endMetadata()
.withNewSpec()
Expand All @@ -1672,9 +1674,10 @@ class Kubernetes implements OrchestratorMain {
.withNewFsGroup().withRule("RunAsAny").endFsGroup()
.endSpec()
.build()
client.policy().v1beta1().podSecurityPolicies().createOrReplace(psp)
createClusterRole(generatePspRole())
createClusterRoleBinding(generatePspRoleBinding(namespace))
client.policy().v1beta1().podSecurityPolicies().createOrReplace(psp)
createClusterRole(generatePspRole())
createClusterRoleBinding(generatePspRoleBinding(namespace))
}
}

/*
Expand Down
4 changes: 3 additions & 1 deletion scripts/ci/clair/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ if kubectl get ns "${namespace}"; then
kubectl delete ns "${namespace}" # handle CI re-runs
fi
kubectl create ns "${namespace}"
kubectl -n "${namespace}" apply -f "${DIR}/psp.yaml"
if [[ "$POD_SECURITY_POLICIES" != "false" ]]; then
kubectl -n "${namespace}" apply -f "${DIR}/psp.yaml"
fi

export POSTGRES_PASSWORD="${CLAIR_DB_PASSWORD}"
kubectl -n "${namespace}" create secret generic clairsecret --from-file="${DIR}/config.yaml"
Expand Down
22 changes: 22 additions & 0 deletions tests/e2e/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export PORT_FORWARD_LOGS="/tmp/port-forward-logs"

# shellcheck disable=SC2120
deploy_stackrox() {
setup_podsecuritypolicies_config

deploy_central

get_central_basic_auth_creds
Expand All @@ -39,6 +41,7 @@ deploy_stackrox_with_custom_sensor() {
die "expected sensor chart version as parameter in deploy_stackrox_with_custom_sensor"
fi
target_version="$1"
setup_podsecuritypolicies_config

deploy_central

Expand Down Expand Up @@ -211,6 +214,25 @@ setup_generated_certs_for_test() {
done
}

setup_podsecuritypolicies_config() {
info "Set POD_SECURITY_POLICIES variable based on kubernetes version"
local version
version=$(kubectl version --output json)
local majorVersion
majorVersion=$(echo "$version" | jq -r .serverVersion.major)
local minorVersion
minorVersion=$(echo "$version" | jq -r .serverVersion.minor)

# PodSecurityPolicy was removed in version 1.25
if (( "$majorVersion" >= 1 && "$minorVersion" >= 25 )); then
ci_export "POD_SECURITY_POLICIES" "false"
info "POD_SECURITY_POLICIES set to false"
else
ci_export "POD_SECURITY_POLICIES" "true"
info "POD_SECURITY_POLICIES set to true"
fi
}

patch_resources_for_test() {
info "Patch the loadbalancer and netpol resources for endpoints test"

Expand Down