Skip to content

Commit

Permalink
feat: ai playbooks chart
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Dec 31, 2024
1 parent 4b91525 commit 13dfc92
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 87 deletions.
2 changes: 2 additions & 0 deletions charts/playbooks-ai/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run*.json
mission-control.properties
25 changes: 25 additions & 0 deletions charts/playbooks-ai/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

.bin/
9 changes: 9 additions & 0 deletions charts/playbooks-ai/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: mission-control-playbooks-ai
description: Flanksource Mission Control Playbooks that uses AI action
icon: https://github.com/flanksource/docs/blob/main/docs/images/flanksource-icon.png?raw=true
type: application
version: 0.0.1
appVersion: "1.0.0"
maintainers:
- name: Flanksource
30 changes: 30 additions & 0 deletions charts/playbooks-ai/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
LOCALBIN ?= $(shell pwd)/.bin

$(LOCALBIN):
mkdir -p .bin

.PHONY: values.schema.json
values.schema.json: .bin/helm-schema
.bin/helm-schema -r -f values.yaml


.PHONY: chart
chart: values.schema.json README.md


.PHONY: README.md
README.md: .bin/helm-docs
.bin/helm-docs -t README.md.tpl

.bin/helm-docs:
test -s $(LOCALBIN)/helm-docs || \
GOBIN=$(LOCALBIN) go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest

.bin/helm-schema:
test -s $(LOCALBIN)/helm-schema || \
GOBIN=$(LOCALBIN) go install github.com/dadav/helm-schema/cmd/helm-schema@latest


.PHONY: lint
lint: chart
ct lint --charts .
18 changes: 18 additions & 0 deletions charts/playbooks-ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# mission-control-playbooks-ai

Flanksource Mission Control Playbooks that uses AI action

## Values

| Key | Type | Default | Description |
| --------------------- | ------ | ------- | ----------------------------------------------------------------------------------- |
| connection | string | `""` | LLM connection: one of ollama, openai or anthropic |
| diagnose.cluster | string | `""` | name of the cluster |
| diagnose.enabled | bool | `true` | enable kubernetes diagnosing playbook |
| diagnose.systemPrompt | string | `""` | Optional system prompt for the LLM. If not provided, a default prompt will be used. |

## Maintainers

| Name | Email | Url |
| ----------- | ----- | --- |
| Flanksource | | |
17 changes: 17 additions & 0 deletions charts/playbooks-ai/README.md.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}


{{ template "chart.sourcesSection" . }}

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}

{{ template "helm-docs.versionFooter" . }}

{{ template "chart.maintainersSection" . }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/playbook.schema.json
{{- if and .Values.playbooks.enabled .Values.playbooks.ai.enabled }}
{{- if and .Values.diagnose.enabled }}
---
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
Expand All @@ -8,7 +8,7 @@ metadata:
spec:
description: Use AI to diagnose unhealthy kubernetes resources
configs:
- tagSelector: 'cluster={{.Values.playbooks.ai.diagnose.cluster}}'
- tagSelector: 'cluster={{.Values.diagnose.cluster}}'
healths:
- unhealthy
- warning
Expand All @@ -22,10 +22,10 @@ spec:
actions:
- name: query
ai:
connection: '{{.Values.playbooks.ai.connection}}'
connection: '{{.Values.connection}}'
systemPrompt: |-
{{- if .Values.playbooks.ai.diagnose.systemPrompt }}
{{- .Values.playbooks.ai.diagnose.systemPrompt | nindent 10 }}
{{- if .Values.diagnose.systemPrompt }}
{{- .Values.diagnose.systemPrompt | nindent 10 }}
{{- else }}
**Role:** Seasoned Kubernetes engineer and Diagnostic Expert
Expand Down
55 changes: 55 additions & 0 deletions charts/playbooks-ai/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"connection": {
"default": "",
"description": "yaml-language-server: $schema=values.schema.json\nLLM connection: one of ollama, openai or anthropic",
"required": [],
"title": "connection",
"type": "string"
},
"diagnose": {
"additionalProperties": false,
"properties": {
"cluster": {
"default": "",
"description": "name of the cluster",
"required": [],
"title": "cluster",
"type": "string"
},
"enabled": {
"default": true,
"description": "enable kubernetes diagnosing playbook",
"required": [],
"title": "enabled",
"type": "boolean"
},
"systemPrompt": {
"default": "",
"description": "Optional system prompt for the LLM. If not provided, a default prompt will be used.",
"required": [],
"title": "systemPrompt",
"type": "string"
}
},
"required": [
"cluster"
],
"title": "diagnose",
"type": "object"
},
"global": {
"description": "Global values are values that can be accessed from any chart or subchart by exactly the same name.",
"required": [],
"title": "global",
"type": "object"
}
},
"required": [
"connection",
"diagnose"
],
"type": "object"
}
29 changes: 29 additions & 0 deletions charts/playbooks-ai/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# yaml-language-server: $schema=values.schema.json
# @schema
# type: string
# required: true
# @schema
# -- LLM connection: one of ollama, openai or anthropic
connection: ""

diagnose:
# @schema
# type: boolean
# required: false
# @schema
# -- enable kubernetes diagnosing playbook
enabled: true

# @schema
# type: string
# required: true
# @schema
# -- name of the cluster
cluster: ""

# @schema
# type: string
# required: false
# @schema
# -- Optional system prompt for the LLM. If not provided, a default prompt will be used.
systemPrompt: ""
6 changes: 1 addition & 5 deletions charts/playbooks-kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ Flanksource Mission Control Playbooks that interact directly with the Kubernetes
| delete.types[5] | string | `"Kubernetes::CronJob"` | |
| delete.types[6] | string | `"Kubernetes::DaemonSet"` | |
| delete.types[7] | string | `"Kubernetes::ConfigMap"` | |
| playbooks.ai.connection | string | `""` | |
| playbooks.ai.diagnose.cluster | string | `""` | |
| playbooks.ai.diagnose.systemPrompt | string | `""` | |
| playbooks.ai.enabled | bool | `false` | |
| playbooks.cleanupFailedPods | bool | `true` | |
| playbooks.createDeployment | bool | `true` | |
| playbooks.delete | bool | `true` | |
| playbooks.deployHelmChart | bool | `true` | |
| playbooks.enabled | bool | `false` | |
| playbooks.enabled | bool | `true` | |
| playbooks.ignoreChanges | bool | `true` | |
| playbooks.logs | bool | `true` | |
| playbooks.podSnapshot | bool | `false` | |
Expand Down
54 changes: 2 additions & 52 deletions charts/playbooks-kubernetes/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,55 +64,6 @@
"additionalProperties": false,
"description": "yaml-language-server: $schema=values.schema.json",
"properties": {
"ai": {
"additionalProperties": false,
"properties": {
"connection": {
"default": "",
"description": "LLM connection: one of ollama, openai or anthropic",
"required": [],
"title": "connection",
"type": "string"
},
"diagnose": {
"additionalProperties": false,
"properties": {
"cluster": {
"default": "",
"description": "name of the cluster",
"required": [],
"title": "cluster",
"type": "string"
},
"systemPrompt": {
"default": "",
"description": "Optional system prompt for the LLM. If not provided, a default prompt will be used.",
"required": [],
"title": "systemPrompt",
"type": "string"
}
},
"required": [
"cluster"
],
"title": "diagnose",
"type": "object"
},
"enabled": {
"default": false,
"required": [],
"title": "enabled",
"type": "boolean"
}
},
"required": [
"enabled",
"connection",
"diagnose"
],
"title": "ai",
"type": "object"
},
"cleanupFailedPods": {
"default": true,
"required": [],
Expand All @@ -138,7 +89,7 @@
"type": "boolean"
},
"enabled": {
"default": false,
"default": true,
"description": "If this is set to false, no playbooks will be created",
"required": [],
"title": "enabled",
Expand Down Expand Up @@ -206,8 +157,7 @@
"scale",
"updateImage",
"updateResources",
"deployHelmChart",
"ai"
"deployHelmChart"
],
"title": "playbooks",
"type": "object"
Expand Down
25 changes: 0 additions & 25 deletions charts/playbooks-kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,6 @@ playbooks:
updateImage: true
updateResources: true
deployHelmChart: true
ai:
enabled: false

# @schema
# type: string
# required: true
# @schema
# LLM connection: one of ollama, openai or anthropic
connection: ""

diagnose:
# @schema
# type: string
# required: true
# @schema
# name of the cluster
cluster: ""

# @schema
# type: string
# required: false
# @schema
# Optional system prompt for the LLM. If not provided, a default prompt will be used.
systemPrompt: ""

delete:
types:
- Kubernetes::Pod
Expand Down

0 comments on commit 13dfc92

Please sign in to comment.