Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/empath-nirvana/magic-happens
A kubernetes operator you should never run under any circumstances
https://github.com/empath-nirvana/magic-happens
Last synced: 3 months ago
JSON representation
A kubernetes operator you should never run under any circumstances
- Host: GitHub
- URL: https://github.com/empath-nirvana/magic-happens
- Owner: empath-nirvana
- Created: 2023-04-16T20:17:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-17T14:26:42.000Z (over 1 year ago)
- Last Synced: 2024-06-15T15:34:06.998Z (5 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 123
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-ChatGPT-repositories - magic-happens - A kubernetes operator you should never run under any circumstances (Others)
README
Readme written by chatgpt, because of course it is:
# MagicHappens Kubernetes Operator
Welcome to the MagicHappens Kubernetes Operator project! This is a proof-of-concept (PoC) operator, built using Kopf, that leverages OpenAI's GPT-powered generation capabilities to create a Kubernetes spec from a simple, human-readable description. Please note that this project is just for fun and should NOT be deployed to a real Kubernetes cluster under any circumstances.## Overview
The MagicHappens operator takes the following YAML as input:```
kind: MagicHappens
apiVersion: gptmagic.io/v1
metadata:
name: redis
spec:
description: "create a redis namespace, and inside the namespace, create a redis cluster, backed by a stateful set, along with a service"
```Upon receiving the YAML, the operator sends the description to OpenAI, which then generates a Kubernetes spec. The operator applies the returned YAML, attempting to correct any errors and maintain consistency across updates.
## Prerequisites
* A Kubernetes cluster (for testing purposes only).
* kubectl installed and configured to interact with your cluster.
* Python 3.7+ installed.
* an openai api key (you can use gpt-3.5 if you don't have access to gpt-4, but the results aren't as reliable
## Installation```
git clone https://github.com/empath-nirvana/magic-happens.git
cd magic-happens
```
Install the required Python packages:
```
pip install -r requirements.txt
```
Deploy the Custom Resource Definition (CRD) to your cluster:```
kubectl apply -f crd.yaml
```
Set up your OpenAI API key as an environment variable:
```
export OPENAI_API_KEY=your_openai_api_key
```
## Usage
Start the operator locally:```
kopf run handler.py --verbose
```
In another terminal, create a new MagicHappens custom resource:
```
kubectl apply -f test.yaml
```
This will trigger the MagicHappens operator to generate and apply the Kubernetes spec based on the description provided in the YAML.Monitor the operator logs for the generated YAML and any errors or corrections.
To clean up the resources created by the operator, delete the MagicHappens custom resource:
```
kubectl delete -f example.yaml
```
## Limitations
This PoC operator is meant for fun and experimentation only. It is not production-ready, and should not be deployed to real Kubernetes clusters. The generated specs may not always be accurate or secure, and the operator may not handle all edge cases or errors gracefully.## License
This project is licensed under the MIT License - see the LICENSE file for details.## Contributing
Feel free to open issues, submit pull requests, or provide feedback to help improve this proof-of-concept project. Remember, this is just for fun and learning!