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
Merged
Show file tree
Hide file tree
Changes from 9 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
21 changes: 21 additions & 0 deletions chart/kubeapps/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
5 changes: 5 additions & 0 deletions chart/kubeapps/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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!

appVersion: 1.0.0.alpha.3
description: Super-charge your Kubernetes cluster with a web UI for Helm Charts, Kubeless functions and the Kubernetes Service Catalog
name: kubeapps
version: 0.1.0
Binary file added chart/kubeapps/charts/mongodb-3.0.4.tgz
Binary file not shown.
6 changes: 6 additions & 0 deletions chart/kubeapps/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: mongodb
repository: https://kubernetes-charts.storage.googleapis.com
version: 3.0.4
digest: sha256:415440e73af7d4b02a10a15f28bb2fc095cbdffdc2e1676d76e0f0eaa1632d50
generated: 2018-07-12T15:46:23.997128539-07:00
4 changes: 4 additions & 0 deletions chart/kubeapps/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
- name: mongodb
version: ">= 0"
repository: https://kubernetes-charts.storage.googleapis.com
19 changes: 19 additions & 0 deletions chart/kubeapps/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
echo http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" .Values.frontend.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "kubeapps.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
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"

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.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?

{{- end }}
90 changes: 90 additions & 0 deletions chart/kubeapps/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "kubeapps.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "kubeapps.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified app name for MongoDB dependency.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "kubeapps.mongodb.fullname" -}}
{{- $name := default "mongodb" .Values.mongodb.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "kubeapps.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create name for the apprepository-controller based on the fullname
*/}}
{{- define "kubeapps.apprepository.fullname" -}}
{{ template "kubeapps.fullname" . }}-apprepository-controller
{{- end -}}

{{/*
Create name for the apprepository bootstrap job
*/}}
{{- define "kubeapps.apprepository-jobs-bootstrap.fullname" -}}
{{ template "kubeapps.fullname" . }}-apprepository-jobs-bootstrap
{{- end -}}

{{/*
Create name for the chartsvc based on the fullname
*/}}
{{- define "kubeapps.chartsvc.fullname" -}}
{{ template "kubeapps.fullname" . }}-chartsvc
{{- end -}}

{{/*
Create name for the dashboard based on the fullname
*/}}
{{- define "kubeapps.dashboard.fullname" -}}
{{ template "kubeapps.fullname" . }}-dashboard
{{- end -}}

{{/*
Create name for the dashboard config based on the fullname
*/}}
{{- define "kubeapps.dashboard-config.fullname" -}}
{{ template "kubeapps.fullname" . }}-dashboard-config
{{- end -}}

{{/*
Create name for the frontend config based on the fullname
*/}}
{{- define "kubeapps.frontend-config.fullname" -}}
{{ template "kubeapps.fullname" . }}-frontend-config
{{- end -}}

{{/*
Create name for the tiller-proxy based on the fullname
*/}}
{{- define "kubeapps.tiller-proxy.fullname" -}}
{{ template "kubeapps.fullname" . }}-tiller-proxy
{{- end -}}
17 changes: 17 additions & 0 deletions chart/kubeapps/templates/apprepository-crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: apprepositories.kubeapps.com
labels:
app: {{ template "kubeapps.apprepository.fullname" . }}
chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
group: kubeapps.com
names:
kind: AppRepository
plural: apprepositories
shortNames:
- apprepos
version: v1alpha1
47 changes: 47 additions & 0 deletions chart/kubeapps/templates/apprepository-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
apiVersion: apps/v1beta2
kind: Deployment
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

chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: 1
selector:
matchLabels:
app: {{ template "kubeapps.apprepository.fullname" . }}
release: {{ .Release.Name }}
template:
metadata:
labels:
app: {{ template "kubeapps.apprepository.fullname" . }}
release: {{ .Release.Name }}
spec:
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

command:
- /apprepository-controller
args:
- --logtostderr
- --repo-sync-image={{ .Values.apprepository.syncImage.repository }}:{{ .Values.apprepository.syncImage.tag }}
- --namespace={{ .Release.Namespace }}
- --mongo-url={{ template "kubeapps.mongodb.fullname" . }}
- --mongo-secret-name={{ template "kubeapps.mongodb.fullname" . }}
resources:
{{ toYaml .Values.apprepository.resources | indent 12 }}
{{- with .Values.apprepository.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.apprepository.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.apprepository.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
30 changes: 30 additions & 0 deletions chart/kubeapps/templates/apprepository-jobs-bootstrap-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
annotations:
helm.sh/hook: post-install
helm.sh/hook-delete-policy: hook-succeeded
helm.sh/hook-weight: "-10"
labels:
app: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
apprepositories.yaml: |-
{{- range .Values.apprepository.repos }}
apiVersion: kubeapps.com/v1alpha1
kind: AppRepository
metadata:
name: {{ .name }}
labels:
app: {{ template "kubeapps.apprepository.fullname" $ }}
chart: {{ template "kubeapps.chart" $ }}
release: {{ $.Release.Name }}
heritage: {{ $.Release.Service }}
spec:
type: helm
url: {{ .url }}
---
{{ end -}}
40 changes: 40 additions & 0 deletions chart/kubeapps/templates/apprepository-jobs-bootstrap-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
annotations:
helm.sh/hook: post-install
helm.sh/hook-delete-policy: hook-succeeded
helm.sh/hook-weight: "-10"
labels:
app: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
rules:
- apiGroups:
- kubeapps.com
resources:
- apprepositories
verbs:
- get
- create
- 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.

metadata:
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
labels:
app: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
namespace: {{ .Release.Namespace }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
annotations:
helm.sh/hook: post-install
helm.sh/hook-delete-policy: hook-succeeded
helm.sh/hook-weight: "-10"
labels:
app: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
50 changes: 50 additions & 0 deletions chart/kubeapps/templates/apprepository-jobs-bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
annotations:
helm.sh/hook: post-install
helm.sh/hook-delete-policy: hook-succeeded
labels:
app: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
chart: {{ template "kubeapps.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
template:
metadata:
labels:
app: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: kubectl
image: "{{ .Values.apprepository.jobsImage.repository }}:{{ .Values.apprepository.jobsImage.tag }}"
command:
- kubectl
- apply
- -f
- /tmp/apprepositories/apprepositories.yaml
volumeMounts:
- mountPath: /tmp/apprepositories
name: apprepositories-config
resources:
{{ toYaml .Values.apprepository.resources | indent 12 }}
volumes:
- name: apprepositories-config
configMap:
name: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
restartPolicy: OnFailure
serviceAccountName: {{ template "kubeapps.apprepository-jobs-bootstrap.fullname" . }}
{{- with .Values.apprepository.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.apprepository.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.apprepository.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
Loading