You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
📖 Update new provider docs to be more current (#12085)
* docs: make the mkdir and cd use the same directory
Signed-off-by: cprivitere <[email protected]>
* docs: document staging the generated files to the git commit
Signed-off-by: cprivitere <[email protected]>
* docs: remove status subresource section
- created by default since kubebuilder 3.0 in 2020
Signed-off-by: cprivitere <[email protected]>
* docs: add comments back and remove reference to deleted comments
- referencing deleted comments is very confusing to understand
Signed-off-by: cprivitere <[email protected]>
* docs: update scaffold examples to current kubebuilder output
Signed-off-by: cprivitere <[email protected]>
* docs: point readers to where the files in question likely are
Signed-off-by: cprivitere <[email protected]>
* docs: replace Captain with Mailgun for consistency in example
Signed-off-by: cprivitere <[email protected]>
* docs: grammar and typo fix
Signed-off-by: cprivitere <[email protected]>
* docs: update examples to what you get from current kubebuilder version
Signed-off-by: cprivitere <[email protected]>
* docs: Improvements to consistency and functionality of example code
- Consistently refer to cluster as mailgunCluster
- Add that you need to import the cluster-api package to your project before you can use the util function
- Use mailgunCluster.ObjectMeta instead of a pointer in GetOwnerCluster call
- Add explanation that we need to wait for the Cluster API controller to set the ownerref before we can use the cluster object, update code to do that
- Show entire Reconcile function again after adding many lines to it
Signed-off-by: cprivitere <[email protected]>
* docs: update reconciler initiation to be like current kubebuilder provided scaffold
Signed-off-by: cprivitere <[email protected]>
* docs: correct typo of credentials manifest filename
Signed-off-by: cprivitere <[email protected]>
* docs: update and simplify image name section
- Provide directions that work with current kubebuilder output
- Provide simpler example overriding of image name
- Drop old no longer working example of image name patching
- Providing a more current example of how providers actually do this would involve teaching about CI/CD setups which seems out of scope for this document
Signed-off-by: cprivitere <[email protected]>
* docs: update cluster-api deployment section
- Old section didn't work anymore
- replace it with a link to the quick start guide
- Suggest/note that we assume the user will use kind and clusterctl init, which will install cert-manager automatically.
- Update Condition status example to match what a kubectl describe currently shows
Signed-off-by: cprivitere <[email protected]>
* docs: update example of runing provider in a local kind cluster
- Show how to load the image into kind
- Use a tag that isn't latest so kubernetes won't try to pull it from docker hub
- Update Conditions fields to current kubernetes output
Signed-off-by: cprivitere <[email protected]>
* docs: update tilt example
- Tilt example wasn't functional as it was
- Added go_main to point to where kubebuilder puts main.go
- Use make tilt-up instead of trying to build your own kind cluster to proerly set up tilt to use the local registry config showin in the example tilt files
Signed-off-by: cprivitere <[email protected]>
* docs: remove unneeded ctx from example
Signed-off-by: cprivitere <[email protected]>
* docs: simplify getowner introduction
Signed-off-by: cprivitere <[email protected]>
---------
Signed-off-by: cprivitere <[email protected]>
The IMG variable is used to build the Docker image and push it to a registry. The default value is `controller:latest`, which is a local image. You can change it to a remote image if you want to push it to a registry.
make docker-push IMG=ghcr.io/your-org/your-repo:dev
27
9
```
28
10
11
+
## Deployment
12
+
29
13
### Cluster API
30
14
31
15
Before you can deploy the infrastructure controller, you'll need to deploy Cluster API itself to the management cluster.
32
16
33
-
You can use a precompiled manifest from the [release page][releases], run `clusterctl init`, or clone [`cluster-api`][capi]and apply its manifests using `kustomize`:
17
+
Follow the [quick start guide](https://cluster-api.sigs.k8s.io/user/quick-start) up to and including the step of [creating the management cluster](https://cluster-api.sigs.k8s.io/user/quick-start#initialize-the-management-cluster). We will proceed presuming you created a cluster with kind and initalized cluster-api with `clusterctl init`.
If you're using kind for your management cluster, you can use the following command to build and push your image to the kind cluster's local registry. We need to use the IMG variable to override the default `controller:latest` image name with a specific version like `controller:0.1` to avoid having kubernetes try to pull the latest version of `controller` from docker hub.
49
+
50
+
```bash
51
+
cd cluster-api-provider-mailgun
52
+
53
+
# Build the Docker image
54
+
make docker-build IMG=controller:dev
55
+
56
+
# Load the Docker image into the kind cluster
57
+
kind load docker-image controller:dev
58
+
```
59
+
69
60
Now you can apply your provider as well:
70
61
71
62
```bash
72
63
cd cluster-api-provider-mailgun
73
64
74
65
# Install CRD and controller to current kubectl context
75
-
make install deploy
66
+
make install deploy IMG=controller:dev
76
67
77
68
kubectl describe -n cluster-api-provider-mailgun-system pod | grep -A 5 Conditions
go_main: cmd/main.go # kubebuilder puts main.go under the cmd directory
105
97
```
106
98
107
99
- Create file `tilt-settings.yaml` in the cluster-api directory:
@@ -116,15 +108,11 @@ enable_providers:
116
108
- mailgun
117
109
```
118
110
119
-
- Create a kind cluster. By default, Tiltfile assumes the kind clusteris named `capi-test`.
111
+
- Bring tilt up by using the `make tilt-up` command in the cluster-api directory. This will ensure tilt is set up correctly to use a local registry for your image. You may need to `make tilt-clean` before this if you've been using tilt with other providers.
120
112
121
113
```bash
122
-
kind create cluster --name capi-test
123
-
124
-
# If you want a more sophisticated setup of kind cluster + image registry, try:
If our cluster was just created, the Cluster API controller may not have set the ownership reference on our object yet, so we'll have to return here and wait to do more with our cluster object until then. We can leave a log message noting that we're waiting for the main Cluster API controller to set the ownership reference. Here's what our `Reconcile()` function looks like now:
log.Info("Waiting for Cluster Controller to set OwnerRef on MailGunCluster")
176
+
return ctrl.Result{}, nil
177
+
}
178
+
```
179
+
143
180
### The fun part
144
181
145
182
_More Documentation: [The Kubebuilder Book][book] has some excellent documentation on many things, including [how to write good controllers!][implement]_
@@ -152,10 +189,10 @@ This is where your provider really comes into its own.
152
189
In our case, let's try sending some mail:
153
190
154
191
```go
155
-
subject:= fmt.Sprintf("[%s] New Cluster %s requested", mgCluster.Spec.Priority, cluster.Name)
156
-
body:= fmt.Sprint("Hello! One cluster please.\n\n%s\n", mgCluster.Spec.Request)
192
+
subject:= fmt.Sprintf("[%s] New Cluster %s requested", mailgunCluster.Spec.Priority, cluster.Name)
193
+
body:= fmt.Sprintf("Hello! One cluster please.\n\n%s\n", mailgunCluster.Spec.Request)
0 commit comments