Skip to content

Latest commit

 

History

History
133 lines (90 loc) · 5.33 KB

CONTRIBUTING.md

File metadata and controls

133 lines (90 loc) · 5.33 KB

Contributing to the Elastic APM mutating admission webhook for Kubernetes

The Elastic APM mutating admission webhook for Kubernetes is open source and we love to receive contributions from our community — you!

There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests or writing code.

You can get in touch with us through Discuss. Feedback and ideas are always welcome.

Development Dependencies

webhook:

helmchart:

Code contributions

If you have a bugfix or new feature that involves significant changes that you would like to contribute, please find or open an issue to discuss the changes first. It may be that somebody is already working on it, or that there are particular issues that you should know about before implementing the change.

For minor changes (e.g. fixing a typo), you can just send your changes.

Testing

The tests currently do not require any external resources, so just run go test ./....

We track code coverage. 100% coverage is not a goal, but please do check that your tests adequately cover the code using go test -cover.

For manual testing, you can start the local kubernetes cluster using kind:

kind create cluster --config kind.yaml

This creates a configuration at ~/.kube/config, which is already set to communicate with the cluster. In case you are using two clusters, you can refer to https://kind.sigs.k8s.io/docs/user/quick-start/#interacting-with-your-cluster

It might be helpful to use skaffold, which manages installing, updating, and removing the helmchart.

Start the watcher in a separate terminal with skaffold dev. This watches for changes on files within the helmchart, the Dockerfile, and any file dependencies specified by the Dockerfile. A change will trigger an update within the kubernetes cluster.

Debugging

For debugging, docker exec into the running kind node, from which the pod network is exposed on the host.

For example:

docker exec -it <kind container id> bash
kubectl get pods -o wide
curl <ip-address>:5678

Deploying an example container

There is a helper script you can use, to deploy a simple echo server with the correct annotation. You can check that it's been configured correctly by the webhook using kubectl.

./example_deploy.sh

Removing Clusters

When using kind, you can retrieve available clusters and delete them via:

kind get clusters
kind delete cluster <cluster-name>

Submitting your changes

Generally, we require that you test any code you are adding or modifying. Once your changes are ready to submit for review:

  1. Sign the Contributor License Agreement

    Please make sure you have signed our Contributor License Agreement. We are not asking you to assign copyright to us, but to give us the right to distribute your code without restriction. We ask this of all contributors in order to assure our users of the origin and continuing existence of the code. You only need to sign the CLA once.

  2. Test your changes

    Run the test suite to make sure that nothing is broken. See testing for details.

  3. Review your changes

    Before sending your changes for review, it pays to review it yourself first!

    If you're making significant changes, please familiarize yourself with Effective Go and go/wiki/CodeReviewComments. These documents will walk you through writing idiomatic Go code, which we strive for.

    Here are a few things to check:

  4. Rebase your changes

    Update your local repository with the most recent code from the main repo, and rebase your branch on top of the latest main branch. We prefer your initial changes to be squashed into a single commit. Later, if we ask you to make changes, add them as separate commits. This makes them easier to review. As a final step before merging we will either ask you to squash all commits yourself or we'll do it for you.

  5. Submit a pull request

    Push your local changes to your forked copy of the repository and submit a pull request. In the pull request, choose a title which sums up the changes that you have made, and in the body provide more details about what your changes do, and the reason for making them. Also mention the number of the issue where discussion has taken place, or issues that are fixed/closed by the changes, e.g. "Closes #123".

  6. Be patient

    We might not be able to review your code as fast as we would like to, but we'll do our best to dedicate it the attention it deserves. Your effort is much appreciated!