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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# See the OWNERS docs at https://go.k8s.io/owners | ||
|
||
reviewers: | ||
- cblecker | ||
- jberkus | ||
- kaslin | ||
- MadhavJivrajani | ||
- mrbobbytables | ||
- Nikhita | ||
- Priyankasaggu11929 | ||
approvers: | ||
- sig-contributor-experience-approvers | ||
labels: | ||
- sig/contributor-experience |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// For format details, see https://containers.dev | ||
{ | ||
"name": "Kubernetes environment from dev container", | ||
|
||
// For details about this image: | ||
// https://github.com/kubernetes/release/tree/master/images/build/cross | ||
"image": "registry.k8s.io/build-image/kube-cross:v1.30.0-go1.22.2-bullseye.0", | ||
"remoteUser": "root", | ||
|
||
// Setup the go environment and mount into the dev container at the expected location | ||
"workspaceFolder": "/go/src/k8s.io/kubernetes", | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/go/src/k8s.io/kubernetes,type=bind,consistency=cached", | ||
|
||
// Install the features based on the software required for Kubernetes development | ||
// https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#installing-required-software | ||
// https://containers.dev/features | ||
"features": { | ||
// The first-run-notice.txt is displayed by a script within | ||
// ghcr.io/devcontainers/features/common-utils:2 | ||
// Although it might be installed by other features, | ||
// we are explicitly installing it to ensure it's included | ||
"ghcr.io/devcontainers/features/common-utils:2": {}, | ||
"ghcr.io/devcontainers/features/docker-in-docker:2": {}, | ||
"ghcr.io/devcontainers/features/python:1": {} | ||
}, | ||
|
||
// Setup the dev container environment | ||
"onCreateCommand": "./.devcontainer/setup.sh", | ||
|
||
// Add etcd & _output/bin path to PATH | ||
"remoteEnv": { | ||
"PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/third_party/etcd:${containerWorkspaceFolder}/_output/bin" | ||
}, | ||
|
||
// Configure the hostRequirements based on the Kubernetes Hardware Requirements | ||
// https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#hardware-requirements | ||
"hostRequirements": { | ||
"memory": "8gb", | ||
"storage": "50gb" | ||
}, | ||
|
||
// for Kubernetes testing, suppress extraneous forwarding messages | ||
"otherPortsAttributes": { | ||
"onAutoForward": "silent" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright 2024 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eux | ||
|
||
# Copies over welcome message | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if ! git remote | grep -q "^upstream$"; then | ||
git remote add upstream https://github.com/kubernetes/kubernetes.git | ||
else | ||
if [ "$(git remote get-url upstream)" != "https://github.com/kubernetes/kubernetes.git" ]; then | ||
git remote set-url upstream https://github.com/kubernetes/kubernetes.git | ||
fi | ||
fi | ||
|
||
# Never push to upstream master | ||
git remote set-url --push upstream no_push | ||
|
||
# To ensure success in hack/print-workspace-status.sh, | ||
# execute git fetch upstream beforehand | ||
# The information retrieved in hack/print-workspace-status.sh is necessary | ||
# to execute the 'kind build node-image' command successfully through kubetest2 | ||
# https://github.com/kubernetes-sigs/kind/blob/v0.22.0/pkg/build/nodeimage/internal/kube/source.go#L71-L104 | ||
git fetch upstream | ||
|
||
# Install etcd | ||
./hack/install-etcd.sh | ||
|
||
# Install gcloud command | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - | ||
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | ||
apt-get update | ||
apt-get install -yq google-cloud-cli | ||
rm -f /etc/apt/sources.list.d/google-cloud-sdk.list | ||
|
||
# Install PyYAML | ||
pip3 install pyyaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
👋 Welcome to Kubernetes contribution in a dev container! | ||
Works in GitHub Codespaces, VS Code, or in docker using the devcontainer cli. | ||
|
||
See https://www.kubernetes.dev/docs/onboarding/ for guidance on contributing to Kubernetes. | ||
|
||
This dev container environment satisfies the requirements found at https://github.com/kubernetes/community/blob/master/contributors/devel/development.md and includes: | ||
- kubernetes/kubernetes repository | ||
- Docker | ||
- Go | ||
- build-essential/rsync/jq/gcloud/PyYAML/etcd | ||
- kind/kubetest2 | ||
|
||
For details about dev containers and the container image, see https://containers.dev and https://github.com/kubernetes/release/tree/master/images/build/cross. | ||
The configuration for the dev container is in the .github/.devcontainer folder. | ||
🎵 By default in Codespaces this environment uses a 8-core machine. Some tests may require a larger machine. In Codespaces you can change the machine type. | ||
See https://docs.github.com/en/codespaces/customizing-your-codespace/changing-the-machine-type-for-your-codespace | ||
|
||
⚙️ If you are working in Codespaces on your own fork, this environment is automatically configured to support the GitHub workflow found at https://www.kubernetes.dev/docs/guide/github-workflow/ (omit the clone step). | ||
↪️ Otherwise, Codespaces will automatically fork the repository for you when you make your first push. | ||
|
||
🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1). | ||
|
||
🤖 Run e2e test command example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
$ make | ||
$ KUBETEST2_RUN_DIR=$(pwd)/_output/local/go/bin/ kubetest2 kind -v 2 \ | ||
--build \ | ||
--up \ | ||
--down \ | ||
--test=ginkgo \ | ||
-- \ | ||
--parallel 4 \ | ||
--focus-regex='TTLAfterFinished' | ||
|
||
For details about kubetest2, see https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/e2e-tests-kubetest2.md and https://github.com/kubernetes-sigs/kubetest2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/devcontainers/features/blob/main/src/common-utils/scripts/rc_snippet.sh