From 753dced55d371da90d761c48700d790cf556e0c9 Mon Sep 17 00:00:00 2001 From: Mario-F Date: Mon, 12 Jul 2021 18:46:33 +0200 Subject: [PATCH] feat(kubevis): implemented initial working version --- charts/kubevis/Chart.yaml | 5 ++- charts/kubevis/README.md | 11 +++++++ charts/kubevis/templates/_helpers.tpl | 6 ++-- charts/kubevis/templates/deployment.yaml | 13 ++------ charts/kubevis/templates/hpa.yaml | 28 ---------------- charts/kubevis/templates/rbac.yaml | 23 +++++++++++++ charts/kubevis/templates/serviceaccount.yaml | 12 ------- charts/kubevis/values.yaml | 34 +++----------------- 8 files changed, 47 insertions(+), 85 deletions(-) delete mode 100644 charts/kubevis/templates/hpa.yaml create mode 100644 charts/kubevis/templates/rbac.yaml delete mode 100644 charts/kubevis/templates/serviceaccount.yaml diff --git a/charts/kubevis/Chart.yaml b/charts/kubevis/Chart.yaml index 56e5f42..a682d44 100644 --- a/charts/kubevis/Chart.yaml +++ b/charts/kubevis/Chart.yaml @@ -1,6 +1,5 @@ apiVersion: v2 name: kubevis -description: A Helm chart for Kubernetes +description: Helm chart to kubevis https://github.com/Mario-F/kubevis type: application -version: 1.0.1 -appVersion: "v1.3.7" +version: 1.1.0 diff --git a/charts/kubevis/README.md b/charts/kubevis/README.md index 0080d6f..058306f 100644 --- a/charts/kubevis/README.md +++ b/charts/kubevis/README.md @@ -1 +1,12 @@ # KubeVis Helm Chart + +The helm chart to deploy kubevis + +## Usage + +Using the helm chart simple use the following commands: + +```shell +helm repo add mariof-charts https://mario-f.github.io/helm-charts/ +helm install kubevis mariof-charts/kubevis +``` diff --git a/charts/kubevis/templates/_helpers.tpl b/charts/kubevis/templates/_helpers.tpl index cb1c068..c93df3f 100644 --- a/charts/kubevis/templates/_helpers.tpl +++ b/charts/kubevis/templates/_helpers.tpl @@ -54,9 +54,9 @@ app.kubernetes.io/instance: {{ .Release.Name }} Create the name of the service account to use */}} {{- define "kubevis.serviceAccountName" -}} -{{- if .Values.serviceAccount.create }} -{{- default (include "kubevis.fullname" .) .Values.serviceAccount.name }} +{{- if .Values.clusterAdmin.enabled }} +{{- include "kubevis.fullname" . }} {{- else }} -{{- default "default" .Values.serviceAccount.name }} +"default" {{- end }} {{- end }} diff --git a/charts/kubevis/templates/deployment.yaml b/charts/kubevis/templates/deployment.yaml index db53cec..8ac6ba0 100644 --- a/charts/kubevis/templates/deployment.yaml +++ b/charts/kubevis/templates/deployment.yaml @@ -1,13 +1,10 @@ apiVersion: apps/v1 -kind: kubevisment +kind: Deployment metadata: name: {{ include "kubevis.fullname" . }} labels: {{- include "kubevis.labels" . | nindent 4 }} spec: - {{- if not .Values.autoscaling.enabled }} - replicas: {{ .Values.replicaCount }} - {{- end }} selector: matchLabels: {{- include "kubevis.selectorLabels" . | nindent 6 }} @@ -25,17 +22,13 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} serviceAccountName: {{ include "kubevis.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: 80 + containerPort: 3000 protocol: TCP livenessProbe: httpGet: diff --git a/charts/kubevis/templates/hpa.yaml b/charts/kubevis/templates/hpa.yaml deleted file mode 100644 index e76fad6..0000000 --- a/charts/kubevis/templates/hpa.yaml +++ /dev/null @@ -1,28 +0,0 @@ -{{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 -kind: HorizontalPodAutoscaler -metadata: - name: {{ include "kubevis.fullname" . }} - labels: - {{- include "kubevis.labels" . | nindent 4 }} -spec: - scaleTargetRef: - apiVersion: apps/v1 - kind: kubevisment - name: {{ include "kubevis.fullname" . }} - minReplicas: {{ .Values.autoscaling.minReplicas }} - maxReplicas: {{ .Values.autoscaling.maxReplicas }} - metrics: - {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} - - type: Resource - resource: - name: cpu - targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} - {{- end }} - {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} - - type: Resource - resource: - name: memory - targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} - {{- end }} -{{- end }} diff --git a/charts/kubevis/templates/rbac.yaml b/charts/kubevis/templates/rbac.yaml new file mode 100644 index 0000000..008c6bd --- /dev/null +++ b/charts/kubevis/templates/rbac.yaml @@ -0,0 +1,23 @@ +{{- if .Values.clusterAdmin.enabled -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "kubevis.fullname" . }} + labels: + {{- include "kubevis.labels" . | nindent 4 }} +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ include "kubevis.fullname" . }} + labels: + {{- include "kubevis.labels" . | nindent 4 }} +subjects: + - kind: ServiceAccount + name: {{ include "kubevis.fullname" . }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: ClusterRole + name: cluster-admin + apiGroup: rbac.authorization.k8s.io +{{- end }} diff --git a/charts/kubevis/templates/serviceaccount.yaml b/charts/kubevis/templates/serviceaccount.yaml deleted file mode 100644 index b404fce..0000000 --- a/charts/kubevis/templates/serviceaccount.yaml +++ /dev/null @@ -1,12 +0,0 @@ -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "kubevis.serviceAccountName" . }} - labels: - {{- include "kubevis.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/charts/kubevis/values.yaml b/charts/kubevis/values.yaml index 44cbb99..a74db65 100644 --- a/charts/kubevis/values.yaml +++ b/charts/kubevis/values.yaml @@ -5,37 +5,20 @@ replicaCount: 1 image: - repository: nginx + repository: ghcr.io/mario-f/kubevis pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "" + tag: v1.4.0 imagePullSecrets: [] nameOverride: "" fullnameOverride: "" -serviceAccount: - # Specifies whether a service account should be created - create: true - # Annotations to add to the service account - annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template - name: "" +clusterAdmin: + # This will create and mount a serviceaccount with cluster-admin privileges + enabled: true podAnnotations: {} -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - service: type: ClusterIP port: 80 @@ -65,13 +48,6 @@ resources: {} # cpu: 100m # memory: 128Mi -autoscaling: - enabled: false - minReplicas: 1 - maxReplicas: 100 - targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - nodeSelector: {} tolerations: []