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

docs: add developer docs for chartsvc and chart-repo #775

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions docs/developer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Please refer to the [Kubeapps Dashboard Developer Guide](dashboard.md) for the d

The `chartsvc` component is a micro-service that creates a API endpoint for accessing the metadata for charts in Helm chart repositories that's populated in a MongoDB server.

<!-- TODO: Point to developer guide in Monocular repo -->
Please refer to the [Kubeapps chartsvc Developer Guide](chartsvc.md) for the developer setup.

### chart-repo

The `chart-repo` component is tool that scans a Helm chart repository and populates chart metadata in a MongoDB server. This metadata is then served by the `chartsvc` component.

<!-- TODO: Point to developer guide in Monocular repo -->
Please refer to the [Kubeapps chart-repo Developer Guide](chart-repo.md) for the developer setup.

### tiller-proxy

Expand Down
62 changes: 62 additions & 0 deletions docs/developer/chart-repo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Kubeapps chart-repo Developer Guide

The `chart-repo` component is tool that scans a Helm chart repository and populates chart metadata in a MongoDB server. This metadata is then served by the `chartsvc` component. Its source is maintained in the [Monocular project repository](https://github.com/helm/monocular).

## Prerequisites

- [Git](https://git-scm.com/)
- [Make](https://www.gnu.org/software/make/)
- [Go programming language](https://golang.org/dl/)
- [Docker CE](https://www.docker.com/community-edition)
- [Kubernetes cluster (v1.8+)](https://kubernetes.io/docs/setup/pick-right-solution/). [Minikube](https://github.com/kubernetes/minikbue) is recommended.
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- [Telepresence](https://telepresence.io)

## Environment

```bash
export GOPATH=~/gopath/
export PATH=$GOPATH/bin:$PATH
export MONOCULAR_DIR=$GOPATH
```

## Download the Monocular source code

```bash
git clone https://github.com/helm/monocular $MONOCULAR_DIR
```

The `chart-repo` sources are located under the `cmd/chart-repo/` directory.

### Install Kubeapps in your cluster

Kubeapps is a Kubernetes-native application. To develop and test Kubeapps components we need a Kubernetes cluster with Kubeapps already installed. Follow the [Kubeapps installation guide](../../chart/kubeapps/README.md) to install Kubeapps in your cluster.

### Building the `chart-repo` image

```bash
cd $MONOCULAR_DIR
dep ensure
make -C cmd/chart-repo docker-build
```

This builds the `chart-repo` Docker image.

### Running in development
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't we just point here to the monocular repo? We are having duplicated documentation

Also this is likely to get outdated since the source code of this tool is not in this repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #775 (comment).

Also this is likely to get outdated since the source code of this tool is not in this repo.

But how often do we need to change the development workflow?

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that we don't update them very often


#### Option 1: Using Telepresence (recommended)
Copy link
Contributor

Choose a reason for hiding this comment

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

this guide only have one option so I guess we can skip the heading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, thanks!


```bash
export MONGO_PASSWORD=$(kubectl get secret --namespace kubeapps kubeapps-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
telepresence --namespace kubeapps --docker-run -e MONGO_PASSWORD=$MONGO_PASSWORD --rm -ti quay.io/helmpack/chart-repo /chart-repo sync --mongo-user=root --mongo-url=kubeapps-mongodb stable https://kubernetes-charts.storage.googleapis.com
```

Note that the chart-repo should be rebuilt for new changes to take effect.

### Running tests

You can run the chart-repo tests along with the tests for the Monocular project:

```bash
go test -v ./...
```
81 changes: 81 additions & 0 deletions docs/developer/chartsvc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Kubeapps chartsvc Developer Guide

The `chartsvc` component is a micro-service that creates an API endpoint for accessing the metadata for charts in Helm chart repositories that's populated in a MongoDB server. Its source is maintained in the [Monocular project repository](https://github.com/helm/monocular).

## Prerequisites

- [Git](https://git-scm.com/)
- [Make](https://www.gnu.org/software/make/)
- [Go programming language](https://golang.org/dl/)
- [Docker CE](https://www.docker.com/community-edition)
- [Kubernetes cluster (v1.8+)](https://kubernetes.io/docs/setup/pick-right-solution/). [Minikube](https://github.com/kubernetes/minikbue) is recommended.
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
- [Telepresence](https://telepresence.io)

## Environment

```bash
export GOPATH=~/gopath/
export PATH=$GOPATH/bin:$PATH
export MONOCULAR_DIR=$GOPATH
```

## Download the Monocular source code

```bash
git clone https://github.com/helm/monocular $MONOCULAR_DIR
```

The `chartsvc` sources are located under the `cmd/chartsvc/` directory.

### Install Kubeapps in your cluster

Kubeapps is a Kubernetes-native application. To develop and test Kubeapps components we need a Kubernetes cluster with Kubeapps already installed. Follow the [Kubeapps installation guide](../../chart/kubeapps/README.md) to install Kubeapps in your cluster.

### Building the `chartsvc` image

```bash
cd $MONOCULAR_DIR
dep ensure
make -C cmd/chartsvc docker-build
```

This builds the `chartsvc` Docker image.

### Running in development

#### Option 1: Using Telepresence (recommended)

```bash
telepresence --swap-deployment kubeapps-internal-chartsvc --namespace kubeapps --expose 8080:8080 --docker-run --rm -ti quay.io/helmpack/chartsvc /chartsvc --mongo-user=root --mongo-url=kubeapps-mongodb
```

Note that the chartsvc should be rebuilt for new changes to take effect.

#### Option 2: Replacing the image in the chartsvc Deployment

Note: By default, Kubeapps will try to fetch the latest version of the image so in order to make this workflow work in Minikube you will need to update the imagePullPolicy first:

```
kubectl patch deployment kubeapps-internal-chartsvc -n kubeapps --type=json -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/imagePullPolicy", "value": "IfNotPresent"}]'
```

```
kubectl set image -n kubeapps deployment kubeapps-internal-chartsvc chartsvc=quay.io/helmpack/chartsvc:latest
```

For further redeploys you can change the version to deploy a different tag or rebuild the same image and restart the pod executing:

```
kubectl delete pod -n kubeapps -l app=kubeapps-internal-chartsvc
```

Note: If you using a cloud provider to develop the service you will need to retag the image and push it to a public registry.

### Running tests

You can run the chartsvc tests along with the tests for the Monocular project:

```bash
go test -v ./...
```