mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-27 16:04:17 +00:00
feat: add helm chart (#318)
* feat: add helm chart Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * Address PR feedback (#1) * remove K8SGPT_BASEURL * add default model * add user-specified Deployment annotations * remove Values.secret.enabled --------- Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * update chart.appVersion, default labels Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * default image tag to Chart.appVersion Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * release-please annotation for k8sgpt image Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * revert improperly relocated Dockerfile Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * revert changes to docker-build target and actually re-locate Dockerfile Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * Update charts/k8sgpt/Chart.yaml Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com> Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> * Update charts/k8sgpt/templates/deployment.yaml Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com> Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> --------- Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com> Co-authored-by: Thomas Schuetz <38893055+thschue@users.noreply.github.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
k8sgpt*
|
k8sgpt*
|
||||||
|
!charts/k8sgpt
|
||||||
*.vscode
|
*.vscode
|
||||||
dist/
|
dist/
|
||||||
|
|
||||||
|
40
Makefile
40
Makefile
@@ -10,6 +10,8 @@ ROOT_PACKAGE=github.com/k8sgpt-ai/k8sgpt
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
DIRS=$(shell ls)
|
DIRS=$(shell ls)
|
||||||
GO=go
|
GO=go
|
||||||
|
GOOS ?= $(shell go env GOOS)
|
||||||
|
GOARCH ?= $(shell go env GOARCH)
|
||||||
|
|
||||||
.DEFAULT_GOAL := help
|
.DEFAULT_GOAL := help
|
||||||
|
|
||||||
@@ -61,17 +63,21 @@ tidy:
|
|||||||
|
|
||||||
## deploy: Deploy k8sgpt
|
## deploy: Deploy k8sgpt
|
||||||
.PHONY: deploy
|
.PHONY: deploy
|
||||||
deploy:
|
deploy: helm
|
||||||
@echo "===========> Deploying k8sgpt"
|
@echo "===========> Deploying k8sgpt"
|
||||||
@$(call funcsecret)
|
$(HELM) install k8sgpt charts/k8sgpt -n k8sgpt --create-namespace
|
||||||
|
|
||||||
|
## update: Update k8sgpt
|
||||||
|
.PHONY: update
|
||||||
|
update: helm
|
||||||
|
@echo "===========> Updating k8sgpt"
|
||||||
|
$(HELM) upgrade k8sgpt charts/k8sgpt -n k8sgpt
|
||||||
|
|
||||||
## undeploy: Undeploy k8sgpt
|
## undeploy: Undeploy k8sgpt
|
||||||
.PHONY: undeploy
|
.PHONY: undeploy
|
||||||
undeploy:
|
undeploy: helm
|
||||||
@echo "===========> Undeploying k8sgpt"
|
@echo "===========> Undeploying k8sgpt"
|
||||||
kubectl delete secret ai-backend-secret --namespace=k8sgpt
|
$(HELM) uninstall k8sgpt -n k8sgpt
|
||||||
kubectl delete -f container/manifests
|
|
||||||
kubectl delete ns k8sgpt
|
|
||||||
|
|
||||||
## docker-build: Build docker image
|
## docker-build: Build docker image
|
||||||
.PHONY: docker-build
|
.PHONY: docker-build
|
||||||
@@ -79,7 +85,6 @@ docker-build:
|
|||||||
@echo "===========> Building docker image"
|
@echo "===========> Building docker image"
|
||||||
docker buildx build --build-arg=VERSION="$$(git describe --tags --abbrev=0)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" --platform="linux/amd64,linux/arm64" -t ${IMG} -f container/Dockerfile . --push
|
docker buildx build --build-arg=VERSION="$$(git describe --tags --abbrev=0)" --build-arg=COMMIT="$$(git rev-parse --short HEAD)" --build-arg DATE="$$(date +%FT%TZ)" --platform="linux/amd64,linux/arm64" -t ${IMG} -f container/Dockerfile . --push
|
||||||
|
|
||||||
|
|
||||||
## fmt: Run go fmt against code.
|
## fmt: Run go fmt against code.
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt:
|
fmt:
|
||||||
@@ -137,11 +142,16 @@ copyright.add: tools.verify.addlicense
|
|||||||
# @addlicense -y $(shell date +"%Y") -v -c "K8sgpt AI." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
# @addlicense -y $(shell date +"%Y") -v -c "K8sgpt AI." -f $(LICENSE_TEMPLATE) $(CODE_DIRS)
|
||||||
@echo "===========> End the copyright is added..."
|
@echo "===========> End the copyright is added..."
|
||||||
|
|
||||||
define funcsecret
|
# =====
|
||||||
ifndef SECRET
|
# Tools
|
||||||
$(error SECRET environment variable is not set)
|
|
||||||
endif
|
HELM_VERSION ?= v3.11.3
|
||||||
kubectl create ns k8sgpt || true
|
|
||||||
kubectl create secret generic ai-backend-secret --from-literal=secret-key=$(SECRET) --namespace=k8sgpt || true
|
helm:
|
||||||
kubectl apply -f container/manifests
|
if ! test -f $(OUTPUT_DIR)/helm-$(GOOS)-$(GOARCH); then \
|
||||||
endef
|
curl -L https://get.helm.sh/helm-$(HELM_VERSION)-$(GOOS)-$(GOARCH).tar.gz | tar xz; \
|
||||||
|
mv $(GOOS)-$(GOARCH)/helm $(OUTPUT_DIR)/helm-$(GOOS)-$(GOARCH); \
|
||||||
|
chmod +x $(OUTPUT_DIR)/helm-$(GOOS)-$(GOARCH); \
|
||||||
|
rm -rf ./$(GOOS)-$(GOARCH)/; \
|
||||||
|
fi
|
||||||
|
HELM=$(OUTPUT_DIR)/helm-$(GOOS)-$(GOARCH)
|
6
charts/k8sgpt/Chart.yaml
Normal file
6
charts/k8sgpt/Chart.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
appVersion: v0.2.4 #x-release-please-version
|
||||||
|
description: A Helm chart for K8SGPT
|
||||||
|
name: k8sgpt
|
||||||
|
type: application
|
||||||
|
version: 1.0.0
|
44
charts/k8sgpt/templates/_helpers.tpl
Normal file
44
charts/k8sgpt/templates/_helpers.tpl
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{- define "k8sgpt.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 "k8sgpt.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 "k8sgpt.chart" -}}
|
||||||
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Common labels
|
||||||
|
*/}}
|
||||||
|
{{- define "k8sgpt.labels" -}}
|
||||||
|
helm.sh/chart: {{ include "k8sgpt.chart" . }}
|
||||||
|
app.kubernetes.io/name: {{ include "k8sgpt.name" . }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||||
|
{{- if .Chart.AppVersion }}
|
||||||
|
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
47
charts/k8sgpt/templates/deployment.yaml
Normal file
47
charts/k8sgpt/templates/deployment.yaml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
{{- if .Values.deployment.annotations }}
|
||||||
|
annotations:
|
||||||
|
{{- toYaml .Values.deployment.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
labels:
|
||||||
|
{{- include "k8sgpt.labels" . | nindent 4 }}
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: {{ include "k8sgpt.name" . }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: {{ include "k8sgpt.name" . }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
serviceAccountName: k8sgpt
|
||||||
|
containers:
|
||||||
|
- name: k8sgpt-container
|
||||||
|
imagePullPolicy: {{ .Values.deployment.imagePullPolicy }}
|
||||||
|
image: {{ .Values.deployment.image.repository }}:{{ .Values.deployment.image.tag | default .Chart.AppVersion }}
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
args: ["serve"]
|
||||||
|
{{- if .Values.deployment.resources }}
|
||||||
|
resources:
|
||||||
|
{{- toYaml .Values.deployment.resources | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: K8SGPT_MODEL
|
||||||
|
value: {{ .Values.deployment.env.model }}
|
||||||
|
- name: K8SGPT_BACKEND
|
||||||
|
value: {{ .Values.deployment.env.backend }}
|
||||||
|
{{- if .Values.secret.secretKey }}
|
||||||
|
- name: K8SGPT_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: ai-backend-secret
|
||||||
|
key: secret-key
|
||||||
|
{{- end }}
|
@@ -1,7 +1,10 @@
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
kind: ClusterRole
|
kind: ClusterRole
|
||||||
metadata:
|
metadata:
|
||||||
name: k8sgpt-cluster-role-all
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
labels:
|
||||||
|
{{- include "k8sgpt.labels" . | nindent 4 }}
|
||||||
rules:
|
rules:
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- '*'
|
- '*'
|
15
charts/k8sgpt/templates/rolebinding.yaml
Normal file
15
charts/k8sgpt/templates/rolebinding.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: ClusterRoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
labels:
|
||||||
|
{{- include "k8sgpt.labels" . | nindent 4 }}
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
roleRef:
|
||||||
|
kind: ClusterRole
|
||||||
|
name: k8sgpt-cluster-role-all
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
7
charts/k8sgpt/templates/sa.yaml
Normal file
7
charts/k8sgpt/templates/sa.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
labels:
|
||||||
|
{{- include "k8sgpt.labels" . | nindent 4 }}
|
10
charts/k8sgpt/templates/secret.yaml
Normal file
10
charts/k8sgpt/templates/secret.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{{- if .Values.secret.secretKey }}
|
||||||
|
apiVersion: v1
|
||||||
|
data:
|
||||||
|
secret-key: {{ .Values.secret.secretKey }}
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: ai-backend-secret
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
type: Opaque
|
||||||
|
{{- end}}
|
19
charts/k8sgpt/templates/service.yaml
Normal file
19
charts/k8sgpt/templates/service.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
labels:
|
||||||
|
{{- include "k8sgpt.labels" . | nindent 4 }}
|
||||||
|
{{- if .Values.service.annotations }}
|
||||||
|
annotations:
|
||||||
|
{{- toYaml .Values.service.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
app.kubernetes.io/name: {{ include "k8sgpt.name" . }}
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8080
|
||||||
|
targetPort: 8080
|
||||||
|
type: {{ .Values.service.type }}
|
18
charts/k8sgpt/templates/serviceMonitor.yaml
Normal file
18
charts/k8sgpt/templates/serviceMonitor.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{{- if .Values.serviceMonitor.enabled }}
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: ServiceMonitor
|
||||||
|
metadata:
|
||||||
|
name: {{ template "k8sgpt.fullname" . }}
|
||||||
|
namespace: {{ .Release.Namespace | quote }}
|
||||||
|
labels:
|
||||||
|
{{- include "k8sgpt.labels" . | nindent 4 }}
|
||||||
|
spec:
|
||||||
|
endpoints:
|
||||||
|
- honorLabels: true
|
||||||
|
path: /metrics
|
||||||
|
port: http
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app.kubernetes.io/name: {{ include "k8sgpt.name" . }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
{{- end }}
|
26
charts/k8sgpt/values.yaml
Normal file
26
charts/k8sgpt/values.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
deployment:
|
||||||
|
image:
|
||||||
|
repository: ghcr.io/k8sgpt-ai/k8sgpt
|
||||||
|
tag: "" # defaults to Chart.appVersion if unspecified
|
||||||
|
imagePullPolicy: Always
|
||||||
|
annotations: {}
|
||||||
|
env:
|
||||||
|
model: "gpt-3.5-turbo"
|
||||||
|
backend: "openai" # one of: [ openai | llama ]
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "1"
|
||||||
|
memory: "512Mi"
|
||||||
|
requests:
|
||||||
|
cpu: "0.2"
|
||||||
|
memory: "156Mi"
|
||||||
|
|
||||||
|
secret:
|
||||||
|
secretKey: "" # base64 encoded OpenAI token
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: ClusterIP
|
||||||
|
annotations: {}
|
||||||
|
|
||||||
|
serviceMonitor:
|
||||||
|
enabled: false
|
@@ -1,42 +0,0 @@
|
|||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: k8sgpt-deployment
|
|
||||||
namespace: k8sgpt
|
|
||||||
labels:
|
|
||||||
app: k8sgpt
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: k8sgpt
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: k8sgpt
|
|
||||||
spec:
|
|
||||||
serviceAccountName: k8sgpt
|
|
||||||
containers:
|
|
||||||
- name: k8sgpt-container
|
|
||||||
imagePullPolicy: Always
|
|
||||||
image: ghcr.io/k8sgpt-ai/k8sgpt:v0.2.8 #x-release-please-version
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
args: ["serve"]
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: "1"
|
|
||||||
memory: "512Mi"
|
|
||||||
requests:
|
|
||||||
cpu: "0.2"
|
|
||||||
memory: "156Mi"
|
|
||||||
env:
|
|
||||||
- name: K8SGPT_MODEL
|
|
||||||
value: "gpt-3.5-turbo"
|
|
||||||
- name: K8SGPT_BACKEND
|
|
||||||
value: "openai"
|
|
||||||
- name: K8SGPT_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: ai-backend-secret
|
|
||||||
key: secret-key
|
|
@@ -1,13 +0,0 @@
|
|||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: k8sgpt-rolebinding
|
|
||||||
namespace: k8sgpt
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: k8sgpt
|
|
||||||
namespace: k8sgpt
|
|
||||||
roleRef:
|
|
||||||
kind: ClusterRole
|
|
||||||
name: k8sgpt-cluster-role-all
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
@@ -1,5 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: k8sgpt
|
|
||||||
namespace: k8sgpt
|
|
@@ -1,15 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: k8sgpt-service
|
|
||||||
namespace: k8sgpt
|
|
||||||
labels:
|
|
||||||
app: k8sgpt
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: k8sgpt
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8080
|
|
||||||
targetPort: 8080
|
|
||||||
type: ClusterIP
|
|
@@ -1,15 +0,0 @@
|
|||||||
apiVersion: monitoring.coreos.com/v1
|
|
||||||
kind: ServiceMonitor
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: k8sgpt
|
|
||||||
name: k8sgpt-service-monitor
|
|
||||||
namespace: k8sgpt
|
|
||||||
spec:
|
|
||||||
endpoints:
|
|
||||||
- honorLabels: true
|
|
||||||
path: /metrics
|
|
||||||
port: http
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: k8sgpt
|
|
Reference in New Issue
Block a user