Skip to content
This repository was archived by the owner on Sep 21, 2020. It is now read-only.

Added custom resource definition instructions #30

Merged
Merged
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
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,6 @@ This creates the `memcached-operator` project.

Learn more about the project directory structure from the SDK [project layout][layout_doc] documentation.

#### Define the Memcached spec and status

Modify the spec and status of the `Memcached` Custom Resource (CR) at `pkg/apis/cache/v1alpha1/memcached_types.go`:

```Go
type MemcachedSpec struct {
// Size is the size of the memcached deployment
Size int32 `json:"size"`
}
type MemcachedStatus struct {
// Nodes are the names of the memcached pods
Nodes []string `json:"nodes"`
}
```

After modifying the `*_types.go` file always run the following command to update the generated code for that resource type:

```sh
$ operator-sdk generate k8s
```

### Manager

The main program for the operator `cmd/manager/main.go` initializes and runs the [Manager][manager_go_doc].
Expand Down Expand Up @@ -88,6 +67,27 @@ $ operator-sdk add api --api-version=cache.example.com/v1alpha1 --kind=Memcached

This will scaffold the `Memcached` resource API under `pkg/apis/cache/v1alpha1/...`.

### Define the Memcached spec and status

Modify the spec and status of the `Memcached` Custom Resource (CR) at `pkg/apis/cache/v1alpha1/memcached_types.go`:

```Go
type MemcachedSpec struct {
// Size is the size of the memcached deployment
Size int32 `json:"size"`
}
type MemcachedStatus struct {
// Nodes are the names of the memcached pods
Nodes []string `json:"nodes"`
}
```

After modifying the `*_types.go` file always run the following command to update the generated code for that resource type:

```sh
$ operator-sdk generate k8s
```

## Add a new Controller

Add a new [Controller][controller_go_doc] to the project that will watch and reconcile the `Memcached` resource:
Expand Down