actions / actions/actions-runner-controller

Add OpenAPI metadata for kustomize patches

Open
#2,620 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs triage
Dominant language
Go
Stars
6.5k
Forks
1.5k
Avg merge
2d 2h
Merged PRs (30d)
27

Description

What would you like added?

Support for kustomize strategic merge patches. This can be done by adding specific x-kubernetes-patch-* metadata keys to the CRD OpenAPI schema.

Why is this needed?

Currently when applying a strategic merge patch to resources like RunnerDeployments or RunnerSets, lists/arrays of objects always get clobbered by the patch instead of merged. It would be nice to be able to apply a patch that contains baseline/required values for the resources, and have those values appended instead of replaced.

Here is an example of the issue and my specific use case:

runner.yaml:

---
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: my-runner
spec:
  replicas: 1
  template:
    spec:
      ephemeral: true
      repository: my-repo
      labels:
        - runner-label
      tolerations:
        - key: firstTaint
          operator: Equal
          value: firstTaintValue
          effect: NoSchedule

patch.yaml:

---
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: This field is required by kustomize but ignored
spec:
  template:
    spec:
      labels:
        - required-label
      tolerations:
        - key: secondTaint
          operator: Equal
          value: secondTaintValue
          effect: NoSchedule

kustomization.yaml:

---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: actions-runner-controller
resources:
  - runner.yaml
# There are additional runners here that are omitted for brevity's sake
patches:
  - path: ./patch.yaml
    target:
      kind: RunnerDeployment

Output:

---
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: my-runner
spec:
  replicas: 1
  template:
    spec:
      ephemeral: true
      repository: my-repo
      labels:
        - runner-label
        - required-label
      tolerations:
        - key: secondTaint
          operator: Equal
          value: secondTaintValue
          effect: NoSchedule

This would be the ideal output:

---
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
  name: my-runner
spec:
  replicas: 1
  template:
    spec:
      ephemeral: true
      repository: my-repo
      labels:
        - runner-label
        - required-label
      tolerations:
        - key: firstTaint
          operator: Equal
          value: firstTaintValue
          effect: NoSchedule
        - key: secondTaint
          operator: Equal
          value: secondTaintValue
          effect: NoSchedule
Additional context

Here's details on the feature and how it can be added:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Kustomize customOpenAPIschema documentation and the KEP linked in the issue, then inspect the CRD OpenAPI schema used for RunnerDeployment and RunnerSet. Use runner.yaml, patch.yaml, and kustomization.yaml as the reproduction, and verify that the resulting labels and tolerations preserve entries from both resources.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes, openapi
Domain
api, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.