Skip to content

Commit

Permalink
add dashbaord (#9)
Browse files Browse the repository at this point in the history
* add dashbaord to helmchart
  • Loading branch information
dergeberl authored Dec 17, 2021
1 parent 2c94f1b commit aa69bab
Show file tree
Hide file tree
Showing 15 changed files with 260 additions and 8 deletions.
4 changes: 2 additions & 2 deletions charts/kubeteach-core/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ maintainers:
- name: dergeberl
url: https://github.com/dergeberl
type: application
version: 0.1.2
appVersion: "v0.1.5-alpha"
version: 0.1.3
appVersion: "v0.2.0-alpha"
13 changes: 13 additions & 0 deletions charts/kubeteach-core/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Thank you for installing {{ .Chart.Name }}. You can list your Task with:

kubectl get tasks -n {{ .Release.Namespace }}
{{ if .Values.dashboard.enabled }}
The Dashboard is enabled. DO NOT MAKE IT AVAILABLE VIA INTERNET!
You can use it with the following command (to forward a local port):

kubectl port-forward -n kt-dev service/kubeteach-core-dashboard 8080:80

Now you can access the dashboard via http://localhost:8080
Username: {{ .Values.dashboard.credentials.username }}
Password: {{ include "kubeteach.dashboardBasicAuthPassword" . }}
{{- end}}
29 changes: 29 additions & 0 deletions charts/kubeteach-core/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,35 @@ app.kubernetes.io/name: {{ include "kubeteach.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "kubeteach.selectorLabelsWebterminal" -}}
app.kubernetes.io/name: {{ include "kubeteach.name" . }}-webterminal
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "kubeteach.webterminalServiceAccountName" -}}
{{- default (printf "%s-webterminal" (include "kubeteach.name" .)) .Values.webterminal.serviceAccount.name }}
{{- end }}


{{- define "kubeteach.serviceAccountName" -}}
{{- default (include "kubeteach.name" .) .Values.serviceAccount.name }}
{{- end }}


{{- define "kubeteach.dashboardBasicAuthPassword" -}}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "kubeteach.name" .) ) -}}
{{- if and $secret.data (not .Values.dashboard.credentials.password) -}}
{{- index $secret "data" "password" | b64dec -}}
{{- else -}}
"{{ .Values.dashboard.credentials.password | default (randAlphaNum 40 )}}"
{{- end -}}
{{- end -}}

{{- define "kubeteach.webterminalCredentials" -}}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (printf "%s-webterminal" (include "kubeteach.name" .)) ) -}}
{{- if and $secret.data (not .Values.webterminal.credentials.password) -}}
{{- index $secret "data" "credentials" | b64dec -}}
{{- else -}}
"{{ (.Values.webterminal.credentials.username | default "terminal" )}}:{{ .Values.webterminal.credentials.password | default (randAlphaNum 40 )}}"
{{- end -}}
{{- end -}}
11 changes: 11 additions & 0 deletions charts/kubeteach-core/templates/dashboard-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.dashboard.credentials -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "kubeteach.name" . }}
labels:
{{- include "kubeteach.labels" . | nindent 4 }}
stringData:
user: "{{ .Values.dashboard.credentials.username | default "kubeteach" }}"
password: {{ include "kubeteach.dashboardBasicAuthPassword" . }}
{{- end}}
17 changes: 17 additions & 0 deletions charts/kubeteach-core/templates/dashboard-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.dashboard.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "kubeteach.name" . }}-dashboard
labels:
{{- include "kubeteach.labels" . | nindent 4 }}
spec:
ports:
- name: dashboard
port: {{ .Values.dashboard.service.port }}
protocol: TCP
targetPort: dashboard
selector:
{{- include "kubeteach.selectorLabels" . | nindent 4 }}
type: {{ .Values.dashboard.service.type }}
{{- end}}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,37 @@ spec:
- name: {{ .Chart.Name }}
args:
- --leader-elect
{{- if .Values.dashboard.enabled }}
- -dashboard
{{- end }}
{{- if .Values.webterminal.enabled }}
- -dashboard-webterminal
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
image: "{{ .Values.images.kubeteach.repository }}:{{ .Values.images.kubeteach.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.images.kubeteach.pullPolicy }}
env:
- name: WEBTERMINAL_CREDENTIALS
valueFrom:
secretKeyRef:
key: credentials
name: {{ include "kubeteach.name" . }}-webterminal
- name: DASHBOARD_BASIC_AUTH_USER
valueFrom:
secretKeyRef:
key: user
name: {{ include "kubeteach.name" . }}
- name: DASHBOARD_BASIC_AUTH_PASSWORD
valueFrom:
secretKeyRef:
key: password
name: {{ include "kubeteach.name" . }}
ports:
{{- if .Values.dashboard.enabled }}
- containerPort: 8090
name: dashboard
{{- end }}
- containerPort: 8080
name: metrics
livenessProbe:
Expand Down
File renamed without changes.
62 changes: 62 additions & 0 deletions charts/kubeteach-core/templates/webterminal-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{- if .Values.webterminal.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "kubeteach.name" . }}-webterminal
labels:
{{- include "kubeteach.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "kubeteach.selectorLabelsWebterminal" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "kubeteach.selectorLabelsWebterminal" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "kubeteach.webterminalServiceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-webterminal
env:
- name: GOTTY_PATH
value: "/shell/"
- name: GOTTY_WS_ORIGIN
value: ".*"
- name: GOTTY_CREDENTIAL
valueFrom:
secretKeyRef:
key: credentials
name: {{ include "kubeteach.name" . }}-webterminal
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.images.kubeteachWebterminal.repository }}:{{ .Values.images.kubeteachWebterminal.tag | default "latest" }}"
imagePullPolicy: {{ .Values.images.kubeteachWebterminal.pullPolicy }}
ports:
- containerPort: 8080
name: webterminal
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
31 changes: 31 additions & 0 deletions charts/kubeteach-core/templates/webterminal-roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.webterminal.serviceAccount.clusterAdmin -}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "kubeteach.name" . }}-webterminal
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- '*'
- nonResourceURLs:
- '*'
verbs:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "kubeteach.name" . }}-webterminal
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "kubeteach.name" . }}-webterminal
subjects:
- kind: ServiceAccount
name: {{ include "kubeteach.webterminalServiceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end}}
10 changes: 10 additions & 0 deletions charts/kubeteach-core/templates/webterminal-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.webterminal.credentials -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "kubeteach.name" . }}-webterminal
labels:
{{- include "kubeteach.labels" . | nindent 4 }}
stringData:
credentials: {{ include "kubeteach.webterminalCredentials" . }}
{{- end}}
17 changes: 17 additions & 0 deletions charts/kubeteach-core/templates/webterminal-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.webterminal.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "kubeteach.name" . }}-dashboard-webterminal
labels:
{{- include "kubeteach.labels" . | nindent 4 }}
spec:
ports:
- name: webterminal
port: {{ .Values.webterminal.service.port }}
protocol: TCP
targetPort: webterminal
selector:
{{- include "kubeteach.selectorLabelsWebterminal" . | nindent 4 }}
type: {{ .Values.webterminal.service.type }}
{{- end}}
10 changes: 10 additions & 0 deletions charts/kubeteach-core/templates/webterminal-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "kubeteach.webterminalServiceAccountName" . }}
labels:
{{- include "kubeteach.labels" . | nindent 4 }}
{{- with .Values.webterminal.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
34 changes: 30 additions & 4 deletions charts/kubeteach-core/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
replicaCount: 1

image:
repository: ghcr.io/dergeberl/kubeteach
pullPolicy: Always
# tag: ""
images:
kubeteach:
repository: ghcr.io/dergeberl/kubeteach
pullPolicy: Always
# tag: "latest"
kubeteachWebterminal:
repository: ghcr.io/dergeberl/kubeteach-webterminal
pullPolicy: Always
# tag: "latest"

dashboard:
enabled: false
service:
type: ClusterIP
port: 80
credentials:
username: "kubeteach"
# password: "password" # if not set a random string will be created if secret does not exists

webterminal:
enabled: false
service:
type: ClusterIP
port: 8080
credentials:
username: "terminal"
# password: "password" # if not set a random string will be created if secret does not exists
serviceAccount:
annotations: {}
clusterAdmin: true

service:
enabled: false
Expand Down

0 comments on commit aa69bab

Please sign in to comment.