|
| 1 | +# How to start contributing |
| 2 | + |
| 3 | +## Read kubebuilder documentation |
| 4 | +[Docs](https://book.kubebuilder.io/introduction) |
| 5 | + |
| 6 | +## Build your develop environment |
| 7 | + |
| 8 | +### Easy way |
| 9 | +1. Download and install [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#creating-a-cluster). |
| 10 | +2. Create lind cluster `kind create cluster --name etcd-operator-kind`. |
| 11 | +3. Switch kubectl context to kind `kubectl config use-context kind-etcd-operator-kind`. Be attentive to avoid damaging your production environment. |
| 12 | +4. Install cert-manager (it creates certificate k8s secrets). Refer to the [docs](https://cert-manager.io/docs/installation/helm/#4-install-cert-manager). |
| 13 | +5. Build docker image *controller:latest* `make docker-build`. |
| 14 | +6. Retag image to upload to kind cluster with correct name `docker tag controller:latest ghcr.io/aenix-io/etcd-operator:latest`. |
| 15 | +7. Load image to kind cluster `kind load docker-image ghcr.io/aenix-io/etcd-operator:latest`. |
| 16 | +8. Install CRDs `make install`. |
| 17 | +9. Deploy operator, RBAC, webhook certs `make deploy`. |
| 18 | + |
| 19 | +To deploy your code changes |
| 20 | +1. Rebuild the image `make docker-build`. |
| 21 | +2. Retag image to upload to kind cluster with correct name `docker tag controller:latest ghcr.io/aenix-io/etcd-operator:latest`. |
| 22 | +3. Load image to kind cluster `kind load docker-image ghcr.io/aenix-io/etcd-operator:latest`. |
| 23 | +4. Redeploy yaml manifests if necessary `make deploy`. |
| 24 | +5. Restart etcd-operator `kubectl rollout restart -n etcd-operator-system deploy/etcd-operator-controller-manager`. |
| 25 | + |
| 26 | +### Advanced way |
| 27 | +Using *easy way* you will not be able to debug golang code locally and every change will be necessary to build as an image, upload to the cluster and then restart operator. |
| 28 | +If you use VSCode, you can connect your IDE to a pod in kubernetes cluster and use `go run cmd/main.go` from the pod. It will allow you to debug easily and faster integrate code changes to you develop environment. |
| 29 | + |
| 30 | +**General steps** |
| 31 | +1. Install VSCode Kubernetes extension. |
| 32 | +2. Install VSCode Dev Containers extension. |
| 33 | +3. Create pvc to store operator code, go modules and your files. |
| 34 | +4. Build Dockerfile to create image for your develop environment (git, golang , etc...). Take base image that you love most. |
| 35 | +5. Patch operator deployment to |
| 36 | + * Attach PVC from step 3. |
| 37 | + * Change operator image to your image. |
| 38 | + * Change command and args to endless sleep loop. |
| 39 | + * Change rolling update strategy to recreate if you use RWO storage class. |
| 40 | + * Change security context RunAsNonRoot to false. |
| 41 | + * Increase requests and limits. |
| 42 | + * Remove readiness and liveness probes. |
| 43 | +6. Attach VSCode to a running container through Kubernetes extension. |
| 44 | +7. Install necessary extensions to the container. They will be preserved after container restart if you attached pvc to home directory. |
| 45 | +8. Run `go run cmd/main.go`. |
0 commit comments