Skip to content
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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ Before creating any project, this guide has the following prerequisites:

Operator SDK CLI tool is used to manage development lifecycle.

Install the CLI tool:
Checkout the desired release tag and install the SDK CLI tool:
```
git checkout tags/v0.0.1
go install github.com/coreos/operator-sdk/commands/operator-sdk
```

Expand Down Expand Up @@ -117,7 +118,7 @@ Re-render the generated code for custom resource:
operator-sdk generate k8s
```

In `main.go`, modify `sdk.Watch` to watch on `Memcached` custom resource:
In `cmd/memcached-operator/main.go`, modify `sdk.Watch` to watch on `Memcached` custom resource:

```Go
func main() {
Expand All @@ -136,6 +137,7 @@ import (
"github.com/coreos/operator-sdk/pkg/sdk/action"
"github.com/coreos/operator-sdk/pkg/sdk/handler"
"github.com/coreos/operator-sdk/pkg/sdk/types"
"github.com/sirupsen/logrus"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line before "github.com/sirupsen/logrus"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github.com/coreos/operator-sdk/* and github.com/sirupsen/logrus are both vendored imports external to the memcached project.
I think our convention is to separate project and non-project imports.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right. I somehow thought we are modifying code inside operator-sdk

apps_v1 "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -145,6 +147,7 @@ func (h *Handler) Handle(ctx types.Context, event types.Event) []types.Action {
var actions []types.Action
switch obj := event.Object.(type) {
case *v1alpha1.Memcached:
logrus.Infof("Received Memcached: %v", obj.Name)
ls := map[string]string{
"app": "memcached",
"name": obj.Name,
Expand Down Expand Up @@ -181,6 +184,7 @@ func (h *Handler) Handle(ctx types.Context, event types.Event) []types.Action {
},
},
}
logrus.Infof("Creating Deployment: %v", obj.Name)
actions = append(actions, types.Action{
Object: d,
Func: action.KubeApplyFunc,
Expand All @@ -207,6 +211,7 @@ func (h *Handler) Handle(ctx types.Context, event types.Event) []types.Action {
}},
},
}
logrus.Infof("Creating Service: %v", obj.Name)
actions = append(actions, types.Action{
Object: svc,
Func: action.KubeApplyFunc,
Expand Down Expand Up @@ -268,7 +273,7 @@ We can test the Memcached service by opening a telnet session and running comman
```
It should output:
```
VALUE foo 0 0 3
VALUE foo 0 3
bar
```

Expand Down