How I’ve Used ChatGPT To Create A Whole GitOps Demo Using 3 Simple Questions

Shon Paz
6 min readDec 10, 2022

--

Introduction

A few days ago I got exposed to OpenAI’s new AI-based chatbot (ChatGPT), which can interact with end users in a conversational way.

TL;DR — you can ask various questions, and the bot creates detailed and creative answers.

This is one of the most impressive things I’ve seen lately, and it made me think that I might be able to use it in order to save some time and be more efficient in my day-to-day work.

As a Solution Architect, I find myself dealing quite a lot with building new demos and trying to simulate things — Most of the time things get a bit messy and I end up spending time fixing syntax errors and searching for solutions online.

I’ve decided to give ChatGPT a shot and try to build a demo that contains an entire CI/CD workflow for a given Flask application that comes to my mind. This application will be deployed in a GitOps way to my existing Openshift cluster.

I had s single rule — ChatGPT does it all, I’m the one who instructs it with guiding questions.

To my surprise, it was worth it. Stay with me and I’ll share my findings.

Generate Code → Build it → Push it to DockerHub

Hi!

I need your help with writing a mock Flask application.

My application will have one route “/homepage“ and a message will be printed to screen that says “Welcome To Our Demo!”.
The “/homepage” web page should have a picture of a dog printed below the “Welcome To Our Demo!” Message.

Dog’s picture can be taken from — https://cdn.pixabay.com/photo/2018/03/31/06/31/dog-3277416_960_720.jpg

Make sure that my Flask application binds all host interfaces (for example, 0.0.0.0).

Flask app must be containerized, built and pushed to DockerHub using my own username, which is “shonpaz123”.
My container image should be light and simple as possible.

Can you help me build the needed files?

Thanks!

In order for you to see how ChatGPT answered my question, I’ve recorded its answer for you:

After filling up all ChatGPT’s instructions, I had a running container running on my laptop. that exposed my application exactly as I wanted it to be.

$ docker run -d -p 5000:5000 shonpaz123/flask-app

The bot exposed my application exactly as I expected:

Generate Kubernetes Manifests → Push To A GitHub Repo

Very helpful, thanks.
Now, I need this to be deployed to my Kubernetes cluster.

Please generate the needed YAML files, that will have a highly-available deployment of my Flask application.

The deployment should pull the “flask-app” image that was pushed to DockerHub using my DockerHub username.

On top, please generate YAML files for an internal ClusterIP service and an Openshift Route that will expose my application to the outside world (you can leave the “hostname” field empty). Make sure the route points to the “/homepage” path.

Additionally, please help me understand how I can push those YAML files to my GitHub repo (my GitHub username is “shpaz”).

Thanks!

I’ve planted a few clues to my instructions:

  • I expected ChatGPT to understand that I’m looking to have more than a single replica of my deployment by asking it to be highly-available
  • I expected it to remember what was my DockerHub username, which was provided earlier
  • I used natural English, to explain quite a technical syntax stuff

In order for you to see how ChatGPT answered my question, I’ve recorded its answer for you:

To my surprise, it was accurate once again. I’ve exported the URL that was created for my application:

$ oc get route

NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
flask-app-route flask-app-route-test.apps.cluster-ttj64.ttj64.sandbox2247.opentlc.com /homepage flask-app-service <all> None

And the result was as the following:

Truly Amazing.

Generate ArgoCD Application YAML → Deploy In A GitOps Way

Amazing, thanks.

Finally, I want my application to suite the GitOps structure.

Please consider the fact that I’m using ArgoCD, and help me generate the “Application” YAML for ArgoCD application deployment.
I want this GitOps application to be auto-synced, and to create a namespace automatically that is called “flask-app-k8s” using the CreateNamespace=true option.

My git repo is called “flask-app-k8s”, use my GitHub username please.
The repo is flat, so no need to access a specific path.

Please consider that I’m using the “oc” command-line, and not “kubectl” nor “argo” command-lines.

Once again, I planted a few clues to my instructions:

  • I expected ChatGPT to understand that I’m using ArgoCD, and suit the YAML file accordingly
  • I expected it to remember what was my DockerHub and GitHub usernames, which were provided earlier
  • I used natural English to explain which of the ArgoCD properties and features I want to use

In order for you to see how ChatGPT answered my question, I’ve recorded its answer for you:

After creating the provided YAML file for my ArgoCD application, the application was deployed successfully (I wasn’t that surprised anymore):

I’ve exported my application’s URL once again:

$ oc get route 

NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD
flask-app-route flask-app-route-flask-app-k8s.apps.cluster-ttj64.ttj64.sandbox2247.opentlc.com /homepage flask-app-service <all> None

When accessing it via my browser, I’ve verified that my application was successfully deployed to my Openshift cluster:

Without writing a single line of code myself, I was able to perform a whole workflow of a semi-automated and simple CI/CD pipeline.

Not sure if that scares me or makes me happy.

Conclusion

Putting humor aside, this is truly exciting.

I’m sure that are much more capabilities to explore with this tool, and that this is only the beginning for this and more tools that will be disruptive enough to reshape our day-to-day life.

Looking forward to seeing more of this, maybe integrated with DALL-E :)

Feel free to use my questions and ask the same things, I guess answers will be different, but that shows that there are various ways to solve the same set of problems.

Hope you’ve enjoyed this demo, see ya next time.

--

--