Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions doc/operator-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ For each CRD that needs to be cluster-scoped, update its manifest to be cluster-
* `deploy/crds/<group>_<version>_<kind>_crd.yaml`
* Set `spec.scope: Cluster`

To ensure that the CRD is always generated with `scope: Cluster`, add the tag `// +genclient:nonNamespaced` above the CRD's Go type defintion in `pkg/apis/<group>/<version>/<kind>_types.go`.


### Example for cluster scoped operator

Expand Down Expand Up @@ -82,3 +84,18 @@ With the above changes the specified manifests should look as follows:
...
scope: Cluster
```
* `pkg/apis/cache/v1alpha1/memcached_types.go`
```Go
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// Memcached is the Schema for the memcacheds API
// +k8s:openapi-gen=true
// +genclient:nonNamespaced
type Memcached struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MemcachedSpec `json:"spec,omitempty"`
Status MemcachedStatus `json:"status,omitempty"`
}
```
2 changes: 2 additions & 0 deletions doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ By default this will be the namespace that the operator is running in. To watch
mgr, err := manager.New(cfg, manager.Options{Namespace: ""})
```

By default the main program will set the manager's namespace using the value of `WATCH_NAMESPACE` env defined in `deploy/operator.yaml`.

## Add a new Custom Resource Definition

Add a new Custom Resource Definition(CRD) API called Memcached, with APIVersion `cache.example.com/v1alpha1` and Kind `Memcached`.
Expand Down