Skip to content

Commit 44155e1

Browse files
authored
docs: updated contributing instructions (projectcontour#5238)
* docs: updated contributing instructions * attempt with kind listening on 127.0.0.1 * set image name based on git hash Signed-off-by: Tero Saarni <[email protected]>
1 parent 3fc0b75 commit 44155e1

File tree

5 files changed

+67
-37
lines changed

5 files changed

+67
-37
lines changed

CONTRIBUTING.md

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Thanks for taking the time to join our community and start contributing.
44
These guidelines will help you get started with the Contour project.
5-
Please note that we require [DCO sign off](#dco-sign-off).
5+
Please note that we require [DCO sign off](#dco-sign-off).
66

77
Read this document for additional website specific guildlines: [Site Contribution Guidelines](/SITE_CONTRIBUTION.md).
88
Guidelines in this document still apply to website contributions.
@@ -15,11 +15,20 @@ This section describes how to build Contour from source.
1515

1616
### Prerequisites
1717

18-
1. *Install Go*
18+
1. Install Docker
1919

20+
The easiest way to experiment with Contour is to build it in a container and run it locally in [kind](https://kind.sigs.k8s.io/) cluster.
21+
22+
2. Install tools: `git`, `make`, [`kind`](https://kind.sigs.k8s.io/docs/user/quick-start/), `kubectl`, `jq` and `yq`
23+
24+
3. Install Go
25+
26+
To debug locally and to run unit tests, you will need to install Go.
2027
Contour generally uses the most recent minor [Go version][1].
2128
Look in the `Makefile` (search for the `BUILD_BASE_IMAGE` variable) to find the specific version being used.
2229

30+
31+
2332
### Fetch the source
2433

2534
Contour uses [`go modules`][2] for dependency management.
@@ -32,9 +41,34 @@ Contour uses [`go modules`][2] for dependency management.
3241
git clone [email protected]:YOUR-USERNAME/contour.git
3342
```
3443

35-
### Building
3644

37-
To build Contour, run:
45+
### Running your first build
46+
47+
The simplest way to get up and running is to build Contour in a Docker container and to deploy it to a local Kind cluster.
48+
These commands will launch a Kind cluster and deploy your build of Contour to it.
49+
50+
```shell
51+
make install-contour-working
52+
```
53+
54+
or for Contour Gateway Provisioner:
55+
56+
```shell
57+
make install-provisioner-working
58+
```
59+
60+
You can access Contour in localhost ports 9080 and 9443.
61+
62+
To remove the Kind cluster and all resources, run:
63+
64+
```shell
65+
make cleanup-kind
66+
```
67+
68+
69+
### Building locally
70+
71+
To build Contour locally, run:
3872

3973
```
4074
make
@@ -65,8 +99,6 @@ Before making a commit, it's always a good idea to check the code for common pro
6599
make lint
66100
```
67101

68-
Note: The lint tasks require the [codespell](https://github.com/codespell-project/codespell) application. Be sure to install version 2.0 or newer before running the lint tasks.
69-
70102
### Local Development/Testing
71103

72104
It's very helpful to be able to test out changes to Contour locally without building images and pushing into clusters.
@@ -109,9 +141,9 @@ Change `initContainers:` to look like this updating the IP and removing the thre
109141

110142
5. Change your Contour code.
111143

112-
6. Build & start Contour allowing Envoy to connect and get its configuration.
144+
6. Build & start Contour allowing Envoy to connect and get its configuration.
113145
```shell
114-
make install && contour serve --kubeconfig=$HOME/.kube/config --xds-address=0.0.0.0 --insecure
146+
make install && contour serve --kubeconfig=$HOME/.kube/config --xds-address=0.0.0.0 --insecure
115147
```
116148

117149
8. Test using the local kind cluster by deploying resources into that cluster. Many of our examples use `local.projectcontour.io` which is configured to point to `127.0.0.1` which allows requests to route to the local kind cluster for easy testing.
@@ -182,7 +214,7 @@ with a colon as delimiter. For example 'docs:', 'internal/(packagename):', 'desi
182214
it may have a `release-note/not-required` category. PRs may also include a `release-note/deprecation`
183215
label alone or in addition to the primary label.
184216
- PRs *must* include a file named `changelogs/unreleased/PR#-githubID-category.md`, which is a Markdown
185-
file with a description of the change. Please see `changelogs/unreleased/<category>-sample.md` for
217+
file with a description of the change. Please see `changelogs/unreleased/<category>-sample.md` for
186218
sample changelogs.
187219
- If main has moved on, you'll need to rebase before we can merge,
188220
so merging upstream main or rebasing from upstream before opening your
@@ -244,8 +276,8 @@ contour_api_v1 "github.com/projectcontour/contour/apis/projectcontour/v1"
244276
contour_api_v1alpha1 "github.com/projectcontour/contour/apis/projectcontour/v1alpha1"
245277
envoy_v3 "github.com/projectcontour/contour/internal/envoy/v3"
246278
xdscache_v3 "github.com/projectcontour/contour/internal/xdscache/v3"
247-
```
248-
279+
```
280+
249281
### Pre commit CI
250282

251283
Before a change is submitted it should pass all the pre commit CI jobs.
@@ -283,11 +315,11 @@ This section provides some useful information and guidelines for working with Co
283315
#### Config/Data Categories
284316
* **Kubernetes Config**: `HTTPProxy`, `Ingress` or [Gateway API][8] config that Contour watches and converts to Envoy config.
285317
* **DAG**: The internal Contour representation of L7 proxy concepts. Kubernetes config is first converted to DAG objects before being converted to Envoy config.
286-
* **Envoy Config**: Configuration that can be provided to Envoy via xDS. This is Contour's final output, generated directly from the DAG.
318+
* **Envoy Config**: Configuration that can be provided to Envoy via xDS. This is Contour's final output, generated directly from the DAG.
287319

288320
#### Test Categories
289321
* **Unit Test**: A Go test for a particular function/package. In some cases, these test more than one package at a time.
290-
* **Feature Test**: A Go test in `internal/featuretests` that tests the translation of Kubernetes config to Envoy config, using a Contour event handler and xDS server.
322+
* **Feature Test**: A Go test in `internal/featuretests` that tests the translation of Kubernetes config to Envoy config, using a Contour event handler and xDS server.
291323
* **End-To-End (E2E) Test**: A Go test in `test/e2e` that performs a full end-to-end test of Contour running in a cluster. Typically verifies the behavior of HTTP requests given a Kubernetes `HTTPProxy`, `Ingress` or Gateway API config.
292324

293325
### Summary of Major Test Suites
@@ -370,7 +402,7 @@ By making a contribution to this project, I certify that:
370402

371403
[1]: https://golang.org/dl/
372404
[2]: https://github.com/golang/go/wiki/Modules
373-
[3]: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository
405+
[3]: https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository
374406
[4]: https://golang.org/pkg/testing/
375407
[5]: https://developercertificate.org/
376408
[6]: https://github.com/projectcontour/contour/issues/new/choose

hack/codespell.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ if command -v ${PROGNAME} >/dev/null; then
77
exec ${PROGNAME} "$@"
88
fi
99

10+
if command -v docker >/dev/null; then
11+
exec docker run \
12+
--rm \
13+
--volume $(pwd):/workdir \
14+
--workdir=/workdir \
15+
--entrypoint=/usr/local/bin/codespell \
16+
ghcr.io/codespell-project/actions-codespell/stable:v1.0 "$@"
17+
fi
18+
1019
cat <<EOF
1120
Unable to run codespell. Please check installation instructions:
1221
https://github.com/codespell-project/codespell#installation

test/scripts/install-contour-working.sh

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,10 @@ if ! kind::cluster::exists "$CLUSTERNAME" ; then
4444
exit 2
4545
fi
4646

47-
# Wrap sed to deal with GNU and BSD sed flags.
48-
run::sed() {
49-
local -r vers="$(sed --version < /dev/null 2>&1 | grep -q GNU && echo gnu || echo bsd)"
50-
case "$vers" in
51-
gnu) sed -i "$@" ;;
52-
*) sed -i '' "$@" ;;
53-
esac
54-
}
47+
# Set the image tag to match the current git hash + dirty flag.
48+
VERSION=$(git describe --exclude="*" --always --dirty)
5549

56-
# Build the current version of Contour.
57-
VERSION="v$$"
50+
# Build the image.
5851
make -C ${REPO} container IMAGE=ghcr.io/projectcontour/contour VERSION=${VERSION}
5952

6053
# Push the Contour build image into the cluster.
@@ -73,17 +66,13 @@ for file in ${REPO}/examples/contour/02-job-certgen.yaml ${REPO}/examples/contou
7366
# Set image pull policy to IfNotPresent so kubelet will use the
7467
# images that we loaded onto the node, rather than trying to pull
7568
# them from the registry.
76-
run::sed \
77-
"-es|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|" \
78-
"$file"
79-
8069
# Set the image tag to $VERSION to unambiguously use the image
8170
# we built above.
82-
run::sed \
71+
sed \
72+
"-es|imagePullPolicy: Always|imagePullPolicy: IfNotPresent|" \
8373
"-es|image: ghcr.io/projectcontour/contour:.*$|image: ghcr.io/projectcontour/contour:${VERSION}|" \
84-
"$file"
85-
86-
${KUBECTL} apply -f "$file"
74+
"$file" | \
75+
${KUBECTL} apply -f -
8776
done
8877

8978
# Wait for Contour and Envoy to report "Ready" status.

test/scripts/install-provisioner-working.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ if ! kind::cluster::exists "$CLUSTERNAME" ; then
2828
exit 2
2929
fi
3030

31-
# Set the image tag to match the current Contour version.
32-
VERSION="v$$"
31+
# Set the image tag to match the current git hash + dirty flag if repo has modifications.
32+
VERSION=$(git describe --exclude="*" --always --dirty)
3333

3434
# Build the Contour Provisioner image.
3535
make -C ${REPO} container IMAGE=ghcr.io/projectcontour/contour VERSION=${VERSION}

test/scripts/kind-expose-port.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ nodes:
66
extraPortMappings:
77
- containerPort: 80
88
hostPort: 9080
9-
listenAddress: "0.0.0.0"
9+
listenAddress: "127.0.0.1"
1010
- containerPort: 443
1111
hostPort: 9443
12-
listenAddress: "0.0.0.0"
12+
listenAddress: "127.0.0.1"
1313
- containerPort: 8002
1414
hostPort: 8002
15-
listenAddress: "0.0.0.0"
15+
listenAddress: "127.0.0.1"

0 commit comments

Comments
 (0)