Skip to content

Commit

Permalink
Assetsvc and asset-syncer docs (#1415)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andres Martinez Gotor authored Jan 8, 2020
1 parent 35d0ae1 commit 039812c
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ jobs:
- run: |
if [[ -z "$CIRCLE_PULL_REQUEST" && -n "$DOCKER_USERNAME" && -n "$DOCKER_PASSWORD" ]]; then
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
for IMAGE in kubeapps/apprepository-controller kubeapps/dashboard kubeapps/tiller-proxy; do
for IMAGE in kubeapps/apprepository-controller kubeapps/dashboard kubeapps/tiller-proxy kubeapps/asset-syncer kubeapps/assetsvc; do
docker pull ${IMAGE}${IMG_MODIFIER}:${DEV_TAG}
docker tag ${IMAGE}${IMG_MODIFIER}:${DEV_TAG} ${IMAGE}:${PROD_TAG}
docker push ${IMAGE}:${PROD_TAG}
Expand Down
8 changes: 4 additions & 4 deletions docs/architecture/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ This proxy is written in Go. Check more details about the implementation in this

Chart repositories in Kubeapps are managed with a `CustomResourceDefinition` called `apprepositories.kubeapps.com`. Each repository added to Kubeapps is an object of type `AppRepository` and the `apprepository-controller` will watch for changes on those type of objects to update the list of available charts to deploy.

### `chart-repo`
### `asset-syncer`

The `chart-repo` component is tool that scans a Helm chart repository and populates chart metadata in a MongoDB database. This metadata is then served by the chartsvc component. It is maintained as part of the [Helm Monocular project](https://github.com/helm/monocular/tree/master/cmd/chart-repo).
The `asset-syncer` component is tool that scans a Helm chart repository and populates chart metadata in a database. This metadata is then served by the `assetsvc` component. Check more details about the implementation in this [document](/docs/developer/asset-syncer.md).

### `chartsvc`
### `assetsvc`

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 database. It is maintained as part of the [Helm Monocular project](https://github.com/helm/monocular/tree/master/cmd/chartsvc).
The `assetsvc` component is a micro-service that creates an API endpoint for accessing the metadata for charts and other resources that's populated in a database. Check more details about the implementation in this [document](/docs/developer/asset-syncer.md).
68 changes: 68 additions & 0 deletions docs/developer/asset-syncer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Kubeapps asset-syncer Developer Guide

The `asset-syncer` component is a tool that scans a Helm chart repository and populates chart metadata in the database. This metadata is then served by the `assetsvc` component.

## 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 KUBEAPPS_DIR=$GOPATH/src/github.com/kubeapps/kubeapps
```

## Download the Kubeapps source code

```bash
git clone https://github.com/kubeapps/kubeapps $KUBEAPPS_DIR
```

The `asset-syncer` sources are located under the `cmd/asset-syncer/` 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 `asset-syncer` image

```bash
cd $KUBEAPPS_DIR
make kubeapps/asset-syncer
```

This builds the `asset-syncer` Docker image.

### Running in development

When using MongoDB:

```bash
export DB_PASSWORD=$(kubectl get secret --namespace kubeapps kubeapps-mongodb -o go-template='{{index .data "mongodb-root-password" | base64decode}}')
telepresence --namespace kubeapps --docker-run -e DB_PASSWORD=$DB_PASSWORD --rm -ti kubeapps/asset-syncer /asset-syncer sync --database-user=root --database-url=kubeapps-mongodb --database-type=mongodb --database-name=charts stable https://kubernetes-charts.storage.googleapis.com
```

When using PostgreSQL:

```bash
export DB_PASSWORD=$(kubectl get secret --namespace kubeapps kubeapps-db -o go-template='{{index .data "postgresql-password" | base64decode}}')
telepresence --namespace kubeapps --docker-run -e DB_PASSWORD=$DB_PASSWORD --rm -ti kubeapps/asset-syncer /asset-syncer sync --database-user=postgres --database-url=kubeapps-postgresql:5432 --database-type=postgresql --database-name=assets stable https://kubernetes-charts.storage.googleapis.com
```

Note that the asset-syncer should be rebuilt for new changes to take effect.

### Running tests

You can run the asset-syncer tests along with the tests for the Kubeapps project:

```bash
go test -v ./...
```
43 changes: 25 additions & 18 deletions docs/developer/chartsvc.md → docs/developer/assetsvc.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Kubeapps chartsvc Developer Guide
# Kubeapps assetsvc 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).
The `assetsvc` 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.

## Prerequisites

Expand All @@ -17,64 +17,71 @@ The `chartsvc` component is a micro-service that creates an API endpoint for acc
```bash
export GOPATH=~/gopath
export PATH=$GOPATH/bin:$PATH
export MONOCULAR_DIR=$GOPATH
export KUBEAPPS_DIR=$GOPATH/src/github.com/kubeapps/kubeapps
```

## Download the Monocular source code
## Download the Kubeapps source code

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

The `chartsvc` sources are located under the `cmd/chartsvc/` directory.
The `assetsvc` sources are located under the `cmd/assetsvc/` 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
### Building the `assetsvc` image

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

This builds the `chartsvc` Docker image.
This builds the `assetsvc` Docker image.

### Running in development

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

When using MongoDB:

```bash
telepresence --swap-deployment kubeapps-internal-assetsvc --namespace kubeapps --expose 8080:8080 --docker-run --rm -ti kubeapps/assetsvc /assetsvc --database-user=root --database-url=kubeapps-mongodb --database-type=mongodb --database-name=charts
```

When using PostgreSQL:

```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
telepresence --swap-deployment kubeapps-internal-assetsvc --namespace kubeapps --expose 8080:8080 --docker-run --rm -ti kubeapps/assetsvc /assetsvc --database-user=postgres --database-url=kubeapps-postgresql:5432 --database-type=postgresql --database-name=assets
```

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

#### Option 2: Replacing the image in the chartsvc Deployment
#### Option 2: Replacing the image in the assetsvc 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 patch deployment kubeapps-internal-assetsvc -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
kubectl set image -n kubeapps deployment kubeapps-internal-assetsvc assetsvc=kubeapps/assetsvc: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
kubectl delete pod -n kubeapps -l app=kubeapps-internal-assetsvc
```

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:
You can run the assetsvc tests along with the tests for the Kubeapps project:

```bash
go test -v ./...
Expand Down
60 changes: 0 additions & 60 deletions docs/developer/chart-repo.md

This file was deleted.

0 comments on commit 039812c

Please sign in to comment.