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

Support Dev Containers / Github Codespaces #121561

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Sharpz7
Copy link
Contributor

@Sharpz7 Sharpz7 commented Oct 27, 2023

Based on: https://github.com/craiglpeters/kubernetes-devcontainer

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds support for devcontainers. Right now, it will take a significant amount of time to build - but ideally I would want to also create an image that is built as part of this, maybe in its own repo, that could then be pulled to speed up build times.
Also a wider discussion on whether you would want to support devcontainers all over k8s should probably happen.

kubernetes/test-infra#30454
kubernetes/test-infra#30511 (comment)

Right now, I have added a custom golang install feature that can take advantage of .go-version being present, but maybe there is a more elegant solution we can use?
I tried this and it didn't work - my bet is the devcontainer is being created before the repo is present so the version cannot be found. This means we now have the version stated in two places... not ideal.

Which issue(s) this PR fixes:

Fixes #113019

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Adds the code/configs to allow for users to use dev-containers when developing k8s. This brings support for GitHub Codespaces, EnvBuilder, the devcontainer-cli and more.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [Usage]: https://github.com/features/codespaces
- [More Info]: https://containers.dev/

/kind feature
/assign @Sharpz7
/sig architecture
/sig contributor-experience

cc @craiglpeters

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Oct 27, 2023
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 27, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @Sharpz7. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 27, 2023
@mrbobbytables
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 27, 2023
@mrbobbytables
Copy link
Member

This PR replaces #120551 and addresses the feedback I left in #120551 (review) (adding an owners file)

I verified that it works and I was successfully able to build kubernetes.

/assign dims cblecker
/priority important-soon
/triage accepted

@k8s-ci-robot k8s-ci-robot added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Oct 27, 2023
@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 27, 2023
@mrbobbytables
Copy link
Member

and I forgot to lgtm in my last comment 🤦

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 27, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 5a5e75f1eff9969fb9271d0d73c0f9715d7f2951

.devcontainers/OWNERS Outdated Show resolved Hide resolved
Copy link
Member

@cblecker cblecker left a comment

Choose a reason for hiding this comment

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

Some questions before we move forward
/hold

.devcontainers/OWNERS Outdated Show resolved Hide resolved
.devcontainers/devcontainer.json Outdated Show resolved Hide resolved
.devcontainers/devcontainer.json Outdated Show resolved Hide resolved
.devcontainers/devcontainer.json Outdated Show resolved Hide resolved
.devcontainers/devcontainer.json Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 27, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Sharpz7
Once this PR has been reviewed and has the lgtm label, please ask for approval from cblecker. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

.devcontainers/OWNERS Outdated Show resolved Hide resolved
@Sharpz7
Copy link
Contributor Author

Sharpz7 commented Oct 30, 2023

@cblecker just a general catch-all for your points.

They are all valid, devcontainers is such a wide standard that anything is possible. But, I would argue that things like our own Docker Image, and building kubectl from source, slow down the build significantly. There is a trade-off here between speed, closeness to ground-truth, and number of files (and how many locations those files are in).

I think the idea is this would be the initial run, and then we would improve what we do overtime. For now, I think this is mostly okay - you can follow the guides easily.

@cblecker
Copy link
Member

@Sharpz7 The tradeoff that I'm considering here is sustainability. I would rather us have something that is slow, but that keeps updated over time as opposed to something that is fast but needs regular maintenance to keep it up to date. I'm all for iterating over time to improve things, but I'd rather it be "hey this always works, but is slow.. maybe we can make it faster" rather than "hey this stopped working.. oh someone needs to go PR in a change to update an image/version/etc to make it useful again".

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 3, 2023
@Sharpz7
Copy link
Contributor Author

Sharpz7 commented Nov 3, 2023

Since we are optimising:

  • I would like to try and not need the "local features", we should use scripts already in the repo (like with etcd for example).
  • I want the go version to be found automatically, its still an env var we would have the manually bump.
  • I am 50/50 on whether we build kubectl from source. I think it boils down to what would the average developer expect? I would lean towards and installed version of kubectl.

Copy link
Member

@cblecker cblecker left a comment

Choose a reason for hiding this comment

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

Attempted to run this and it's failing. The build image is normally wrapped with a bunch of bash to ensure the right variables are passed in.

.devcontainer/OWNERS Outdated Show resolved Hide resolved
.devcontainer/OWNERS Outdated Show resolved Hide resolved
Copy link

@craiglpeters craiglpeters left a comment

Choose a reason for hiding this comment

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

Using kube-cross is as simple as pointing to the image in the container registry. The local features are not needed as kube-cross already has everything except pyyaml.

.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
.devcontainer/local-features/etcd/install.sh Outdated Show resolved Hide resolved
.devcontainer/local-features/kubectl-kind/install.sh Outdated Show resolved Hide resolved
.devcontainer/local-features/kubetest2/install.sh Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 23, 2023
@Sharpz7
Copy link
Contributor Author

Sharpz7 commented Nov 23, 2023

I think using https://containers.dev/implementors/json_reference/#variables-in-devcontainerjson might be the way we can configure for the correct go version and Kubernetes version, but I am not sure.

Thoughts @craiglpeters ?

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 1, 2024
@sftim
Copy link
Contributor

sftim commented Apr 22, 2024

Changelog suggestion

-Adds the code/configs to allow for users to use dev-containers when developing k8s. This brings support for GitHub Codespaces, EnvBuilder, the devcontainer-cli and more.
+Added support for using a [devcontainer](https://containers.dev/) when developing Kubernetes.

(Markdown works, and we can rely on people to click the link if they want to learn more).

bells17 added a commit to bells17/kubernetes that referenced this pull request Apr 27, 2024
@bells17
Copy link
Contributor

bells17 commented Apr 28, 2024

Hello,

I've created a new PR with permission from @craiglpeters .
May I request a review for this PR?

#124584

https://kubernetes.slack.com/archives/C1TU9EB9S/p1714223550391479?thread_ts=1713701062.612009&cid=C1TU9EB9S

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. sig/contributor-experience Categorizes an issue or PR as relevant to SIG Contributor Experience. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Codespaces configuration dev container
9 participants