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

doc: update docs, add links and cleanup #2

Merged
merged 1 commit into from
Aug 14, 2024
Merged
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
65 changes: 48 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ endpoint and token which can be set through command line or the environment vari
Also, some changes may be intended to be done "on-the-fly" in the Mailu frontend, for example setting auto reply or changing the password.

## Description
// TODO(user): An in-depth paragraph about your project and overview of use
This operator adds three custom resources: `Domain`, `User` and `Alias` and each resource represents an object in Mailu API.
For details refer also to your Mailu API documentation: https://mailu.io/master/api.html

Domain fields and defaults (see [sample](config/samples/operator_v1alpha1_domain.yaml))
- Name (required)
Expand All @@ -19,7 +20,7 @@ Domain fields and defaults (see [sample](config/samples/operator_v1alpha1_domain
- SignupEnabled
- Alternatives

User fields and defaults
User fields and defaults (see [sample](config/samples/operator_v1alpha1_user.yaml))
- AllowSpoofing
- ChangePwNextLogin
- Comment
Expand Down Expand Up @@ -48,41 +49,71 @@ User fields and defaults
- SpamMarkAsRead
- SpamThreshold

Alias fields and defaults
- Email (required)
Alias fields and defaults (see [sample](config/samples/operator_v1alpha1_alias.yaml))
- Name (required)
- Domain (required)
- Comment
- Destination
- Wildcard

### Simplified flow
Using `Domain` as an example resource
```mermaid
flowchart LR
CRD(Domain)
CRD(Domain resource)
Controller
MailUAPI(MailU API)
MailuAPI(Mailu API)

User -- create Domain resource --> CRD
User -- 1. create Domain resource --> CRD

Controller -- watch Domain resources --> CRD
Controller -- get/create/update Domain --> MailUAPI
Controller -- update resource --> CRD
Controller -- 2. watch Domain resources --> CRD
Controller -- 3. get/create/update Domain --> MailuAPI
Controller -- 4. update resource status --> CRD
```

## Getting Started

```shell
operator-sdk init --plugins=go/v4 --domain mailu.io --repo github.com/sickhub/mailu-operator
operator-sdk create api --group operator --version v1alpha1 --kind Domain --resource --controller
operator-sdk create api --group operator --version v1alpha1 --kind User --resource --controller
operator-sdk create api --group operator --version v1alpha1 --kind Alias --resource --controller
```


### Prerequisites
- go version v1.21.0+
- docker version 17.03+.
- kubectl version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.
- A running installation of [Mailu](https://github.com/Mailu/Mailu) with API enabled.


## Try it out
As this project is brand new and in alpha stage, here are the current steps to try it out:

```shell
REGISTRY=<your-registry>
# 1. build the image and push it to your own registry
make docker-buildx IMG=$REGISTRY/mailu-operator:v0.0.1

# 2. build the `install.yaml` used to deploy the operator (including CRDs, Roles and Deployment)
make build-installer IMG=$REGISTRY/mailu-operator:v0.0.1

# 3. apply the `install.yaml` to your k8s cluster
kubectl apply -f dist/install.yaml
```

Uninstall
```shell
kubectl delete -f dist/install.yaml
```


## Development: Build and deploy on your cluster

To setup the project, `operator-sdk` was used to generate the structure and custom resource objects:
```shell
operator-sdk init --plugins=go/v4 --domain mailu.io --repo github.com/sickhub/mailu-operator
operator-sdk create api --group operator --version v1alpha1 --kind Domain --resource --controller
operator-sdk create api --group operator --version v1alpha1 --kind User --resource --controller
operator-sdk create api --group operator --version v1alpha1 --kind Alias --resource --controller
```

### To Deploy on the cluster
**Build and push your image to the location specified by `IMG`:**

```sh
Expand Down
3 changes: 2 additions & 1 deletion config/samples/operator_v1alpha1_alias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: alias-sample
spec:
email: test@example.com
comment: "test email"
destination:
- test2@example.com
domain: example.com
name: test
wildcard: true