Skip to content

Instrumentation CRD v1alpha1 missing securityContext on language specs — breaks restricted PSA #4894

@gustavovnicius

Description

@gustavovnicius

What happened?

The v1alpha1 Instrumentation CRD schema does not include securityContext on the language-specific specs (e.g. spec.java.securityContext). This means there is no way to explicitly set the security context on auto-instrumentation init containers via the Instrumentation CR.

Relationship with #4848

This issue is related to but separate from #4848:

With the operator pinned to pre-v0.146.0, the implicit inheritance works as a workaround. But the CRD should support explicit configuration for:

  1. Deployments where the app container security context differs from what the init container needs
  2. GitOps workflows where the desired state should be fully declarative in the CR
  3. Validation tooling that checks CRD manifests against the schema

Steps to reproduce

  1. Create a namespace with pod-security.kubernetes.io/enforce: restricted
  2. Apply an Instrumentation CR with spec.java.securityContext set:
    spec:
      java:
        securityContext:
          runAsNonRoot: true
          allowPrivilegeEscalation: false
          capabilities:
            drop: ["ALL"]
          seccompProfile:
            type: RuntimeDefault
  3. kubectl apply fails: strict decoding error: unknown field "spec.java.securityContext"
  4. kubectl apply --server-side also fails: field not declared in schema

Expected behavior

The securityContext field should be included in the Instrumentation CRD schema for all language specs, so that the init container security context can be set explicitly.

Environment

Workaround

Pin the operator to pre-v0.146.0. The init container security context is inherited from the app container automatically. This breaks in v0.146.0+ due to #4848.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions