Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add a simple local development guide #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ test/e2e/data/infrastructure-oci/v1beta1/cluster-template-bare-metal.yaml
test/e2e/data/infrastructure-oci/v1beta1/cluster-template-custom-networking-seclist.yaml
test/e2e/data/infrastructure-oci/v1beta1/cluster-template-custom-networking-nsg.yaml
test/e2e/data/infrastructure-oci/v1beta1/cluster-template-multiple-node-nsg.yaml

# local development files
auth-config.yaml
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
- [Using Calico](./networking/calico.md)
- [Using Antrea](./networking/antrea.md)
- [Custom Networking](./networking/custom-networking.md)
- [Developer Guide](./development/development.md)
- [Reference](./reference/reference.md)
- [Glossary](./reference/glossary.md)
92 changes: 92 additions & 0 deletions docs/src/development/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Developer Guide

## Install prerequisites

1. Install make.
- `$ xcode-select --install` on macOS.
- `$ sudo apt-get install build-essential` on Ubuntu Linux
- `$ sudo dnf install make gcc` on Oracle Linux
1. Install [Go][go]
Comment on lines +5 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try this:

Suggested change
1. Install make.
- `$ xcode-select --install` on macOS.
- `$ sudo apt-get install build-essential` on Ubuntu Linux
- `$ sudo dnf install make gcc` on Oracle Linux
1. Install [Go][go]
1. Install the required build tools for each operating system:
- macOS: `xcode-select --install`
- Oracle Linux: `sudo yum install make gcc`
- Ubuntu Linux: `sudo apt-get install build-essential`
1. Install [Go][go] by following the [installation guide](https://go.dev/doc/install).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OSs are sorted alphabetically too.

1. Install [KIND][kind]
- `$ GO111MODULE="on" go get sigs.k8s.io/kind@v0.12.0`.
Comment on lines +10 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Install [KIND][kind]
- `$ GO111MODULE="on" go get sigs.k8s.io/kind@v0.12.0`.
1. Install [KIND][kind] by running the following command on all platforms: `$ GO111MODULE="on" go get sigs.k8s.io/kind@v0.12.0`.

1. Install [Kustomize][kustomize]
- [install instructions][kustomizelinux]
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Install [Kustomize][kustomize]
- [install instructions][kustomizelinux]
1. Install [Kustomize][kustomize] by following the [install instructions][kustomizelinux].

1. Install [envsubst][envsubst]
joekr marked this conversation as resolved.
Show resolved Hide resolved
- `$ go get github.com/a8m/envsubst/cmd/envsubst`
Comment on lines +14 to +15
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. Install [envsubst][envsubst]
- `$ go get github.com/a8m/envsubst/cmd/envsubst`
1. Install [envsubst][envsubst] by running the following command on all platforms: `go get github.com/a8m/envsubst/cmd/envsubst`


## Fork and get the source
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Fork and get the source
## Fork and clone this repository


Fork the [`cluster-api-provider-oci repo`](https://github.com/oracle/cluster-api-provider-oci).
See the [forking](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and
[cloning](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
documentation for more details.
Comment on lines +19 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Fork the [`cluster-api-provider-oci repo`](https://github.com/oracle/cluster-api-provider-oci).
See the [forking](https://docs.github.com/en/get-started/quickstart/fork-a-repo) and
[cloning](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
documentation for more details.
Before you can submit changes to this repository, you need a copy of it to which you have write access. This is done by [forking](https://docs.github.com/en/get-started/quickstart/fork-a-repo) the [`cluster-api-provider-oci`](https://github.com/oracle/cluster-api-provider-oci) repository, then [cloning](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) the fork that was just created.
> **Tip:** click the "Code" button on the home page of your fork to find the exact URL required for the `clone` command.


Example:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Example:
The following example creates a `sigs.k8s.io` directory in the active Go `src` location, then clones your fork of the repository from GitHub in that diretory:

```bash
cd "$(go env GOPATH)"/src
mkdir sigs.k8s.io
cd sigs.k8s.io/
git clone git@github.com:<GITHUB USERNAME>/cluster-api-provider-oci.git
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
git clone git@github.com:<GITHUB USERNAME>/cluster-api-provider-oci.git
git clone git@github.com:github_username/cluster-api-provider-oci.git

cd cluster-api-provider-oci
git remote add upstream git@github.com:orale/cluster-api-provider-oci.git
git fetch upstream
Comment on lines +30 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three lines should be in a seperate code block from the lines above with the following line between:

Now that you have a local clone of your, add a reference to the upstream repository so to enable keeping your fork current with changes made upstream and to tell Git and GitHub where to open pull requests for your changes:

```
joekr marked this conversation as resolved.
Show resolved Hide resolved

## Running a local management cluster for development

The simplest way to test the code is to run it on your local development workstation.
If you have `capoci-controller-manager` running in your management cluster,
joekr marked this conversation as resolved.
Show resolved Hide resolved
please scale down the deployment, otherwise running your development build will conflict with the
currently running `capoci-controller-manager`:
Comment on lines +38 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If you have `capoci-controller-manager` running in your management cluster,
please scale down the deployment, otherwise running your development build will conflict with the
currently running `capoci-controller-manager`:
> **Note:** If you are re-using an existing management cluster that already has `capoci-controller-manager` installed, be sure to provide sufficient resources for both instances or scale down the existing instances to release resources for the new instance.


```bash
kubectl scale deployment/capoci-controller-manager --replicas=0 -n cluster-api-provider-oci-system
```

To build, run and test all your code changes locally, copy the
`hack/auth-config-template.yaml` file to `<path-to-your-repo>/auth-config.yml` in your
cloned copy of the repository and modify it to match your local configuration.
Comment on lines +46 to +48
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To build, run and test all your code changes locally, copy the
`hack/auth-config-template.yaml` file to `<path-to-your-repo>/auth-config.yml` in your
cloned copy of the repository and modify it to match your local configuration.
To build, run and test all your code changes locally, copy the `hack/auth-config-template.yaml` to `hack/auth-config.yml` and modify it to match your local configuration.


Then run the following commands:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Then run the following commands:
After populating the local configuration file to suit your envornment, the following command will run the test suite:


```bash
export AUTH_CONFIG_DIR="<path-to-your-repo>/auth-config.yaml"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export AUTH_CONFIG_DIR="<path-to-your-repo>/auth-config.yaml"
export AUTH_CONFIG_DIR="hack/auth-config.yaml"

make run
```

If you want to test your changes using an image built locally using `docker build`, execute the
following steps:

```bash
export TAG=<tag>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export TAG=<tag>
export TAG="$(git rev-parse --short HEAD)"

export REGISTRY="<region>.ocir.io/<namespace>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would create a section on "demo values" and use specific values for ocir and namespace instead of using variable placeholders which are more prone to generating less gnomic errors. The namespace of example should generate the very useful namespace doesn't exist error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this and think we will add it later as part of a larger document cleanup task.

make docker-build
```

`region` for example, `phx` or `us-phoenix-1`. See the
[Available Endpoints](https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registryprerequisites.htm#Availab)
topic in the Oracle Cloud Infrastructure Registry (OCIR) documentation.

`namespace` is the auto-generated [object storage namespace](https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/understandingnamespaces.htm)
string of the tenancy (as shown on the tenancy information page) that owns the
repository to which you want to push the image.

![tenancy_namespace](../images/tenancy_namespace.png)

Push the resulting container image to the repository. For more info on how to push
to OCIR see
<https://www.oracle.com/webfolder/technetwork/tutorials/obe/oci/registry/index.html>

Execute the following steps to install the image

```bash
make release-manifests
kubectl apply -f out/infrastructure-oci/v0.1.1-development/infrastructure-components.yaml
```

[go]: https://golang.org/doc/install
[go.mod]: https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/master/go.mod
[kind]: https://sigs.k8s.io/kind
[kustomize]: https://github.com/kubernetes-sigs/kustomize
[kustomizelinux]: https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md
[envsubst]: https://github.com/a8m/envsubst
Binary file added docs/src/images/tenancy_namespace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions hack/auth-config-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# see region identifier in https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm
# for a list of regions
region: <region>
tenancy: ocid1.tenancy.oc1..<unique_ID>
user: ocid1.user.oc1..<unique_ID>
key: |
-----BEGIN RSA PRIVATE KEY-----
<your_private_key>
-----END RSA PRIVATE KEY-----
fingerprint: <your_private_key_fingerprint>

useInstancePrincipals: false
joekr marked this conversation as resolved.
Show resolved Hide resolved