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

Add how to install operator locally; fix telegram link #31

Merged
merged 6 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
45 changes: 45 additions & 0 deletions HOW-TO-START-DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# How to start contributing

## Read kubebuilder documentation
[Docs](https://book.kubebuilder.io/introduction)

## Build your develop environment

### Easy way
1. Download and install [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#creating-a-cluster).
2. Create lind cluster `kind create cluster --name etcd-operator-kind`.
3. Switch kubectl context to kind `kubectl cluster-info --context kind-etcd-operator-kind`. Be attentive to avoid damaging your production environment.
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 write it like kubectl set-context kind-etcd-operator-kind or something like that. The command you provided does not change context. Following make commands will be executed against some other cluster :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you, will have a look today.
Probably I accidentally copied the wrong line from my history. At least I executed everything against correct cluster :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sircthulhu fixed

4. Install cert-manager (it creates certificate k8s secrets). Refer to the [docs](https://cert-manager.io/docs/installation/helm/#4-install-cert-manager).
5. Build docker image *controller:latest* `make docker-build`.
6. Retag image to upload to kind cluster with correct name `docker tag controller:latest ghcr.io/aenix-io/etcd-operator:latest`.
7. Load image to kind cluster `kind load docker-image ghcr.io/aenix-io/etcd-operator:latest`.
8. Install CRDs `make install`.
9. Deploy operator, RBAC, webhook certs `make deploy`.

To deploy your code changes
1. Rebuild the image `make docker-build`.
2. Retag image to upload to kind cluster with correct name `docker tag controller:latest ghcr.io/aenix-io/etcd-operator:latest`.
3. Load image to kind cluster `kind load docker-image ghcr.io/aenix-io/etcd-operator:latest`.
4. Redeploy yaml manifests if necessary `make deploy`.
5. Restart etcd-operator `kubectl rollout restart -n etcd-operator-system deploy/etcd-operator-controller-manager`.

### Advanced way
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.
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.

**General steps**
1. Install VSCode Kubernetes extension.
2. Install VSCode Dev Containers extension.
3. Create pvc to store operator code, go modules and your files.
4. Build Dockerfile to create image for your develop environment (git, golang , etc...). Take base image that you love most.
5. Patch operator deployment to
* Attach PVC from step 3.
* Change operator image to your image.
* Change command and args to endless sleep loop.
* Change rolling update strategy to recreate if you use RWO storage class.
* Change security context RunAsNonRoot to false.
* Increase requests and limits.
* Remove readiness and liveness probes.
6. Attach VSCode to a running container through Kubernetes extension.
7. Install necessary extensions to the container. They will be preserved after container restart if you attached pvc to home directory.
8. Run `go run cmd/main.go`.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Open Source](https://img.shields.io/badge/Open-Source-brightgreen)](https://opensource.org/)
[![Apache-2.0 License](https://img.shields.io/github/license/aenix-io/etcd-operator)](https://opensource.org/licenses/)
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/etcd-operator)
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/etcd_operator)
[![Active](http://img.shields.io/badge/Status-Active-green.svg)](https://aenix.io/etcd-operator/)
[![GitHub Release](https://img.shields.io/github/release/aenix-io/etcd-operator.svg?style=flat)](https://github.com/aenix-io/etcd-operator)
[![GitHub Commit](https://img.shields.io/github/commit-activity/y/aenix-io/etcd-operator)](https://github.com/aenix-io/etcd-operator)
Expand Down