Skip to content

Commit

Permalink
mdbook, not gitbook
Browse files Browse the repository at this point in the history
  • Loading branch information
liztio committed Nov 15, 2019
1 parent 90547bc commit 0468e7b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 49 deletions.
Expand Up @@ -5,12 +5,11 @@
The patch in `config/default/manager_image_patch.yaml` will be applied to the manager pod.
Right now there is a placeholder `IMAGE_URL`, which you will need to change to your actual image.

{% hint style="info" %}
Development Images: It's likely that you will want one location and tag for release development, and another during development.
### Development Images
It's likely that you will want one location and tag for release development, and another during development.

The approach most Cluster API projects is using [a `Makefile` that uses `sed` to replace the image URL][sed] on demand during development.
[sed]: https://github.com/kubernetes-sigs/cluster-api/blob/e0fb83a839b2755b14fbefbe6f93db9a58c76952/Makefile#L201-L204
{% endhint %}

## Deployment

Expand Down Expand Up @@ -55,8 +54,8 @@ Conditions:
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.
### 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]
Expand All @@ -74,7 +73,6 @@ docker_build('<your docke username or repository url>/cluster-api-controller-mai
```

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


## Your first Cluster
Expand Down
4 changes: 1 addition & 3 deletions docs/book/src/providers/implementers-guide/configure.md
Expand Up @@ -141,9 +141,7 @@ index e9352ce..29008db 100644

## EnvSubst

{% hint style="info" %}
A tool like [direnv](https://direnv.net/) can be used to help manage enviroment variables.
{% endhint %}
_A tool like [direnv](https://direnv.net/) can be used to help manage enviroment variables._


`kustomize` does not handle replacing those `${VARIABLES}` with actual values.
Expand Down
Expand Up @@ -101,8 +101,7 @@ if err != nil {
}
```

{% hint style="warning" %}
*client-go versions*
### client-go versions
At the time this document was written, `kubebuilder` pulls `client-go` version `1.14.1` into `go.mod` (it looks like `k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible`).

If you encounter an error when compiling like:
Expand All @@ -114,13 +113,9 @@ If you encounter an error when compiling like:
```

You may need to bump `client-go`. At time of writing, that means `1.15`, which looks like: `k8s.io/client-go v11.0.1-0.20190409021438-1a26190bd76a+incompatible`.
{% endhint %}

## The fun part

{% hint style="info" %}
More Documentation: [The Kubebuilder Book][book] has some excellent documentation on many things, including [how to write good controllers!][implement]
{% endhint %}
_More Documentation: [The Kubebuilder Book][book] has some excellent documentation on many things, including [how to write good controllers!][implement]_

[book]: https://book.kubebuilder.io/
[implement]: https://book.kubebuilder.io/cronjob-tutorial/controller-implementation.html
Expand Down
6 changes: 0 additions & 6 deletions docs/book/src/providers/implementers-guide/create_api.md
@@ -1,21 +1,15 @@
{% method %}

# Defining your API

The API generated by Kubebuilder is just a shell, your actual API will likely have more fields defined on it.

{% hint style="info" %}
Kubernetes has a lot of conventions and requirements around API design.
The [Kubebuilder docs][apidesign] have some helpful hints on how to design your types.
{% endhint %}

[apidesign]: https://book.kubebuilder.io/cronjob-tutorial/api-design.html#designing-an-api


Let's take a look at what was generated for us:

{% endmethod %}

```go
// MailgunClusterSpec defines the desired state of MailgunCluster
type MailgunClusterSpec struct {
Expand Down
11 changes: 0 additions & 11 deletions docs/book/src/providers/implementers-guide/generate_crds.md
@@ -1,7 +1,5 @@
{% method %}
### Create a repository

{% sample lang="bash" %}
```bash
mkdir cluster-api-provider-cluster-api-provider-mailgun
cd src/sigs.k8s.io/cluster-api-provider-mailgun
Expand All @@ -10,15 +8,11 @@ git init

You'll then need to set up [go modules][gomod]

{% sample lang="bash" %}
```bash
$ go mod init github.com/liztio/cluster-api-provider-mailgun
go: creating new go.mod: module github.com/liztio/cluster-api-provider-mailgun
```

{% endmethod %}

{% method %}
### Generate scaffolding

```bash
Expand All @@ -33,9 +27,6 @@ Commit your changes so far:
```bash
git commit -m "Generate scaffolding."
```
{% endmethod %}

{% method %}
### Generate provider resources for Clusters and Machines

Here you will be asked if you want to generate resources and controllers.
Expand All @@ -49,7 +40,6 @@ Create Controller under pkg/controller [y/n]?
y
```

{% sample lang="bash" %}
```bash
kubebuilder create api --group infrastructure --version v1alpha3 --kind MailgunCluster
kubebuilder create api --group infrastructure --version v1alpha3 --kind MailgunMachine
Expand All @@ -59,4 +49,3 @@ kubebuilder create api --group infrastructure --version v1alpha3 --kind MailgunM
git add .
git commit -m "Generate Cluster and Machine resources."
```
{% endmethod %}
13 changes: 1 addition & 12 deletions docs/book/src/providers/implementers-guide/naming.md
Expand Up @@ -12,30 +12,23 @@ more than one [_variant_][variant-naming]. So for example,
well as one based on their hosted EKS solution.


{% hint style="info" %}
## A note on Acronyms

Because these names end up being so long, developers of Cluster API frequently refer to providers by acronyms.
Cluster API itself becomes [CAPI], pronounced "Cappy."
cluster-api-provider-aws is [CAPA], pronounced "KappA."
cluster-api-provider-gcp is [CAPG], pronounced "Cap Gee," [and so on][letterc].

[CAPI] https://cluster-api.sigs.k8s.io/reference/glossary.html#capi
[CAPI]: https://cluster-api.sigs.k8s.io/reference/glossary.html#capi
[CAPA]: https://cluster-api.sigs.k8s.io/reference/glossary.html#capa
[CAPG]: https://cluster-api.sigs.k8s.io/reference/glossary.html#capg
[letterc]: https://cluster-api.sigs.k8s.io/reference/glossary.html#c
{% endhint %}

# Resource Naming

{% panel style="info", title="Important" %}
For the purposes of this guide we will create a provider for a
service named **mailgun**. Therefore the name of the repository will be
`cluster-api-provider-mailgun`.
{% endpanel %}


{% method %}

Every Kubernetes resource has a *Group*, *Version* and *Kind* that uniquely
identifies it.
Expand All @@ -51,19 +44,15 @@ identifies it.
often contain a domain name, such as k8s.io. The domain for Cluster API
resources is `cluster.k8s.io`.

{% sample lang="yaml" %}
```yaml
apiVersion: mailgun.cluster.k8s.io/v1alpha1
kind: MailgunMachineSpec
```

{% sample lang="yaml" %}
```yaml
apiVersion: mailgun.cluster.k8s.io/v1alpha1
kind: MailgunMachineStatus
```
{% endmethod %}

[repo-naming]: https://github.com/kubernetes-sigs/cluster-api/issues/383
[variant-naming]: https://github.com/kubernetes-sigs/cluster-api/issues/480

Expand Down
29 changes: 25 additions & 4 deletions docs/book/src/providers/implementers-guide/overview.md
Expand Up @@ -12,15 +12,20 @@ Much of the information here was adapted directly from it.

### tl;dr

{% codegroup %}
```bash::MacOS
{{#tabs name:"kind-cluster" tabs:"MacOS,Linux"}}
{{#tab MacOS}}

```bash
# Install kubectl
brew install kubernetes-cli

# Install kustomize
brew install kustomize
```
```bash::Linux
{{#/tab }}
{{#tab Linux}}

```bash
# Install kubectl
KUBECTL_VERSION=$(curl -sf https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -fLO https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl
Expand All @@ -35,7 +40,23 @@ curl -sf https://api.github.com/repos/kubernetes-sigs/kustomize/releases/latest
mv kustomize_*_${OS_TYPE}_amd64 /usr/local/bin/kustomize
chmod u+x /usr/local/bin/kustomize
```
{% endcodegroup %}

{{#/tab }}
{{#/tabs }}

```
# Install Kubebuilder
os=$(go env GOOS)
arch=$(go env GOARCH)
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.1.0/${os}/${arch} | tar -xz -C /tmp/
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.1.0_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
```

[kubebuilder-book]: https://book.kubebuilder.io/
[kubectl-install]: http://kubernetes.io/docs/user-guide/prereqs/
Expand Down

0 comments on commit 0468e7b

Please sign in to comment.