Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -euo pipefail
# Capture first: `git diff | grep -q` under pipefail can fail with SIGPIPE
# when grep stops reading early, which would skip the regeneration.
staged=$(git diff --cached --name-only)
if ! grep -qE '^(charts/saw-bom/profiles/|charts/governance-policy/profiles/|charts/openshell-saw/files/provider-profiles/|charts/openshell-saw/files/installer/saw_ui_limit\.py$|charts/saw-workspace-relay/files/saw_ui_limit\.py$|charts/openshell-saw/templates/_governed-proxy-policy\.tpl$|charts/saw-users/files/workspace\.py$|charts/openshell-keycloak/files/saw_keycloak_admin\.py$|scripts/saw-profile-catalog\.py$)' <<<"$staged"; then
if ! grep -qE '^(charts/saw-bom/profiles/|charts/governance-policy/profiles/|charts/openshell-saw/files/provider-profiles/|charts/openshell-saw/files/installer/saw_ui_limit\.py$|charts/saw-workspace-relay/files/saw_ui_limit\.py$|charts/(saw-portal-container|saw-users|openshell-rhdh)/files/preflight\.py$|charts/openshell-saw/templates/_governed-proxy-policy\.tpl$|charts/saw-users/files/workspace\.py$|charts/openshell-keycloak/files/saw_keycloak_admin\.py$|scripts/saw-profile-catalog\.py$)' <<<"$staged"; then
exit 0
fi

Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/deployment-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:
sudo install -m 0755 "$RUNNER_TEMP/kubeconform" /usr/local/bin/kubeconform
- name: Validate deployment and dependencies
run: make test-dependencies
- name: Validate optional Trustee pattern selection and propagation
run: |
helm pull clustergroup --repo https://charts.validatedpatterns.io \
--version 0.9.61 --untar --untardir "$RUNNER_TEMP/saw-pattern-check"
uv run --locked scripts/ci/check_confidential_pattern.py \
--chart "$RUNNER_TEMP/saw-pattern-check/clustergroup"
- uses: actions/upload-artifact@v4
if: always()
with:
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/profile-catalog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ on:
- "charts/openshell-saw/files/provider-profiles/**"
- "charts/openshell-saw/files/installer/saw_ui_limit.py"
- "charts/saw-workspace-relay/files/saw_ui_limit.py"
- "charts/saw-portal-container/files/preflight.py"
- "charts/saw-users/files/preflight.py"
- "charts/openshell-rhdh/files/preflight.py"
- "charts/openshell-keycloak/files/saw_keycloak_admin.py"
- "charts/openshell-rhdh/files/saw_keycloak_admin.py"
- "charts/saw-users/files/workspace.py"
Expand All @@ -47,6 +50,9 @@ on:
- "charts/openshell-saw/files/provider-profiles/**"
- "charts/openshell-saw/files/installer/saw_ui_limit.py"
- "charts/saw-workspace-relay/files/saw_ui_limit.py"
- "charts/saw-portal-container/files/preflight.py"
- "charts/saw-users/files/preflight.py"
- "charts/openshell-rhdh/files/preflight.py"
- "charts/openshell-saw/templates/_governed-proxy-policy.tpl"
- "charts/saw-bom/profiles/**"
- "charts/openshell-keycloak/files/saw_keycloak_admin.py"
Expand Down
4 changes: 4 additions & 0 deletions Makefile-quickstart
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ e2e-workspace: .check-saw-name .check-deployment-mode ## Check one workspace end
test-dependencies: ## Validate rendered charts and deployment dependencies
@uv run --locked scripts/ci/deployment_validation.py --report deployment-validation.json

.PHONY: kata-operator-check
kata-operator-check: ## Check the installed OSC Subscription and CSV before adding Kata users
@python3 scripts/check-sandboxed-operator.py

test-pattern-e2e: ## Run E2E checks on a fresh cluster; cleanup is separate
@uv run --locked scripts/ci/pattern_e2e.py

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ More detail: [deployment guide](docs/deployment-guide.md),
endpoint.
- Kata workspaces also need OpenShift sandboxed containers
([Kata guide](docs/kata-workspaces.md)).
The pattern installs its operator; Kata registration requires its installed
CSV to be `Succeeded`, in addition to runtime and worker readiness.
- Optional Red Hat build of Trustee installation is controlled by
`global.confidential.enabled` ([Trustee setup](docs/trustee.md)). It defaults
to false and does not activate confidential workspaces by itself.

## Installation

Expand Down
3 changes: 3 additions & 0 deletions charts/openshell-rhdh/files/portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@ def check_workspace_preflight(k8s, user, site, mode, profile, catalog):
configs = k8s.call("GET", "/apis/kataconfiguration.openshift.io/v1/kataconfigs").get("items", [])
nodes = k8s.call("GET", "/api/v1/nodes").get("items", [])
kata_crd = "kataconfigs.kataconfiguration.openshift.io"
api_readiness["sandboxedOperator"] = _preflight.sandboxed_operator_ready(
k8s.call("GET", _preflight.OSC_SUBSCRIPTIONS_PATH).get("items"),
k8s.call("GET", _preflight.OSC_CSVS_PATH).get("items"))
api_readiness[kata_crd] = _preflight.crd_established(k8s.call(
"GET", "/apis/apiextensions.k8s.io/v1/customresourcedefinitions/" + kata_crd,
ok404=True))
Expand Down
44 changes: 44 additions & 0 deletions charts/openshell-rhdh/files/preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def __init__(self, reason):
"storage", "secrets", "registry", "providerEgress", "revisions",
)
KATA_CHECKS = ("osc", "kataConfig", "workers", "runtimeClass")
OSC_NAMESPACE = "openshift-sandboxed-containers-operator"
OSC_API = "/apis/operators.coreos.com/v1alpha1/namespaces/" + OSC_NAMESPACE
OSC_SUBSCRIPTIONS_PATH = OSC_API + "/subscriptions"
OSC_CSVS_PATH = OSC_API + "/clusterserviceversions"

# This pinned image has /sandbox mode 0770, owned by 1000:0. The OpenShift
# namespace UID cannot traverse it. The reviewed notebook build adds o+x.
Expand Down Expand Up @@ -368,6 +372,44 @@ def crd_established(obj):
and condition.get("status") == "True" for condition in conditions)


def sandboxed_operator_ready(subscriptions, csvs):
"""Require the OSC Subscription's installed CSV, not a leftover Kata CRD."""
if not isinstance(subscriptions, list) or not isinstance(csvs, list):
return False
installed = set()
for csv in csvs:
if not isinstance(csv, dict):
continue
metadata, status = csv.get("metadata") or {}, csv.get("status") or {}
if (isinstance(metadata, dict) and isinstance(status, dict)
and metadata.get("namespace") == OSC_NAMESPACE
and not metadata.get("deletionTimestamp")
and status.get("phase") == "Succeeded"):
name = metadata.get("name")
if isinstance(name, str):
installed.add(name)
for subscription in subscriptions:
if not isinstance(subscription, dict):
continue
metadata = subscription.get("metadata") or {}
spec, status = subscription.get("spec") or {}, subscription.get("status") or {}
if not all(isinstance(value, dict) for value in (metadata, spec, status)):
continue
if (metadata.get("namespace") != OSC_NAMESPACE or metadata.get("deletionTimestamp")
or spec.get("name") != "sandboxed-containers-operator"):
continue
conditions = status.get("conditions") or []
if not isinstance(conditions, list) or any(
isinstance(item, dict) and item.get("status") == "True"
and item.get("type") in {"ResolutionFailed", "InstallPlanFailed"}
for item in conditions):
continue
name = status.get("installedCSV")
if isinstance(name, str) and name in installed:
return True
return False


def api_resources_available(discovery, group_version, resource_names):
"""Check served API resources from discovery, including built-in APIs."""
if not isinstance(discovery, dict) or discovery.get("groupVersion") != group_version:
Expand Down Expand Up @@ -430,6 +472,8 @@ def verify_kata_platform(site, runtime_class, kata_configs, nodes, api_readiness
raise PreflightError("AgentSandboxUnavailable")
if api_readiness.get("kataconfigs.kataconfiguration.openshift.io") is not True:
raise PreflightError("SandboxedContainersUnavailable")
if api_readiness.get("sandboxedOperator") is not True:
raise PreflightError("SandboxedContainersUnavailable")
if not isinstance(kata_configs, list):
raise PreflightError("KataConfigNotReady")
ready_configs = [item for item in kata_configs
Expand Down
24 changes: 24 additions & 0 deletions charts/openshell-rhdh/templates/osc-preflight-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if has "kata" .Values.portal.deploymentModes }}
# OLM metadata only, scoped to the platform operator's namespace.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: saw-portal-osc-preflight
namespace: openshift-sandboxed-containers-operator
rules:
- apiGroups: [operators.coreos.com]
resources: [subscriptions, clusterserviceversions]
verbs: [list]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: saw-portal-osc-preflight
namespace: openshift-sandboxed-containers-operator
roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: saw-portal-osc-preflight}
subjects:
- {kind: ServiceAccount, name: {{ .Values.portal.provisionerServiceAccount }}, namespace: {{ .Values.portal.namespace }}}
{{- if ne .Values.portal.provisionerServiceAccount "saw-workspaces-generator" }}
- {kind: ServiceAccount, name: saw-workspaces-generator, namespace: {{ .Values.portal.namespace }}}
{{- end }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/saw-portal-container/files/enroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from saw_kubernetes.compiler import compile_profile_files, digest
from saw_kubernetes.intent import build_intent
from preflight import PreflightError, api_resources_available, crd_established, verify_kata_platform
from preflight import OSC_SUBSCRIPTIONS_PATH, OSC_CSVS_PATH, sandboxed_operator_ready
from portal_contract import verify_contract
from receipt import receipt_key
from gateway_ca import read_public_ca
Expand Down Expand Up @@ -67,6 +68,8 @@ def obj(kind,name,namespace=ns):
if exc.code == 404:raise PreflightError("ClusterVersionUnavailable") from None
raise
api_readiness={}
api_readiness["sandboxedOperator"]=sandboxed_operator_ready(
api(OSC_SUBSCRIPTIONS_PATH).get("items"), api(OSC_CSVS_PATH).get("items"))
for name in ("kataconfigs.kataconfiguration.openshift.io", "sandboxes.agents.x-k8s.io",
"externalsecrets.external-secrets.io", "adminnetworkpolicies.policy.networking.k8s.io"):
try:
Expand Down
44 changes: 44 additions & 0 deletions charts/saw-portal-container/files/preflight.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def __init__(self, reason):
"storage", "secrets", "registry", "providerEgress", "revisions",
)
KATA_CHECKS = ("osc", "kataConfig", "workers", "runtimeClass")
OSC_NAMESPACE = "openshift-sandboxed-containers-operator"
OSC_API = "/apis/operators.coreos.com/v1alpha1/namespaces/" + OSC_NAMESPACE
OSC_SUBSCRIPTIONS_PATH = OSC_API + "/subscriptions"
OSC_CSVS_PATH = OSC_API + "/clusterserviceversions"

# This pinned image has /sandbox mode 0770, owned by 1000:0. The OpenShift
# namespace UID cannot traverse it. The reviewed notebook build adds o+x.
Expand Down Expand Up @@ -368,6 +372,44 @@ def crd_established(obj):
and condition.get("status") == "True" for condition in conditions)


def sandboxed_operator_ready(subscriptions, csvs):
"""Require the OSC Subscription's installed CSV, not a leftover Kata CRD."""
if not isinstance(subscriptions, list) or not isinstance(csvs, list):
return False
installed = set()
for csv in csvs:
if not isinstance(csv, dict):
continue
metadata, status = csv.get("metadata") or {}, csv.get("status") or {}
if (isinstance(metadata, dict) and isinstance(status, dict)
and metadata.get("namespace") == OSC_NAMESPACE
and not metadata.get("deletionTimestamp")
and status.get("phase") == "Succeeded"):
name = metadata.get("name")
if isinstance(name, str):
installed.add(name)
for subscription in subscriptions:
if not isinstance(subscription, dict):
continue
metadata = subscription.get("metadata") or {}
spec, status = subscription.get("spec") or {}, subscription.get("status") or {}
if not all(isinstance(value, dict) for value in (metadata, spec, status)):
continue
if (metadata.get("namespace") != OSC_NAMESPACE or metadata.get("deletionTimestamp")
or spec.get("name") != "sandboxed-containers-operator"):
continue
conditions = status.get("conditions") or []
if not isinstance(conditions, list) or any(
isinstance(item, dict) and item.get("status") == "True"
and item.get("type") in {"ResolutionFailed", "InstallPlanFailed"}
for item in conditions):
continue
name = status.get("installedCSV")
if isinstance(name, str) and name in installed:
return True
return False


def api_resources_available(discovery, group_version, resource_names):
"""Check served API resources from discovery, including built-in APIs."""
if not isinstance(discovery, dict) or discovery.get("groupVersion") != group_version:
Expand Down Expand Up @@ -430,6 +472,8 @@ def verify_kata_platform(site, runtime_class, kata_configs, nodes, api_readiness
raise PreflightError("AgentSandboxUnavailable")
if api_readiness.get("kataconfigs.kataconfiguration.openshift.io") is not True:
raise PreflightError("SandboxedContainersUnavailable")
if api_readiness.get("sandboxedOperator") is not True:
raise PreflightError("SandboxedContainersUnavailable")
if not isinstance(kata_configs, list):
raise PreflightError("KataConfigNotReady")
ready_configs = [item for item in kata_configs
Expand Down
14 changes: 14 additions & 0 deletions charts/saw-portal-container/templates/auto-enroll.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ kind: ClusterRoleBinding
metadata: {name: {{ $t }}-{{ $name }}}
roleRef: {apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: {{ $t }}-{{ $name }}}
subjects: [{kind: ServiceAccount, name: {{ $name }}, namespace: {{ $t }}}]
{{- if $s.kataRuntimeClass }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: {name: {{ $t }}-{{ $name }}-osc, namespace: openshift-sandboxed-containers-operator}
rules:
- {apiGroups: [operators.coreos.com], resources: [subscriptions, clusterserviceversions], verbs: [list]}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata: {name: {{ $t }}-{{ $name }}-osc, namespace: openshift-sandboxed-containers-operator}
roleRef: {apiGroup: rbac.authorization.k8s.io, kind: Role, name: {{ $t }}-{{ $name }}-osc}
subjects: [{kind: ServiceAccount, name: {{ $name }}, namespace: {{ $t }}}]
{{- end }}
{{- range $ns := list $n $t $gov }}
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
5 changes: 5 additions & 0 deletions charts/saw-trustee/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: saw-trustee
description: Optional Red Hat build of Trustee with a Restricted profile and closed bootstrap ingress
type: application
version: 0.1.0
35 changes: 35 additions & 0 deletions charts/saw-trustee/templates/trustee.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if .Values.global.confidential.enabled }}
{{- $t := .Values.trustee }}
# Keep bootstrap KBS inaccessible to workloads until measured, registration-
# specific authorization and ingress are implemented. The vendor operator owns
# its generated policies; do not race it by pre-creating those ConfigMaps.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ $t.name }}-bootstrap-deny
namespace: {{ .Release.Namespace }}
annotations:
argocd.argoproj.io/sync-wave: '-1'
argocd.argoproj.io/sync-options: Prune=false,Delete=false
spec:
podSelector:
matchLabels:
app: kbs
policyTypes: [Ingress]
ingress: []
---
apiVersion: confidentialcontainers.org/v1alpha1
kind: TrusteeConfig
metadata:
name: {{ $t.name }}
namespace: {{ .Release.Namespace }}
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true,Prune=false,Delete=false
spec:
profileType: Restricted
kbsServiceType: ClusterIP
httpsSpec:
tlsSecretName: {{ $t.httpsSecretName | quote }}
attestationTokenVerificationSpec:
tlsSecretName: {{ $t.attestationTokenSecretName | quote }}
{{- end }}
27 changes: 27 additions & 0 deletions charts/saw-trustee/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://json-schema.org/draft-07/schema#",
"type": "object",
"required": ["global", "trustee"],
"properties": {
"global": {
"type": "object",
"required": ["confidential"],
"properties": {
"confidential": {
"type": "object",
"required": ["enabled"],
"properties": {"enabled": {"type": "boolean"}}
}
}
},
"trustee": {
"type": "object",
"required": ["name", "httpsSecretName", "attestationTokenSecretName"],
"properties": {
"name": {"type": "string", "maxLength": 40, "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"},
"httpsSecretName": {"type": "string", "minLength": 1, "maxLength": 253, "pattern": "^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$"},
"attestationTokenSecretName": {"type": "string", "minLength": 1, "maxLength": 253, "pattern": "^[a-z0-9]([-a-z0-9.]*[a-z0-9])?$"}
}
}
}
}
10 changes: 10 additions & 0 deletions charts/saw-trustee/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
global:
confidential:
enabled: false

# Existing kubernetes.io/tls Secrets in the release namespace. The operator
# reads these; Helm never reads or generates private key material.
trustee:
name: saw-trustee
httpsSecretName: saw-trustee-https
attestationTokenSecretName: saw-trustee-token
Loading
Loading