KubeGPT
// Operator sending alerts to Slack based on events in Kubernetes and receiving GPT responses to errors.
Proceess
- Get Event from the Kubernetes API server.
- Receive a list of Events as a response from the API server.
- Alert Error Events to Slack and store them in Cache.
- Extract fields from the Event and query the GPT API.
- Receive a response from the GPT.
- Post the GPT response to Slack and store it in the cache.
- For duplicate events, transmit from the cache to Slack at the predefined intervals.
Getting Started
Prerequisites
- go version v1.20.0+
- docker version 17.03+.
- kubectl version v1.11.3+.
- Access to a Kubernetes v1.11.3+ cluster.
Slack app setting
To receive messages via Slack, you need to configure the Slack app.
-
https://api.slack.com/apps 에서 create new app을 선택합니다.
-
Select From an app manifest.
-
Select the workspace you want to register for.
-
Copy and paste the JSON below into your Slack app's manifest, replacing ${} with whatever you want.
{
"display_information": {
"name": "${APP_NAME}",
"description": "${APP_DESCRIPTION}",
"background_color": "${APP_BACKGROUND_COLOR}",
},
"features": {
"bot_user": {
"display_name": "${BOT_DISPLAY_NAME}",
"always_online": false
}
},
"oauth_config": {
"scopes": {
"bot": [
"chat:write",
"incoming-webhook"
]
}
},
"settings": {
"org_deploy_enabled": false,
"socket_mode_enabled": false,
"token_rotation_enabled": false
}
}
- Select the Slack channel you want to add the APP to with Install to Workspace.
- Under Incoming Webhooks, copy the webhook URL.
export SLACK_WEBHOOK_URL=<Webhook URL>
NOTE: Slack URLs shouldn't be shared externally.
GPT setting
Issue an API key to use the GPT API. Obtain your API key from https://platform.openai.com/api-keys. Copy the key and run the code below.
export OPENAI_API_KEY=<API Key>
NOTE: API keys shouldn't be shared externally.
Helm Install
Install Helm Chart
helm repo add kubegpt https://kuberixenterprise.github.io/kubegpt/kubeGPT
helm repo update
helm install kubegpt kubegpt/kubegpt -n kubegpt \
--set slack.webhook=${SLACK_WEBHOOK_URL} --set ai.token=${OPENAI_API_KEY} \
--create-namespace