{"by":"empath-nirvana","descendants":32,"id":35604715,"kids":[35606176,35606190,35606114,35606750,35606151,35605883,35605948,35606084,35606233],"score":48,"text":"I built this kubernetes operator as a proof of concept this weekend..  It only has a single required item in the spec, a freeform description field.  The operator will use chatgpt to generate a spec, then immediately apply it to the cluster.  It makes some attempt to correct errors if there&#x27;s a problem with the syntax.  It will leave additional comments, questions or instructions in the status field of the object.  I built this in a weekend and it&#x27;s still quite unrefined.  It&#x27;s in no way production ready, please don&#x27;t use it for anything real, but it works better than you would think, considering how simple it is.  If you&#x27;re going to use it, run it on a local cluster like &#x27;kind&#x27;.<p>Some descriptions to try:<p>* install a redis namespace with a redis cluster and a service in it\n* create an argocd application in the argocd namespace to install velero.\n* write a python script that lists all ec2 instances in us-east-1, and run it as a k8s job with the aws credentials already saved in the default namespace..<p>a somewhat longer description that also worked:\ngiven the following spec:\n    ---\n    kind: MagicHappens\n    apiVersion: gptmagic.io&#x2F;v1\n    metadata:\n      name: foo\n    spec:\n      description: this is a freeform description field that will be sent to chatgpt to generate kubernetes resources\n      dryRun: false\n    ---\n    Can you create more magic happens resources, each of which describes an argocd application that needs to be created to install a helm chart for one of the standard cluster addons that need to be installed on a cluster for it to be production ready.  The description should be be freeform text like the following: &quot;Create an argocd application in the argocd namespace to install istio from the helm chart with all the defaults&quot; or &quot;Create an argocd application in the argocd namespace to install prometheus and grafana, with an ingress enabled for grafana&quot;. Be very thorough and included as many apps that might be needed for a prod ready cluster using industry standard CNCF projects if possible.<p>(this produces a list of additional resources for the operator, which the operator then goes on to create argocd applications for -- it also left comments with instructions on one of the resources for how configure it to work with your cloud provider<p>something to note is that since you can run arbitrary containers with arbitrary commands, and chatgpt can write arbitrary code, you don&#x27;t have to limit yourself to k8s stuff.. if you&#x27;ve got saas credentials on the cluster, you can just tell it to run a python script as a job to do whatever you want.<p>Since most people are cowards, there&#x27;s a dryRun field that defaults to true, so it only attaches the spec to the object.<p>It is <i>scary</i> how well this works.","time":1681756762,"title":"Show HN: Magic Happens – let ChatGPT manage your Kubernetes cluster","type":"story","url":"https://github.com/empath-nirvana/magic-happens"}