diff --git a/.gitignore b/.gitignore index 5b304658..e0a6776f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 03f621db..e1525753 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -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) diff --git a/docs/src/development/development.md b/docs/src/development/development.md new file mode 100644 index 00000000..8b0f0f3c --- /dev/null +++ b/docs/src/development/development.md @@ -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] +1. Install [KIND][kind] + - `$ GO111MODULE="on" go get sigs.k8s.io/kind@v0.12.0`. +1. Install [Kustomize][kustomize] + - [install instructions][kustomizelinux] +1. Install [envsubst][envsubst] + - `$ go get github.com/a8m/envsubst/cmd/envsubst` + +## Fork and get the source + +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. + +Example: +```bash +cd "$(go env GOPATH)"/src +mkdir sigs.k8s.io +cd sigs.k8s.io/ +git clone git@github.com:/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 +``` + +## 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, +please scale down the deployment, otherwise running your development build will conflict with the +currently running `capoci-controller-manager`: + +```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 `/auth-config.yml` in your +cloned copy of the repository and modify it to match your local configuration. + +Then run the following commands: + +```bash +export AUTH_CONFIG_DIR="/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= +export REGISTRY=".ocir.io/" +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 + + +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 diff --git a/docs/src/images/tenancy_namespace.png b/docs/src/images/tenancy_namespace.png new file mode 100644 index 00000000..80306450 Binary files /dev/null and b/docs/src/images/tenancy_namespace.png differ diff --git a/hack/auth-config-template.yaml b/hack/auth-config-template.yaml new file mode 100644 index 00000000..f3c805af --- /dev/null +++ b/hack/auth-config-template.yaml @@ -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: +tenancy: ocid1.tenancy.oc1.. +user: ocid1.user.oc1.. +key: | + -----BEGIN RSA PRIVATE KEY----- + + -----END RSA PRIVATE KEY----- +fingerprint: + +useInstancePrincipals: false \ No newline at end of file