Skip to content

Commit

Permalink
chore: change values structure
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jan 1, 2025
1 parent 951795f commit 9d34ecc
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 112 deletions.
25 changes: 12 additions & 13 deletions charts/playbooks-ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ Flanksource Mission Control Playbooks that uses AI action

## Values

| Key | Type | Default | Description |
| ------------------------------- | ------ | ------- | ------------------------------------------------------------------------------------------ |
| diagnose.cluster | string | `""` | name of the cluster |
| diagnose.enabled | bool | `true` | create a playbook that can diagnose an unhealthy kubernetes resource in the given cluster. |
| diagnose.systemPrompt | string | `""` | Optional system prompt for the LLM. If not provided, a default prompt will be used. |
| diganoseToSlack.cluster | string | `""` | name of the cluster |
| diganoseToSlack.enabled | bool | `true` | and send the diagnosis to slack. |
| diganoseToSlack.slackConnection | string | `""` | connection string for slack |
| diganoseToSlack.systemPrompt | string | `""` | Optional system prompt for the LLM. If not provided, a default prompt will be used. |
| global.connection | string | `""` | LLM connection: one of ollama, openai or anthropic |
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| diagnose.enabled | bool | `true` | create a playbook that diagnoses cataloges |
| diagnose.notification.enabled | bool | `true` | create a playbook that diagnoses cataloges and send the diagnosis report to slack. |
| diagnose.notification.systemPrompt | string | `""` | Optional system prompt for the LLM. If not provided, a default prompt will be used. |
| diagnose.selector | list | `[{"name":"airsonic","namespace":"default"}]` | selector the configs for the playbook resource |
| diagnose.systemPrompt | string | `""` | Optional system prompt for the LLM. If not provided, a default prompt will be used. |
| global.llm_connection | string | `""` | LLM connection: one of ollama, openai or anthropic |
| slack.connection | string | `""` | connection string for slack |

## Maintainers

| Name | Email | Url |
| ----------- | ----- | --- |
| Flanksource | | |
| Name | Email | Url |
| ---- | ------ | --- |
| Flanksource | | |
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/playbook.schema.json
{{- if and .Values.diagnose.enabled }}
{{- if .Values.diagnose.enabled }}
---
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: diagnose-unhealthy-kubernetes-resource
name: diagnose-catalogs
spec:
description: Use AI to diagnose unhealthy kubernetes resources
description: Use AI to diagnose catalogs
configs:
- tagSelector: 'cluster={{.Values.diagnose.cluster}}'
healths:
- unhealthy
- warning
# TODO: Limit this selector to kubernetes types
{{- with .Values.diagnose.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
parameters:
- name: prompt
label: Prompt
default: Find out why $(.config.name) is unhealthy
default: 'Find out why $(.config.name) is unhealthy'
properties:
multiline: 'true'
actions:
- name: query
ai:
connection: '{{.Values.global.connection}}'
connection: '{{.Values.global.llm_connection}}'
systemPrompt: |-
{{- if .Values.diagnose.systemPrompt }}
{{- .Values.diagnose.systemPrompt | nindent 10 }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/flanksource/duty/main/schema/openapi/playbook.schema.json
{{- if and .Values.diganoseToSlack.enabled }}
{{- if and .Values.diagnose.enabled .Values.diagnose.notification.enabled }}
---
apiVersion: mission-control.flanksource.com/v1
kind: Playbook
metadata:
name: send-diagnostics-to-slack
spec:
description: Use AI to diganoseToSlack unhealthy kubernetes resources and send notification to slack
description: Use AI to configs and send the report to slack
configs:
- tagSelector: 'cluster={{.Values.diganoseToSlack.cluster}}'
healths:
- unhealthy
- warning
# TODO: Limit this selector to kubernetes types
{{- with .Values.diagnose.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
parameters:
- name: prompt
label: Prompt
default: Find out why $(.config.name) is unhealthy
default: 'Find out why $(.config.name) is unhealthy'
properties:
multiline: 'true'
actions:
- name: query
ai:
connection: '{{.Values.global.connection}}'
connection: '{{.Values.global.llm_connection}}'
systemPrompt: |-
{{- if .Values.diganoseToSlack.systemPrompt }}
{{- .Values.diganoseToSlack.systemPrompt | nindent 10 }}
{{- if .Values.diagnose.notification.systemPrompt }}
{{- .Values.diagnose.notification.systemPrompt | nindent 10 }}
{{- else }}
**Role:** Seasoned Kubernetes engineer and Diagnostic Expert
Expand All @@ -35,7 +33,7 @@ spec:
1. **Resource Analysis:** Examine the manifest of the unhealthy resource thoroughly.
2. **Contextual Investigation:** Consider additional related resources provided (e.g., pods, replica sets, namespaces) to gain a comprehensive understanding of the issue.
3. **One-Time Diagnosis:** Aim to diganoseToSlack the issue in a single response without requiring follow-up questions.
3. **One-Time Diagnosis:** Aim to diagnose the issue in a single response without requiring follow-up questions.
**Output:** Provide a concise diagnosis and potential solutions based on the analysis.
The output should be in json using Block Kit(https://api.slack.com/block-kit) - a UI framework for Slack apps.
Expand Down Expand Up @@ -77,7 +75,7 @@ spec:
since: 30d
- name: send notificaiton
notification:
connection: {{.Values.diganoseToSlack.slackConnection}}
connection: {{.Values.slack.connection}}
message: "$(getLastAction.result.markdown)"
title: Diagnosis report
{{- end}}
90 changes: 47 additions & 43 deletions charts/playbooks-ai/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,46 @@
"diagnose": {
"additionalProperties": false,
"properties": {
"cluster": {
"default": "",
"description": "name of the cluster",
"required": [],
"title": "cluster",
"type": "string"
},
"enabled": {
"default": true,
"description": "create a playbook that can diagnose an unhealthy kubernetes resource in the given cluster.",
"description": "create a playbook that diagnoses cataloges",
"required": [],
"title": "enabled",
"type": "boolean"
},
"notification": {
"additionalProperties": false,
"properties": {
"enabled": {
"default": true,
"description": "create a playbook that diagnoses cataloges and send the diagnosis report to slack.",
"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": [],
"title": "notification",
"type": "object"
},
"selector": {
"description": "selector the configs for the playbook resource",
"items": {
"additionalProperties": true,
"required": [],
"type": "object"
},
"required": [],
"title": "selector",
"type": "array"
},
"systemPrompt": {
"default": "",
"description": "Optional system prompt for the LLM. If not provided, a default prompt will be used.",
Expand All @@ -28,57 +54,35 @@
}
},
"required": [
"cluster"
"notification"
],
"title": "diagnose",
"type": "object"
},
"diganoseToSlack": {
"global": {
"additionalProperties": false,
"description": "yaml-language-server: $schema=values.schema.json",
"properties": {
"cluster": {
"llm_connection": {
"default": "",
"description": "name of the cluster",
"required": [],
"title": "cluster",
"type": "string"
},
"enabled": {
"default": true,
"description": "create a playbook that can diagnose an unhealthy kubernetes resource in the given cluster\nand send the diagnosis to slack.",
"required": [],
"title": "enabled",
"type": "boolean"
},
"slackConnection": {
"default": "",
"description": "connection string for slack",
"required": [],
"title": "slackConnection",
"type": "string"
},
"systemPrompt": {
"default": "",
"description": "Optional system prompt for the LLM. If not provided, a default prompt will be used.",
"description": "LLM connection: one of ollama, openai or anthropic",
"required": [],
"title": "systemPrompt",
"title": "llm_connection",
"type": "string"
}
},
"required": [
"slackConnection",
"cluster"
"llm_connection"
],
"title": "diganoseToSlack",
"title": "global",
"type": "object"
},
"global": {
"slack": {
"additionalProperties": false,
"description": "yaml-language-server: $schema=values.schema.json",
"properties": {
"connection": {
"default": "",
"description": "LLM connection: one of ollama, openai or anthropic",
"description": "connection string for slack",
"required": [],
"title": "connection",
"type": "string"
Expand All @@ -87,14 +91,14 @@
"required": [
"connection"
],
"title": "global",
"title": "slack",
"type": "object"
}
},
"required": [
"global",
"diagnose",
"diganoseToSlack"
"slack",
"diagnose"
],
"type": "object"
}
64 changes: 31 additions & 33 deletions charts/playbooks-ai/values.yaml
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
# yaml-language-server: $schema=values.schema.json
---
global:
# @schema
# type: string
# required: true
# @schema
# -- LLM connection: one of ollama, openai or anthropic
connection: ""

diagnose:
# @schema
# type: boolean
# required: false
# @schema
# -- create a playbook that can diagnose an unhealthy kubernetes resource in the given cluster.
enabled: true
llm_connection: ""

slack:
# @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: ""
# -- connection string for slack
connection: ""

diganoseToSlack:
diagnose:
# @schema
# type: boolean
# required: false
# @schema
# -- create a playbook that can diagnose an unhealthy kubernetes resource in the given cluster
# -- and send the diagnosis to slack.
# -- create a playbook that diagnoses cataloges
enabled: true

# @schema
# type: string
# required: true
# @schema
# -- connection string for slack
slackConnection: ""

# @schema
# type: string
# required: true
# @schema
# -- name of the cluster
cluster: ""
# required: false
# type: array
# items:
# type: object
# additionalProperties: true
# @schema
# -- selector the configs for the playbook resource
selector:
- name: "*"

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

notification:
# @schema
# type: boolean
# required: false
# @schema
# -- create a playbook that diagnoses cataloges and send the diagnosis report to slack.
enabled: true

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

0 comments on commit 9d34ecc

Please sign in to comment.