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

Add Helm chart for installing Kubeapps #349

Merged
merged 22 commits into from
Aug 2, 2018

Conversation

prydonius
Copy link
Contributor

@prydonius prydonius commented Jun 7, 2018

fixes #325

Todos:

  • values for configuring TLS with tiller-proxy

@prydonius
Copy link
Contributor Author

@arapulido the latest changes should be testable, you'll need to install Tiller using helm init and build your own images for the dashboard and apprepository-controller

@arapulido
Copy link
Contributor

@prydonius I have checked this and I am getting a CRD validation error:

helm install --set apprepository.image.repository=arapulido/apprepository-controller --set dashboard.image.repository=arapulido/dashboard ./kubeapps
Error: apiVersion "kubeapps.com/v1alpha1" in kubeapps/templates/apprepositories.yaml is not available

I have been checking around but it seems that there is not yet a solution for this. Did you encounter this error? How did you fix it?

@prydonius
Copy link
Contributor Author

Oh woops, I forgot to mention you also need the RC Helm version: https://github.com/helm/helm/releases/tag/v2.10.0-rc.1, it adds support for a CRD hook. I was hoping for this to be released this week, but if not it will be a blocker for our release or we will need a workaround.

export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "kubeapps.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.frontend.service.port }}
{{- else if contains "ClusterIP" .Values.frontend.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "kubeapps.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
Copy link
Contributor

Choose a reason for hiding this comment

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

The pod get the app label as .Release.Name-.kubeapps.name, instead of just kubeapps, so the command shown here will get 0 pods

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

{{- else if contains "ClusterIP" .Values.frontend.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "kubeapps.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:80
Copy link
Contributor

Choose a reason for hiding this comment

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

The pod is listening in the port 8080, so the command above should be kubectl port-forward $POD_NAME 8080

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

@arapulido
Copy link
Contributor

arapulido commented Jul 24, 2018

App Repositories view is empty, even though the charts are loading fine:
screen shot 2018-07-24 at 12 27 06 pm

There are no errors in the console or the logs.

Adding a new repo fails, this shows in the console:

TypeError: "e.metadata is undefined"
renderhttp://localhost:8080/static/js/main.6090e182.js:1:3562936renderhttp://localhost:8080/static/js/main.6090e182.js:1:3562890lhttp://localhost:8080/static/js/main.6090e182.js:1:1056655beginWorkhttp://localhost:8080/static/js/main.6090e182.js:1:1058377ihttp://localhost:8080/static/js/main.6090e182.js:1:1070502ahttp://localhost:8080/static/js/main.6090e182.js:1:1070823shttp://localhost:8080/static/js/main.6090e182.js:1:1071061whttp://localhost:8080/static/js/main.6090e182.js:1:1074605yhttp://localhost:8080/static/js/main.6090e182.js:1:1074342hhttp://localhost:8080/static/js/main.6090e182.js:1:1073470phttp://localhost:8080/static/js/main.6090e182.js:1:1072860enqueueSetStatehttp://localhost:8080/static/js/main.6090e182.js:1:1047385setStatehttp://localhost:8080/static/js/main.6090e182.js:1:1026654onStateChangehttp://localhost:8080/static/js/main.6090e182.js:1:241229notifyhttp://localhost:8080/static/js/main.6090e182.js:1:1125085notifyNestedSubshttp://localhost:8080/static/js/main.6090e182.js:1:1125602onStateChangehttp://localhost:8080/static/js/main.6090e182.js:1:241247uhttp://localhost:8080/static/js/main.6090e182.js:1:243585nhttp://localhost:8080/static/js/main.6090e182.js:1:1142948nhttp://localhost:8080/static/js/main.6090e182.js:1:1738533dispatchhttp://localhost:8080/static/js/main.6090e182.js:1:1132779Phttp://localhost:8080/static/js/main.6090e182.js:1:1199752nhttp://localhost:8080/static/js/main.6090e182.js:1:1197258rhttp://localhost:8080/static/js/main.6090e182.js:1:1196595ahttp://localhost:8080/static/js/main.6090e182.js:1:1196335

@arapulido
Copy link
Contributor

Installing charts doesn't work for me either

@arapulido
Copy link
Contributor

@tompizmor @javsalgar It would be very useful if you start reviewing this as well, thanks!

@prydonius
Copy link
Contributor Author

Hmm, thanks @arapulido. Seems to be an issue when building the docker image for the Dashboard, because with Telepresence the AppRepositories work for me.

With the image you built, I can see that the namespace it retrieves from the config is undefined: http://localhost:8080/api/kube/apis/kubeapps.com/v1alpha1/namespaces/undefined/apprepositories. This is also why installing charts doesn't work, because it tries to fetch the AppRepository but the namespace is not being found. Will continue looking into it.

Adnan Abdulhussein added 2 commits July 24, 2018 16:57
@prydonius
Copy link
Contributor Author

The issue was the ConfigMap was incorrect JSON (oops!), when using telepresence it uses the local config.json which was correct.

Also the creation error for AppRepositories was due to using the wrong resource link, fixed that too.

Note, when doing a Helm upgrade, please make sure you set the same password for MongoDB, otherwise it will get regenerated (known Helm issue - helm/helm#3053) and break chart syncs and the chartsvc:

$ kubectl get secret $RELEASE_NAME-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode
$ helm upgrade $RELEASE_NAME --set apprepository.image.repository=arapulido/apprepository-controller --set dashboard.image.repository=arapulido/dashboard --set mongodb.mongodbRootPassword=$MONGO_PASSWORD ./kubeapps

@arapulido
Copy link
Contributor

@prydonius I have rebuilt and deployed the chart in a new cluster, and now the Dashboard doesn't get the login form, but tries directly to get to the App list (getting a 401 in response)

@arapulido
Copy link
Contributor

@prydonius I have tested the chart and with the cluster-admin role things seem to work, but as soon as I create a serviceaccount with less permissions, it seems that we need to create the roles manually (when with kubeapps up they are created automatically). It looks like all RBAC roles are missing: https://github.com/kubeapps/kubeapps/blob/master/manifests/user-roles.jsonnet

I get this error when deploying to the namespace my serviceaccount has write access to:
screen shot 2018-07-26 at 4 41 50 pm

that also talks about the kubeapps namespace, which is wrong in this case.

@arapulido
Copy link
Contributor

Once I created a role to read apprepositories in the default namespace and applied it in a binding to the serviceaccount I was using, I was able to deploy the chart to my namespace

@@ -0,0 +1,5 @@
apiVersion: v1
Copy link
Member

Choose a reason for hiding this comment

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

Should you also add the maintainers and other metadata like home, sources and icon?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I'll do that, thanks!

metadata:
name: {{ template "kubeapps.apprepository.fullname" . }}
labels:
app: {{ template "kubeapps.apprepository.fullname" . }}
Copy link
Member

Choose a reason for hiding this comment

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

I see that when there is an issue deploying a chart from kubeapps the following message is show:

Check the health of Kubeapps components 'kubectl get po --all-namespaces -l created-by=kubeapps'.

However, it seems any pod created by the chart has the label created-by=kubeapps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where are you seeing that? I thought that was from the kubeapps CLI, it's not in the NOTES.txt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh sorry, it's actually shown in the UI, will fix that thanks. Note you'll need to build images for the apprepository-controller and dashboard to make this actually work.

Copy link
Member

Choose a reason for hiding this comment

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

yes, I saw that Ara already built the images so I used the same ones

repository: kubeapps/chart-repo
tag: latest
repos:
- name: stable
Copy link
Member

Choose a reason for hiding this comment

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

Have you thought about also adding the bitnami charts repo here?

serviceAccountName: {{ template "kubeapps.apprepository.fullname" . }}
containers:
- name: controller
image: "{{ .Values.apprepository.image.repository }}:{{ .Values.apprepository.image.tag }}"
Copy link
Member

Choose a reason for hiding this comment

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

do you think it makes sense to also allow specifying the registry for the container image?

Copy link
Contributor Author

@prydonius prydonius Jul 27, 2018

Choose a reason for hiding this comment

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

Maybe we should do it for consistency, but I was just going off the helm create template. TBH I don't really like adding the registry value, because I don't think the value needs to be so fine-grained, setting repository=myregistry.com/apprepository-controller works fine right?

It's also confusing if you're used to the upstream charts that just have the repository value, if we had registry default to docker.io, then the above would actually render docker.io/myregistry.com/apprepository-controller which would be incorrect.

Choose a reason for hiding this comment

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

In other charts the image is set using a template. This could be easier down the line if we want to change the way we set the images ("registry, repository, image" or "repository,image")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@javsalgar I couldn't find where the template was used, we seem to be just doing this: https://github.com/helm/charts/blob/master/stable/drupal/templates/deployment.yaml#L27. In any case, since this chart will eventually be going into bitnami/charts I am going to update it for consistency

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

I gave this a test and it worked as expected. For Kubeless I would suggest that instead of adding it as a subchart I would do the same that we do with the service catalog: Detect that it's missing and point to the kubeless chart that is in the incubator registry. If that gets complicated for any reason we should show a custom error message in the Functions view.

Let me know when you want me to take a look to this again!

{{- else if contains "ClusterIP" .Values.frontend.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app={{ template "kubeapps.fullname" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:8080
Copy link
Contributor

Choose a reason for hiding this comment

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

kubectl port-forward --namespace {{ .Release.Namespace}} $POD_NAME 8080:8080

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah good catch, thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Is that what technically kubeapps dashboard used to do?

Copy link
Contributor

@migmartri migmartri left a comment

Choose a reason for hiding this comment

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

Does helm support subdirectories under templates/ i.e apprepository/ chart-svc/`

Not for now, but I am curious if it would make sense to make them separated charts and the dashboard imports them as subcharts. As I said, not important since nobody is going to re-use them for now and we are going to package them all at the same time but food for thought.

@@ -75,4 +78,7 @@ func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&repoSyncImage, "repo-sync-image", "kubeapps/chart-repo:latest", "container repo/image to use in CronJobs")
flag.StringVar(&namespace, "namespace", "kubeapps", "Namespace to discover AppRepository resources")
Copy link
Contributor

Choose a reason for hiding this comment

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

May I ask why these changes are related to the creation of a chart? Couldn't this have been done in another previous patch?

Just trying to understand the dynamics :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was needed because previously apprepository-controller was hardcoded to use the kubeapps namespace which was fine as kubeapps up didn't make that configurable. The chart can be installed in any namespace though (although we could hardcode it, but bad practice), so this is needed for that to work.

@prydonius
Copy link
Contributor Author

@migmartri good points, I don't know if Helm supports directories inside templates, but another option is to just have the subcharts inside the charts/ dir separating them as you suggest. I thought about it, but figured for now it wasn't that important and probably adds more boilerplate. Simply adding directories under templates/ though might be nice to clean it up a bit more.

- update hardcoded references to `kubeapps` namespace to variable
  Kubeapps installation namespace
- remove Kubeless roles as Kubeapps n longer bundles it and so is
  unable to create the necessary Roles in the `kubeless` namespace. The
  permission error alerts in Kubeapps should be sufficient for users
  using Kubeless within Kubeapps
@prydonius prydonius changed the title [WIP] Add Helm chart for installing Kubeapps Add Helm chart for installing Kubeapps Jul 30, 2018
@prydonius
Copy link
Contributor Author

prydonius commented Jul 30, 2018

#349 (comment)

that also talks about the kubeapps namespace, which is wrong in this case.

@arapulido I will fix this in a separate PR as I need to rework the way we get the namespace in the dashboard a bit and don't want to add more to this. For now, this PR functionally works and so I think we can merge as-is.

I believe I've addressed all the other review changes.

Things to address in other PRs:

  • Removing Kubeless from menu (and pointer to incubator Helm chart for kubeless if you navigate to /functions)
  • Fixing error alerts for Kubeapps namespace and command to check health of Kubeapps components

```

#### Write access to App Repositories

In order to create and refresh App Repositories in Kubeapps, apply the
`kubeapps-repositories-write` Role in the kubeapps namespace.
`kubeapps-repositories-write` Role in the namespace KUbeapps is installed in.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/KUbeapps/Kubeapps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, thanks

@andresmgot
Copy link
Contributor

andresmgot commented Jul 31, 2018

For me I am okay to merge this PR as it is and open different ones to address the items missing to avoid more and a bigger PR.

echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.frontend.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ template "kubeapps.fullname" . }}'

Choose a reason for hiding this comment

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

Remove "of"

serviceAccountName: {{ template "kubeapps.apprepository.fullname" . }}
containers:
- name: controller
image: "{{ .Values.apprepository.image.repository }}:{{ .Values.apprepository.image.tag }}"

Choose a reason for hiding this comment

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

In other charts the image is set using a template. This could be easier down the line if we want to change the way we set the images ("registry, repository, image" or "repository,image")

httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 60

Choose a reason for hiding this comment

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

In our production-ready infrastructure assets, these kind of values go in values.yaml

Copy link
Member

Choose a reason for hiding this comment

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

right! We usually export health checks settings so users can fine tune them

@sameersbn
Copy link
Contributor

@prydonius you seem to have added the tarball charts/mongodb-4.0.4.tgz to PR.

@prydonius
Copy link
Contributor Author

@sameersbn I was thinking of vendoring it, but I'll remove it

registry: docker.io
repository: kubeapps/chart-repo
tag: latest
jobsImage:
Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment explaining that this is to perform a workaround.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we run it even if you are using the version of helm that does not require the workaround?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do run it yes, this workaround works with all versions of Helm, and I don't know if we can detect the new version easily enough to change the way we do this (also it's still not yet released).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@migmartri fixed

- delete
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
Copy link
Contributor

Choose a reason for hiding this comment

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

Add hook annotations.

chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually it might make sense to bake this configuration in the image.

@prydonius prydonius merged commit d9102c6 into vmware-tanzu:master Aug 2, 2018
@prydonius prydonius deleted the helm-chart branch August 2, 2018 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make a Helm Chart for Kubeapps
7 participants