add support for devcontainer

This commit is contained in:
Rémy Léone 2023-12-21 18:19:30 +01:00
parent 0300a3b858
commit 86d5fb595f
4 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,26 @@
// For format details, see https://containers.dev
{
"name": "Kops environment from dev container",
// Image to pull when not building from scratch. See .devcontainer/build/devcontainer.json
// and .github/devcontainer-build-and-push.yml for the instructions on how this image is built
"image": "registry.k8s.io/build-image/kube-cross:v1.29.0-go1.21.3-bullseye.0",
// Setup the go environment and mount into the dev container at the expected location
"workspaceFolder": "/go/src/k8s.io/kops",
"workspaceMount": "source=${localWorkspaceFolder},target=/go/src/k8s.io/kops,type=bind,consistency=cached",
// Ensure that the host machine has enough resources to build and test Kops
"hostRequirements": {
"cpus": 4
},
// Copy over welcome message and install pyyaml
"onCreateCommand": "bash .devcontainer/setup.sh",
// for Kubernetes testing, suppress extraneous forwarding messages
"otherPortsAttributes": {
"onAutoForward": "silent"
},
"remoteUser": "root"
// Configure tool-specific properties.
// "customizations": {
// },
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
}

24
.devcontainer/setup.sh Normal file
View File

@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Copyright 2023 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
cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
git remote add upstream https://github.com/kubernetes/kops.git
# Never push to upstream master
git remote set-url --push upstream no_push

View File

@ -0,0 +1,20 @@
👋 Welcome to Kops contribution in a dev container!
Works in GitHub Codespaces, VS Code, or in docker using the devcontainer cli
See https://kops.sigs.k8s.io/contributing/ for guidance on contributing to Kops
This debian dev container image satisfies https://github.com/kubernetes/community/blob/master/contributors/devel/development.md and includes:
- kubernetes/kubernetes repository
- Docker
- go
- kubectl, etcd, kubetest2, and kind
For details about dev containers and the debian dev container base image see https://containers.dev and https://github.com/devcontainers/images/tree/main/src/base-debian.
The configuration for the dev container is in the .github/.devcontainer folder. (will be moved to prow)
🎵 By default in Codespaces this environment uses a 4-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 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).

1
.gitignore vendored
View File

@ -24,7 +24,6 @@
# Vscode files # Vscode files
.vscode .vscode
.devcontainer
# Emacs save files # Emacs save files
*~ *~