---
# System prepended metadata

title: Katacoda scenario for K8s New Contributors

---

# Katacoda scenario for K8s New Contributors

## Context Building
- Tracking issue: https://github.com/kubernetes/community/issues/5576
- Script to get things up and running on Katacoda machine: https://gist.github.com/BenHall/b9a546797797fec6492a1a7d90b31ef3


Preliminary goals (from the issue):
```
Basic Steps:

- Create a fork on github
- Install basic tools like go, make (build-essential on ubuntu)
- Checkout their personal fork
- Add kubernete/kubernetes as a remote
- Make some simple change
- Run basic developer workflows like
    - Run a test using go
    - Run some verification and
    update scripts (hack/verify-gofmt.sh, hack/verify-typecheck.sh)
- Create a branch and submit a PR
```

---

## Draft scenario writeup 

### 1. Create a fork on github
As Kubernetes is a large project with multiple contributors, in order to make any changes to this project, we need to create a copy of repository using **fork**. Git fork helps to create a copy of the repository and make changes without affecting the upstream repository. 

### 2. Install basic tools
Kubernetes is written in Go. Building and developing Kubernetes requires a very recent version of Go.This table [lists](https://github.com/kubernetes/community/blob/master/contributors/devel/development.md#go) the required Go versions for different versions of Kubernetes.
**Installing GO**
`sudo curl -O https://storage.googleapis.com/golang/go1.17.linux-amd64.tar.gz`{{execute}}

`sudo tar -xvf go1.17.linux-amd64.tar.gz`{{execute}}
`sudo rm -rf /usr/local/go`{{execute}}
`sudo mv go /usr/local`{{execute}}

**Installing make (Ubuntu/Debian)**
`sudo apt-get install build-essential`{{execute}}

### 3. Cloning the Kubernetes Git Repository
`git clone https://github.com/kubernetes/kubernetes`{{execute}}
`cd kubernetes`{{execute}}

### 4. Checkout the personal fork
Making remote repository
`git remote add upstream https://github.com/kubernetes/kubernetes.git`{{execute}}
Never push to upstream master
`git remote set-url --push upstream no_push`{{execute}}
Confirm that your remotes make sense:
`git remote -v`{{execute}}
Get your local master up to date:
`git fetch upstream`{{execute}}
`git checkout master`{{execute}}
`git rebase upstream/master`{{execute}}

### 5. Run Basic Developer workflow
Generating the OpenAPI spec and related files
`hack/update-generated-swagger-docs.sh`{{execute}}
`hack/update-openapi-spec.sh`{{execute}}
`hack/update-generated-protobuf.sh`{{execute}}

Run `git status`{{execute}} to see what was generated

The `copycli` command cleans the temporary build directory, generates the kubectl command file
`make copycli`{{execute}}
### 6. Run a test using Go
Because kubernetes only merges pull requests when unit, integration, and e2e tests are passing, your development environment needs to run all tests successfully. While this quick start will get you going, to really understand the testing infrastructure, read the [Testing Guide](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/testing.md) and check out the [SIG Architecture developer guide](https://github.com/kubernetes/community/blob/master/contributors/devel/README.md#sig-testing) material.
#### Few examples on unit test
[Unit tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/testing.md#unit-tests) in kubernetes is used to confirm that a particular function behaves as intended. `make test` could be used to run all the unit tests at once, it is the entrypoint for running the unit tests that ensures that GOPATH is set up correctly. To run unit tests from certain packages, certain arguments could be passed along with `make test` `k8s.io/kubernetes` prefix is added automatically to these:
`make test WHAT=./pkg/kubelet                # run tests for pkg/kubelet`{{execute}}
More infromation on this is provided [here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-testing/testing.md#run-unit-tests-from-certain-packages)
