Skip to content

Commit 86d5fb5

Browse files
committed
add support for devcontainer
1 parent 0300a3b commit 86d5fb5

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

.devcontainer/devcontainer.json

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

.devcontainer/setup.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eux
18+
19+
# Copies over welcome message
20+
cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
21+
22+
git remote add upstream https://github.com/kubernetes/kops.git
23+
# Never push to upstream master
24+
git remote set-url --push upstream no_push

.devcontainer/welcome-message.txt

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
👋 Welcome to Kops contribution in a dev container!
2+
Works in GitHub Codespaces, VS Code, or in docker using the devcontainer cli
3+
4+
See https://kops.sigs.k8s.io/contributing/ for guidance on contributing to Kops
5+
6+
This debian dev container image satisfies https://github.com/kubernetes/community/blob/master/contributors/devel/development.md and includes:
7+
- kubernetes/kubernetes repository
8+
- Docker
9+
- go
10+
- kubectl, etcd, kubetest2, and kind
11+
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.
12+
The configuration for the dev container is in the .github/.devcontainer folder. (will be moved to prow)
13+
🎵 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.
14+
See https://docs.github.com/en/codespaces/customizing-your-codespace/changing-the-machine-type-for-your-codespace
15+
16+
⚙️ If you are working in Codespaces on your own fork, this environment is automatically configured to support the GitHub
17+
workflow https://www.kubernetes.dev/docs/guide/github-workflow/ (omit the clone step)
18+
↪️ Otherwise Codespaces will automatically fork the repository for you when you make your first push
19+
20+
🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1).

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
# Vscode files
2626
.vscode
27-
.devcontainer
2827

2928
# Emacs save files
3029
*~

0 commit comments

Comments
 (0)