---
# System prepended metadata

title: CMO Development

---

# CMO Development 

## Run CMO Locally
### Assumptions
* Should have a cluster running
* Has setup Go development env

### Build and Run CMO

The `make` target `run-local` builds the `operator` and runs CMO locally

```shell
export KUBECONFIG=/path/to/kubeconfig/file
make run-local
```

### Fix jsonnet 

**TL;DR:**
1. build operator
1. use `hack/local-cmo.sh`
1. modify assets/yamls 
1. backport


Sometimes we may not want to rebuild the operator. E.g. you may need
to figure out how the stack behaves after applying a change to generated
kubernetes manifest.  In other words, to modify the YAML in `assets/` 
directory directly without needing to change the `jsonnet/` or 
the `vendored` jsonnet files. 

In these cases it is easier to change those yaml files manually, run 
the operator (with those changed files) and later tweak `jsonnet`, than 
to figuring out which parts of jsonnet code you may need to change to
fix an issue. 

It is easier to follow the following workflow
Setup: 
1. Start openshift cluster ( e.g. using `cluster-bot` )
1. `export KUBECONFIG=/path/to/kubeconfig`
1. Build operator - `make operator` 

Repeat:
1. Run `hack/local-cmo.sh` (**does not** build the operator)
1. Amend yaml files 
1. ☝☝☝ _rinse and repeat_

Finally:
1. Port the changes back to `jsonnet` or vendored `jsonnet`



## Updating vendored jsonnsets

NOTE: `jb update <repo-url>/<jsonnet-subdir>` doesn't seem to work since it
does not update the dependencies (at the time of writing)

Steps to update a bundle e.g. `kube-prometheus`:

```shell
cd jsonnset


# edit jsonnset.json and remove all but the bundle you want to update
# remove everything but *kube-prometheus* from the jsonnet.json file
jb update
cp lockfile.json backup
# restore the original jsonnet.json file
git checkout -- jsonnet.json # (restore to original)

#apply all changes from backup to lockfile
vimdiff backup lockfile.json  

rm -rf vendor ; jb install

# Now you should have only the changes that is part 
# of latest kube-prometheus (release 0.8)
make generate
git add everything and commit

```