Skip to content

Support kustomize patches for provider deployments #952

@broboa

Description

@broboa

User Story

As a cluster operator I would like to apply custom patches to provider deployments to work around upstream issues and meet organizational requirements without waiting for upstream fixes.

Detailed Description

The cluster-api-operator should support applying kustomize patches to provider deployment manifests. This would allow users to modify provider deployments for various needs, including security context configuration, resource limits, tolerations, node selectors, and other deployment customizations.

Current blocker: Provider deployments fail in namespaces with pod-security.kubernetes.io/enforce: restricted due to missing security context fields in upstream manifests. While this should be fixed at the provider level, operator support for patches would unblock users immediately.

Proposed enhancement to the provider CRDs (CoreProvider, BootstrapProvider, ControlPlaneProvider, InfrastructureProvider, AddonProvider):

Add a patches field that accepts strategic merge patches or JSON patches:

apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: InfrastructureProvider
metadata:
  name: kubevirt
  namespace: capk-system
spec:
  version: v0.1.10
  patches:
  - target:
      kind: Deployment
      name: capk-controller-manager
    patch: |-
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: capk-controller-manager
      spec:
        template:
          spec:
            containers:
            - name: manager
              securityContext:
                allowPrivilegeEscalation: false
                runAsNonRoot: true
                capabilities:
                  drop:
                    - ALL
                seccompProfile:
                  type: RuntimeDefault

This would allow the operator to apply patches to provider manifests before deploying them, similar to how kustomize works.

Anything else you would like to add:

This is a more flexible solution than adding specific fields for security context, resource limits, etc. It follows the kustomize pattern that users are already familiar with and allows for any deployment customization without requiring operator API changes.

Use cases:

  • Adding security contexts for PodSecurity restricted policy compliance
  • Adjusting resource limits/requests
  • Adding tolerations or node selectors
  • Injecting sidecars or init containers
  • Modifying environment variables or volume mounts

While upstream providers should ship with secure defaults, this feature would:

  1. Unblock users immediately when upstream issues exist
  2. Allow customization for organization-specific requirements
  3. Enable testing of fixes before they're merged upstream

Related issue:

/kind feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureCategorizes issue or PR as related to a new feature.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions