Skip to content

feat(project): add KinD configuration options and DinD support - #395

Open
nkzk wants to merge 28 commits into
crossplane:mainfrom
nkzk:feat-project-closed-networks
Open

nkzk wants to merge 28 commits into
crossplane:mainfrom
nkzk:feat-project-closed-networks

Conversation

@nkzk

@nkzk nkzk commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description of your changes

This PR adds support for running crossplane project in devcontainers and closed company networks with the following changes:

  1. Add configuration options for KinD in crossplane-project.yaml.

    • Allow the user to specify their own kind-config (to avoid the need for more updates and flags to support other kind options later, ref. Adam's comment in this issue)
    • Add options to:
      • specify which containers to attach to the kind-network
        • i first implemented configuration of the kind network with the experimental KIND_EXPERIMENTAL_DOCKER_NETWORK feature, but since this is a potentially unstable feature, i refactored it to instead attach specified containers to the kind cluster network.
      • use internal KinD kubeconfig.
      • specify registry storage type (ref explanation below)
    Example crossplane-project file
     apiVersion: dev.crossplane.io/v1alpha1
     kind: Project
     metadata:
       name: example
     spec:
       dependencies:
         - type: xpkg
           xpkg:
             apiVersion: pkg.crossplane.io/v1
             kind: Function
             package: xpkg.crossplane.io/crossplane-contrib/function-go-templating
             version: "v0.12.4"
         - type: xpkg
           xpkg:
             apiVersion: pkg.crossplane.io/v1
             kind: Provider
             package: xpkg.crossplane.io/crossplane-contrib/provider-kubernetes
             version: "v1.3.1"
       repository: example.com/my-org/example
      # New runtime field 
       runtime:
         registry:
           storage:
             type: volume
         kind:
           config:
             path: kind-config.yaml
           internal: true
           network:
             attachContainers:
               - my-container
  1. Support registry data sideloading when running crossplane project in Docker-in-Docker

    When running crossplane project in a container, bind-mounting the CLI’s local registry directory into the registry container mounts an empty host path, leaving the registry without its certificates and package data.
    This happens because the generated files are only in the container where the command was ran, and not on the host.

    I added a storage interface where the bind-mount implementation ensures we keep old behavior, and a config-flag to use a volume-implementation. This required some refactoring of the code, for example moving where certs are created so they can be initalized in the docker-volume.

Fixes #313

With these changes, a user in a closed company network and devcontainer can run crossplane project with the following files and command

NOTE: subject to change ref. this comment

./crossplane-project.yaml
apiVersion: dev.crossplane.io/v1alpha1
kind: Project
metadata:
  name: example
spec:
  dependencies:
    - type: xpkg
      xpkg:
        apiVersion: pkg.crossplane.io/v1
        kind: Function
        package: xpkg.crossplane.io/crossplane-contrib/function-go-templating
        version: "v0.12.4"
    - type: xpkg
      xpkg:
        apiVersion: pkg.crossplane.io/v1
        kind: Provider
        package: xpkg.crossplane.io/crossplane-contrib/provider-kubernetes
        version: "v1.3.1"
  repository: example.com/my-org/example
  runtime:
      registry:
        storage:
          type: volume
      kind:
        config:
          path: kind-config.yaml
        internal: true
        network:
          attachContainers:
            - my-container
./kind-config.yaml
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
containerdConfigPatches:
  - |
    [plugins."io.containerd.grpc.v1.cri".registry.mirrors]
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
        endpoint = ["https://docker-remote.my-registry.com"]
      [plugins."io.containerd.grpc.v1.cri".registry.mirrors."ghcr.io"]
        endpoint = ["https://ghcr-remote.my-registry.com"]
./image-configs.yaml
---
apiVersion: pkg.crossplane.io/v1beta1
kind: ImageConfig
metadata:
  name: docker.io
spec:
  matchImages:
    - prefix: docker.io
  rewriteImage:
    prefix: docker-remote.my-registry.com
---
apiVersion: pkg.crossplane.io/v1beta1
kind: ImageConfig
metadata:
  name:  ghcr.io
spec:
  matchImages:
    - prefix: ghcr.io
  rewriteImage:
    prefix: ghcr-remote.my-registry.com
crossplane project run --init-resources=image-configs.yaml

I have:

Need help with this checklist? See the cheat sheet.

@nkzk
nkzk force-pushed the feat-project-closed-networks branch 3 times, most recently from 450403a to e272f26 Compare October 1, 2026 11:30
@nkzk

nkzk commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Before review, I want to refactor this again so that the registry-storage works like before by default, and add a config flag for the docker-volume method. I think that will be cleaner and better.

Comment thread cmd/crossplane/project/run.go Resolved
Comment thread cmd/crossplane/project/run.go Resolved
Comment thread internal/docker/docker.go Resolved
Comment thread internal/docker/storage.go Resolved
Comment thread internal/docker/storage.go Resolved
Comment thread internal/docker/storage.go Resolved
@nkzk
nkzk force-pushed the feat-project-closed-networks branch from d87dd05 to 4d44ebc Compare October 2, 2026 14:56
Comment thread apis/dev/v1alpha1/project_types.go Resolved
Comment thread apis/dev/v1alpha1/project_types.go Resolved
Comment thread apis/dev/v1alpha1/project_types.go Resolved
Comment thread cmd/crossplane/project/run.go Resolved
Comment thread cmd/crossplane/project/run.go Resolved
@nkzk
nkzk force-pushed the feat-project-closed-networks branch from 5b4ba76 to 93f6845 Compare October 2, 2026 15:17
Comment thread internal/docker/docker.go Resolved
@nkzk
nkzk force-pushed the feat-project-closed-networks branch 3 times, most recently from 65fed25 to ba0f07e Compare October 5, 2026 08:31
@nkzk
nkzk marked this pull request as ready for review October 5, 2026 08:33
nkzk and others added 20 commits November 25, 2026 18:09
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
…o select storage-type

the bindmount implementation ensures that we keep old behavior, and the volume implementation is for DinD support

Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
…ied network

Signed-off-by: Nikita Z <nkzk95@gmail.com>
…specified network

Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Nikita Zakharov <54776184+nkzk@users.noreply.github.com>
…ners instead of docker-network

Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
@nkzk
nkzk force-pushed the feat-project-closed-networks branch from 1825971 to 182739e Compare November 25, 2026 17:16
@nkzk

nkzk commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for taking this on, @nkzk, and sorry it's taken so long for me to review. Overall, this looks good to me.

I've left a few notes around validation and defaulting for the project API - as you said in reply to coderabbit, kubebuilder annotations aren't useful here since the project types don't end up in a cluster, but we do implement centralized validation and defaulting for consistency across the project-related commands.

Went through your comments and moved defaults/validations/StorageType to apis/, and added cases in validation_test.go in cd3f9f8.

Also expanded the "maximum config" test in 73302cc, and spotted a simplification of the "storageMatch" check which was added after a coderabbit review: 07e486d.

I ran lint and flake check, looks good.

@nkzk
nkzk requested a review from adamwg November 25, 2026 17:18

@adamwg adamwg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the updates.

I believe there's follow-up work to do to improve the cert handling, so that user-provided configs don't need to include the containerd config patch we have in the default one (or other workarounds), but this change is usable without that work. Am I correct? If so I'll get this merged :-).

Comment thread cmd/crossplane/project/run.go Resolved
@nkzk

nkzk commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

LGTM, thanks for the updates.

I believe there's follow-up work to do to improve the cert handling, so that user-provided configs don't need to include the containerd config patch we have in the default one (or other workarounds), but this change is usable without that work. Am I correct? If so I'll get this merged :-).

Nice, np! Yes its usable, i think being able to bring your own kind config opens up a few options!

If i recall correctly from the containterd config docs, i think that patch is actually no longer necessary. But I agree, there could be some followup to improve containerd cert configuration. Seems like more people than us are having this issue!

I could look into it if you want:)

I tested the latest changes myself with different config variations, but since im in a special environment (devcontainer and closed network) maybe you could give it a spin first?

If you have some seconds thoughts on the API, i'd be happy to make changes. I tried to make it extendable and not lock us in too much, but i wasnt that creative with the 'internal' boolean.

nkzk added 2 commits November 26, 2026 09:37
Signed-off-by: Nikita Z <nkzk95@gmail.com>
…he configuration in the project-file

Signed-off-by: Nikita Z <nkzk95@gmail.com>
@nkzk
nkzk force-pushed the feat-project-closed-networks branch from ea5542b to d91d978 Compare November 26, 2026 08:37
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.54271% with 182 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.97%. Comparing base (14a9f58) to head (d91d978).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Nikita Z <nkzk95@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal(crossplane project): add configuration options to support users in closed networks and devcontainers

3 participants