Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm: allow relative paths for helm charts in watches.yaml file #2287

Merged
merged 1 commit into from
Dec 4, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Added
- Support for vars in top level ansible watches. ([#2147](https://github.com/operator-framework/operator-sdk/pull/2147))
- Support for `"ansible.operator-sdk/verbosity"` annotation on Custom Resources watched by Ansible based operators to override verbosity on an individual resource. ([#2102](https://github.com/operator-framework/operator-sdk/pull/2102))
- Support for relative helm chart paths in the Helm operator's watches.yaml file. ([#2287](https://github.com/operator-framework/operator-sdk/pull/2287))

### Changed
- Upgrade minimal Ansible version in the init projects from `2.4` to `2.6`. ([#2107](https://github.com/operator-framework/operator-sdk/pull/2107))
Expand Down
15 changes: 2 additions & 13 deletions doc/helm/dev/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ mandatory fields:
**chart**: This is the path to the Helm chart that you have added to the
container. For example, if your Helm charts directory is at
`/opt/helm/helm-charts/` and your Helm chart is named `busybox`, this value
will be `/opt/helm/helm-charts/busybox`.
will be `/opt/helm/helm-charts/busybox`. If the path is relative, it is
relative to the current working directory.

Example specifying a Helm chart watch:

Expand Down Expand Up @@ -267,18 +268,6 @@ when we were testing our Helm chart locally. This section assumes the developer
has read the [Helm Operator user guide][helm_operator_user_guide] and has the
proper dependencies installed.

Since `up local` reads from `./watches.yaml`, there are a couple options
available to the developer. If `chart` is left alone (by default
`/opt/helm/helm-charts/<name>`) the Helm chart must exist at that location in
the filesystem. It is recommended that the developer create a symlink at this
location, pointed to the Helm chart in the project directory, so that changes
to the Helm chart are reflected where necessary.

```sh
sudo mkdir -p /opt/helm/helm-charts
sudo ln -s $PWD/helm-charts/<name> /opt/helm/helm-charts/<name>
```

Create a Custom Resource Definition (CRD) for resource Foo. `operator-sdk` autogenerates this file
inside of the `deploy` folder:

Expand Down
14 changes: 1 addition & 13 deletions doc/helm/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ in `watches.yaml` and executes Helm releases using the specified chart:
- version: v1alpha1
group: example.com
kind: Nginx
chart: /opt/helm/helm-charts/nginx
chart: helm-charts/nginx
```

### Reviewing the Nginx Helm Chart
Expand Down Expand Up @@ -210,18 +210,6 @@ nginx-operator 1 1 1 1 1m

This method is preferred during the development cycle to speed up deployment and testing.

It is important that the `chart` path referenced in `watches.yaml` exists
on your machine. By default, the `watches.yaml` file is scaffolded to work with
an operator image built with `operator-sdk build`. When developing and
testing your operator with `operator-sdk up local`, the SDK will look in your
local filesystem for this path. The SDK team recommends creating a symlink at
this location to point to your helm chart's path:

```sh
sudo mkdir -p /opt/helm/helm-charts
sudo ln -s $PWD/helm-charts/nginx /opt/helm/helm-charts/nginx
```

Run the operator locally with the default Kubernetes config file present at
`$HOME/.kube/config`:

Expand Down
3 changes: 2 additions & 1 deletion internal/scaffold/helm/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ if ! whoami &>/dev/null; then
fi
fi

exec ${OPERATOR} run helm --watches-file=/opt/helm/watches.yaml $@
cd $HOME
exec ${OPERATOR} run helm --watches-file=$HOME/watches.yaml $@
`
2 changes: 1 addition & 1 deletion internal/scaffold/helm/watches.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ const watchesYAMLTmpl = `---
- version: {{.Resource.Version}}
group: {{.Resource.FullGroup}}
kind: {{.Resource.Kind}}
chart: /opt/helm/{{.HelmChartsDir}}/{{.ChartName}}
chart: {{.HelmChartsDir}}/{{.ChartName}}
`