Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - Add Support for Owner References in Kubernetes Driver #2626

Open
ali-kafel opened this issue Jul 24, 2024 · 0 comments
Open
Labels
area/driver/kubernetes help wanted Extra attention is needed kind/enhancement New feature or request

Comments

@ali-kafel
Copy link

ali-kafel commented Jul 24, 2024

Description

Hello,

I would like to have the ability to specify Kubernetes Owner References via the Docker Buildx CLI when using the Kubernetes driver. This feature will enhance the integration between Docker Buildx and Kubernetes, allowing resources created during the build process (e.g., Pods, Deployments) to automatically adopt ownership lifecycle policies.

Currently, Docker Buildx allows specifying a variety of options and configurations when using the Kubernetes driver. However, a critical lifecycle management feature is missing: the ability to set ownerReferences on Kubernetes resources like Pods directly through the Buildx CLI.

CLI and Driver Enhancements:

  • Provide new --driver-opt options to specify ownerReferences.
  • Allow users to pass owner reference details (e.g., apiVersion, kind, name, uid, controller, blockOwnerDeletion).

Use Case:
This feature is particularly useful for integrating Docker Buildx with ephemeral GitHub Actions runners or other resources that have dynamic lifecycles. For instance, in CI/CD environments, deployments or Pods created as a part of the build process should be cleaned up automatically when the controlling resource is deleted.

Current Manual Process:
Currently, we are manually adding the owner reference to a Buildx builder deployment to a runner. See an example:

> kubectl patch deployment builder-2f073425-0441-48bc-8ed2-2d8a286158001 --type='json' -p='[{"op": "replace", "path": "/metadata/ownerReferences", "value":[{"apiVersion": "actions.github.com/v1alpha1", "kind": "EphemeralRunner", "name": "large-dind-spot-rjz82-runner-4w7sp", "uid": "b636330d-26b7-417a-8464-c2641438feed", "controller": true, "blockOwnerDeletion": false}]}]'

> kubectl get ephemeralrunner large-dind-spot-rjz82-runner-4w7sp
Error from server (NotFound): ephemeralrunners.actions.github.com "large-dind-spot-rjz82-runner-4w7sp" not found

> kubectl get deployment builder-2f073425-0441-48bc-8ed2-2d8a286158001
Error from server (NotFound): deployments.apps "builder-2f073425-0441-48bc-8ed2-2d8a286158001" not found

This ensures that when the runner is deleted, the builder is deleted as well. This works much better than running the cleanup at the end of a GitHub Actions job since there are cases where a runner will exit prematurely and never actually run the builder cleanup at the end of a job.

Adding an owner reference ensures the builder deployment will be a part of the GitHub Actions runner lifecycle in Kubernetes.

Thank You

@ali-kafel ali-kafel added kind/enhancement New feature or request status/triage labels Jul 24, 2024
@crazy-max crazy-max added area/driver/kubernetes help wanted Extra attention is needed and removed status/triage labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/driver/kubernetes help wanted Extra attention is needed kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants