Skip to content

Commit

Permalink
Merge branch 'feature/namespace-add-podsecurity-label' into 'v3'
Browse files Browse the repository at this point in the history
kubernetes: Add support for PodSecurity labeling

See merge request anders/ci-configuration!370
  • Loading branch information
antti-mikael committed Sep 8, 2023
2 parents fabbbfc + 92cb851 commit 3bc7332
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitlab-ci-base-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ variables:
SERVICE_ARTIFACT_FOLDER: "service_artifacts"
BUILD_ARTIFACT_FOLDER: "build_artifacts"

# Default PodSecurity label
K8S_POD_SECURITY: baseline

# Kolga branch used in the pipeline
KOLGA_BRANCH: "v3"

.build:
Expand Down
11 changes: 11 additions & 0 deletions kolga/libs/kubernetes.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,17 @@ def get_namespace_labels() -> Dict[str, str]:
# TODO: Un-hardcode this label
labels = {"app": "kubed"}

if settings.K8S_POD_SECURITY:
if settings.K8S_POD_SECURITY not in (
"privileged",
"baseline",
"restricted",
):
logger.warning(
f"Unknown pod security standard: {settings.K8S_POD_SECURITY}"
)
labels["pod-security.kubernetes.io/enforce"] = settings.K8S_POD_SECURITY

if settings.PROJECT_ID:
labels["kolga.io/project_id"] = settings.PROJECT_ID

Expand Down
1 change: 1 addition & 0 deletions kolga/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ class SettingsValues(BaseSettings):
K8S_PERSISTENT_STORAGE_PATH: str = ""
K8S_PERSISTENT_STORAGE_SIZE: str = "1Gi"
K8S_PERSISTENT_STORAGE_STORAGE_TYPE: str = "standard"
K8S_POD_SECURITY: str = ""
K8S_PROBE_FAILURE_THRESHOLD: int = 3
K8S_PROBE_INITIAL_DELAY: int = 60
K8S_PROBE_PERIOD: int = 10
Expand Down
6 changes: 4 additions & 2 deletions utils/check-style
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ set -u
# Change working directory to project root
cd "$(dirname "$0")/.."

set -x

flake8
isort . -c
black . --check
isort . --check
black . --check --diff

0 comments on commit 3bc7332

Please sign in to comment.