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 #124584

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

Conversation

bells17
Copy link
Contributor

@bells17 bells17 commented Apr 27, 2024

Based on:

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

What type of PR is this?

/kind feature
/sig architecture
/sig contributor-experience

What this PR does / why we need it:

This PR adds configuration files for running dev containers.

Currently, I am developing on Mac OS X, but sometimes I encounter errors like the one mentioned below:
#124156

By enabling the use of dev containers in the k/k repository, I can reduce the discrepancies in the development environment caused by differences in operating systems, and decrease the occurrence of errors like the one mentioned above.

Which issue(s) this PR fixes:

Fixes #113019

Special notes for your reviewer:

To ensure that all tools mentioned in the Development Guide are installed, I use the dev container feature and setup.sh to install any tools that are not already included in the kube-cross Dockerfile.

The following commands have been confirmed to work successfully in VSCode Dev Containers / Github Codespaces:

  • make

  • make verify

  • make update

  • make test

  • make test-integration

  • Running e2e tests with kubetest2:

    KUBETEST2_RUN_DIR=$(pwd)/_output/local/go/bin/ kubetest2 kind -v 2 \
        --build \
        --up \
        --down \
        --test=ginkgo \
        -- \
        --parallel 4 \
        --focus-regex='TTLAfterFinished'
    

Does this PR introduce a user-facing change?

Added support for using a [devcontainer](https://containers.dev/) when developing Kubernetes.

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

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

cc @craiglpeters

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. labels Apr 27, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 Apr 27, 2024

// Add etcd path to PATH
"remoteEnv": {
"PATH": "${containerEnv:PATH}:${containerEnv:GOPATH}/src/k8s.io/kubernetes/third_party/etcd"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rm -f /etc/apt/sources.list.d/google-cloud-sdk.list

# Install PyYAML
pip3 install pyyaml
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: bells17
Once this PR has been reviewed and has the lgtm label, please assign dims for approval. 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

# Never push to upstream master
git remote set-url --push upstream no_push

# Install gcloud command
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bells17 bells17 force-pushed the devcontainer branch 2 times, most recently from 364df68 to 905bc10 Compare April 27, 2024 20:26
mkdir -p /usr/local/etc/vscode-dev-containers
cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt

# Ensure that the upstream remote is set, and configure it if it's not
Copy link
Contributor Author

Choose a reason for hiding this comment

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


# Install kind & kubetest2 for e2e testing
go install sigs.k8s.io/kind@latest
go install sigs.k8s.io/kubetest2/...@latest
Copy link
Contributor Author

@bells17 bells17 Apr 27, 2024

Choose a reason for hiding this comment

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


// Features to add to the dev container. More info: https://containers.dev/features
"features": {
// The first-run-notice.txt is displayed by a script within
Copy link
Contributor Author

Choose a reason for hiding this comment

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


🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1).

🤖 Run e2e test command example:
Copy link
Contributor Author

@bells17 bells17 Apr 27, 2024

Choose a reason for hiding this comment

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

I’m not familiar with the best command to easily run e2e tests in a local environment, so I would appreciate any guidance.
(I believe it is preferable to use a deployer like kind that allows anyone to easily run it locally.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bells17 bells17 marked this pull request as ready for review April 27, 2024 20:48
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 27, 2024
@k8s-ci-robot k8s-ci-robot requested a review from dims April 27, 2024 20:48
@bells17
Copy link
Contributor Author

bells17 commented Apr 28, 2024

/retest

@bells17
Copy link
Contributor Author

bells17 commented Apr 28, 2024

I'll add individuals who appear to be related to the original PR as reviewers:
#121561

/cc @craiglpeters @mrbobbytables @cblecker @sftim

@bells17 bells17 force-pushed the devcontainer branch 2 times, most recently from 68f0c9a to 2fda795 Compare April 28, 2024 12:28
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. kind/feature Categorizes issue or PR as related to a new feature. 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. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Codespaces configuration dev container
2 participants