Skip to content

Commit

Permalink
Add build and deploy documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
liztio committed Nov 15, 2019
1 parent f7c5d60 commit 8a7d80f
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,99 @@ The approach most Cluster API projects is using [a `Makefile` that uses `sed` to

## Deployment

### Cluster API

Before you can deploy the infrastructure controller, you'll need to deploy Cluster API itself.

You can clone `cluster-api` for the latest version, or just [use a precompiled manifest][install].
You can [use a precompiled manifest][install], or clone [`cluster-api`][capi] and apply its manifests using `kustomize`.

``` shell
cd cluster-api
kustomize build config/default | kubectl apply -f-
```

Check the status of the manager to make sure it's running properly

```shell
$ kubectl describe -n capi-system pod | grep -A 5 Conditions
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
```

[install]: https://cluster-api.sigs.k8s.io/tasks/installation.html#install-cluster-api

### Your provider

Now you can apply your provider as well:

```
$ cd cluster-api-provider-mailgun
$ kustomize build config/default | envsubst | kubectl apply -f-
$ kubectl describe -n cluster-api-provider-mailgun-system pod | grep -A 5 Conditions
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
```

{% hint style="info" %}
Tiltfile: Cluster API development requires a lot of iteration, and the "build, tag, push, update deployment" workflow can be very tedious.
[Tilt](https://tilt.dev) makes this process much simpler by watching for updates, then automatically building and deploying them.

You can visit [some example repositories][capidev], but you can get started by writing out a yaml manifest and using the following [`Tiltfile`][tiltfile]
`kustomize build config/default | envsubst > capm.yaml`

[capidev]: https://github.com/chuckha/capi-dev
[tiltfile]: https://docs.tilt.dev/tiltfile_concepts.html

```starlark
allow_k8s_contexts('kubernetes-admin@luna')

k8s_yaml('capm.yaml')

docker_build('<your docke username or repository url>/cluster-api-controller-mailgun-amd64', '.')
```

You can then use Tilt to watch the logs coming off your container
{% endhint %}


## Your first Cluster

Let's try our cluster out. We'll make some simple YAML:

```yaml
apiVersion: cluster.x-k8s.io/v1alpha2
kind: Cluster
metadata:
name: hello-mailgun
spec:
clusterNetwork:
pods:
cidrBlocks: ["192.168.0.0/16"]
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: MailgunCluster
name: hello-mailgun
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha3
kind: MailgunCluster
metadata:
name: hello-mailgun
spec:
priority: "ExtremelyUrgent"
request: "Please make me a cluster, with sugar on top?"
requester: "[email protected]"
```
We apply it as normal with `kubectl apply -f <filename>.yaml`.

If all goes well, you should be getting an email to the address you configured when you set up your management cluster:

![An email from mailgun urgently requesting a cluster](cluster-email.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 40 additions & 1 deletion docs/book/provider_implementations/configure_and_deploy.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Configure and Deploy
# Configure

## YAML

Expand Down Expand Up @@ -100,6 +100,45 @@ You can now (hopefully) generate your yaml!
kustomize build config/default
```
## RBAC Role
The default [RBAC role][role] contains permissions for accessing your cluster infrastructure CRDs, but not for accessing Cluster API resources.
You'll need to add these to `config/rbac/role.yaml`
[role]: https://kubernetes.io/docs/reference/access-authn-authz/rbac/
```diff
diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml
index e9352ce..29008db 100644
--- a/config/rbac/role.yaml
+++ b/config/rbac/role.yaml
@@ -6,6 +6,24 @@ metadata:
creationTimestamp: null
name: manager-role
rules:
+- apiGroups:
+ - cluster.x-k8s.io
+ resources:
+ - clusters
+ - clusters/status
+ verbs:
+ - get
+ - list
+ - watch
+- apiGroups:
+ - cluster.x-k8s.io
+ resources:
+ - machines
+ - machines/status
+ verbs:
+ - get
+ - list
+ - watch
- apiGroups:
- infrastructure.cluster.x-k8s.io
resources:
```

## EnvSubst

{% hint style="info" %}
Expand Down

0 comments on commit 8a7d80f

Please sign in to comment.