🔨 Add _helpers.tpl and NOTES.txt to Helm chart and refactor labels (#1406)

* include kubernetes default labels

Using _helpers.tpl to define those labels

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>

* include Notes with tips after the installs

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>

* create a standard service account name

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>

* Update helm-chart/templates/NOTES.txt

Co-authored-by: M. Mert Yildiran <me@mertyildiran.com>

* Update helm-chart/templates/NOTES.txt

Co-authored-by: M. Mert Yildiran <me@mertyildiran.com>

* fixes ingress and nginx labels

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>

* fixes new label mapping from values

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>

* update makefile to to use correct default namespace and release name to generate manifests

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>

---------

Signed-off-by: Luiz Oliveira <ziuloliveira@gmail.com>
Co-authored-by: M. Mert Yildiran <me@mertyildiran.com>
This commit is contained in:
Luiz Oliveira 2023-08-10 16:39:17 -03:00 committed by GitHub
parent 461ad1921e
commit 7c8adee7a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 160 additions and 60 deletions

View File

@ -73,7 +73,7 @@ generate-helm-values: ## Generate the Helm values from config.yaml
./bin/kubeshark__ config > ./helm-chart/values.yaml ./bin/kubeshark__ config > ./helm-chart/values.yaml
generate-manifests: ## Generate the manifests from the Helm chart using default configuration generate-manifests: ## Generate the manifests from the Helm chart using default configuration
helm template ./helm-chart > ./manifests/complete.yaml helm template kubeshark -n default ./helm-chart > ./manifests/complete.yaml
logs-worker: logs-worker:
export LOGS_POD_PREFIX=kubeshark-worker- export LOGS_POD_PREFIX=kubeshark-worker-

View File

@ -2,14 +2,11 @@
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}
{{- end }} {{- end }}
name: kubeshark-service-account name: {{ include "kubeshark.serviceAccountName" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}

View File

@ -2,11 +2,8 @@
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}

View File

@ -2,11 +2,8 @@
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}
@ -19,5 +16,5 @@ roleRef:
name: kubeshark-cluster-role name: kubeshark-cluster-role
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: kubeshark-service-account name: {{ include "kubeshark.serviceAccountName" . }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}

View File

@ -2,13 +2,10 @@
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-hub app: kubeshark-hub
sidecar.istio.io/inject: "false" sidecar.istio.io/inject: "false"
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}
@ -48,7 +45,7 @@ spec:
cpu: {{ .Values.tap.resources.hub.requests.cpu }} cpu: {{ .Values.tap.resources.hub.requests.cpu }}
memory: {{ .Values.tap.resources.hub.requests.memory }} memory: {{ .Values.tap.resources.hub.requests.memory }}
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: kubeshark-service-account serviceAccountName: {{ include "kubeshark.serviceAccountName" . }}
terminationGracePeriodSeconds: 0 terminationGracePeriodSeconds: 0
tolerations: tolerations:
- effect: NoExecute - effect: NoExecute

View File

@ -2,11 +2,8 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}

View File

@ -2,13 +2,10 @@
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-front app: kubeshark-front
sidecar.istio.io/inject: "false" sidecar.istio.io/inject: "false"
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}
@ -51,7 +48,7 @@ spec:
configMap: configMap:
name: kubeshark-nginx-config name: kubeshark-nginx-config
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
serviceAccountName: kubeshark-service-account serviceAccountName: {{ include "kubeshark.serviceAccountName" . }}
terminationGracePeriodSeconds: 0 terminationGracePeriodSeconds: 0
tolerations: tolerations:
- effect: NoExecute - effect: NoExecute

View File

@ -2,11 +2,8 @@
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}

View File

@ -3,11 +3,8 @@
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}

View File

@ -2,13 +2,10 @@
apiVersion: apps/v1 apiVersion: apps/v1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-worker-daemon-set app: kubeshark-worker-daemon-set
sidecar.istio.io/inject: "false" sidecar.istio.io/inject: "false"
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}
@ -24,7 +21,6 @@ spec:
{{- end }} {{- end }}
template: template:
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-worker-daemon-set app: kubeshark-worker-daemon-set
{{- if .Values.tap.labels }} {{- if .Values.tap.labels }}
@ -88,7 +84,7 @@ spec:
{{- end }} {{- end }}
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true hostNetwork: true
serviceAccountName: kubeshark-service-account serviceAccountName: {{ include "kubeshark.serviceAccountName" . }}
terminationGracePeriodSeconds: 0 terminationGracePeriodSeconds: 0
tolerations: tolerations:
- effect: NoExecute - effect: NoExecute

View File

@ -3,11 +3,8 @@
apiVersion: networking.k8s.io/v1 apiVersion: networking.k8s.io/v1
kind: IngressClass kind: IngressClass
metadata: metadata:
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
annotations: annotations:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}

View File

@ -9,11 +9,8 @@ metadata:
{{- if .Values.tap.annotations }} {{- if .Values.tap.annotations }}
{{- toYaml .Values.tap.annotations | nindent 4 }} {{- toYaml .Values.tap.annotations | nindent 4 }}
{{- end }} {{- end }}
creationTimestamp: null
labels: labels:
{{- if .Values.tap.labels }} {{- include "kubeshark.labels" . | nindent 4 }}
{{- toYaml .Values.tap.labels | nindent 4 }}
{{- end }}
name: kubeshark-ingress name: kubeshark-ingress
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
spec: spec:

View File

@ -4,6 +4,8 @@ kind: ConfigMap
metadata: metadata:
name: kubeshark-nginx-config name: kubeshark-nginx-config
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
labels:
{{- include "kubeshark.labels" . | nindent 4 }}
data: data:
default.conf: | default.conf: |
server { server {

View File

@ -0,0 +1,27 @@
Thank you for installing {{ title .Chart.Name }}.
Your deployment has been successful. The release is named {{ .Release.Name }} and it has been deployed in the {{ .Release.Namespace }} namespace.
{{- if .Values.tap.ingress.enabled }}
{{ if not .Values.license -}}
warning:
> Ingress option enabled but license not set. The application should not work as expected.
> Get a license at https://console.kubeshark.co/
{{- else }}
You can now access the application through the following URL:
http{{ if .Values.tap.ingress.tls }}s{{ end }}://{{ .Values.tap.ingress.host }}
{{- end -}}
{{- else }}
To access the application, follow these steps:
1. Perform port forwarding with the following commands:
kubectl port-forward -n {{ .Release.Namespace }} service/kubeshark-hub 8898:80 & \
kubectl port-forward -n {{ .Release.Namespace }} service/kubeshark-front 8899:80
2. Once port forwarding is done, you can access the application by visiting the following URL in your web browser:
http://0.0.0.0:8899
{{ end }}

View File

@ -0,0 +1,68 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kubeshark.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 "kubeshark.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 chart name and version as used by the chart label.
*/}}
{{- define "kubeshark.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "kubeshark.labels" -}}
helm.sh/chart: {{ include "kubeshark.chart" . }}
{{ include "kubeshark.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Values.additionalLabels }}
{{ toYaml . }}
{{- end }}
{{- if .Values.tap.labels }}
{{ toYaml .Values.tap.labels }}
{{- end }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "kubeshark.selectorLabels" -}}
app.kubernetes.io/name: {{ include "kubeshark.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "kubeshark.serviceAccountName" -}}
{{- if and .Values.serviceAccount .Values.serviceAccount.create }}
{{- default (include "kubeshark.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- printf "%s-service-account" .Release.Name }}
{{- end }}
{{- end }}

View File

@ -3,8 +3,12 @@
apiVersion: v1 apiVersion: v1
kind: ServiceAccount kind: ServiceAccount
metadata: metadata:
creationTimestamp: null
labels: labels:
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-service-account name: kubeshark-service-account
namespace: default namespace: default
@ -15,6 +19,12 @@ kind: ConfigMap
metadata: metadata:
name: kubeshark-nginx-config name: kubeshark-nginx-config
namespace: default namespace: default
labels:
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
data: data:
default.conf: | default.conf: |
server { server {
@ -37,8 +47,12 @@ data:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
creationTimestamp: null
labels: labels:
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-cluster-role name: kubeshark-cluster-role
namespace: default namespace: default
@ -63,8 +77,12 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
creationTimestamp: null
labels: labels:
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-cluster-role-binding name: kubeshark-cluster-role-binding
namespace: default namespace: default
@ -81,8 +99,12 @@ subjects:
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
creationTimestamp: null
labels: labels:
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-hub name: kubeshark-hub
namespace: default namespace: default
@ -101,8 +123,12 @@ status:
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
creationTimestamp: null
labels: labels:
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-front name: kubeshark-front
namespace: default namespace: default
@ -121,10 +147,14 @@ status:
apiVersion: apps/v1 apiVersion: apps/v1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-worker-daemon-set app: kubeshark-worker-daemon-set
sidecar.istio.io/inject: "false" sidecar.istio.io/inject: "false"
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-worker-daemon-set name: kubeshark-worker-daemon-set
namespace: default namespace: default
@ -134,7 +164,6 @@ spec:
app: kubeshark-worker-daemon-set app: kubeshark-worker-daemon-set
template: template:
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-worker-daemon-set app: kubeshark-worker-daemon-set
name: kubeshark-worker-daemon-set name: kubeshark-worker-daemon-set
@ -201,10 +230,14 @@ spec:
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-hub app: kubeshark-hub
sidecar.istio.io/inject: "false" sidecar.istio.io/inject: "false"
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-hub name: kubeshark-hub
namespace: default namespace: default
@ -254,10 +287,14 @@ status: {}
apiVersion: v1 apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
creationTimestamp: null
labels: labels:
app: kubeshark-front app: kubeshark-front
sidecar.istio.io/inject: "false" sidecar.istio.io/inject: "false"
helm.sh/chart: kubeshark-41.7
app.kubernetes.io/name: kubeshark
app.kubernetes.io/instance: kubeshark
app.kubernetes.io/version: "41.7"
app.kubernetes.io/managed-by: Helm
annotations: annotations:
name: kubeshark-front name: kubeshark-front
namespace: default namespace: default