This is a kind of documentation or walks thought of my work, which can be called a DevSecOps diary.

Writing a Quick Kubernetes Diagnostic Tool With Help of GitHub Copilot in Less Than 15 Minutes!

img.png

I haven’t changed to check the GitHub Copilot after my account gets activated, After seeing this Asking Github Copilot to write Fuzzers & Hacking code for me - Hacking with AI. I had spent a few minutes writing a Kubernetes Diagnostic Tool With Help of GitHub Copilot and the result was so productive. Here is the very naive approach I took to write a program to show how GitHub Copilot makes programmer life so productive.

I have just copied an example from https://github.com/kubernetes/client-go/tree/master/examples/create-update-delete-deployment and made the program running to check the program can run and make changes in my Kubernetes cluster to see all of my setups is correct.

The next steps are very simple, All I have to write in text what i want

github_copilot_suggestions_funtion_text.png

I had written a few quick functions that help a quick diagnosis on a cluster

// A function that prints all Kubernetes nodes that are not ready state

// A function that print the last five Kubernetes events

// A function that prints pods that are restarted more than once

// A function name “printPodsAreNotReady” that print pods are not ready state

github_copilot_suggestions_funtion_text.png

The only function I have to change a little manually is “printRestatedMorethanOncePods”. However, GitHub Copilot is basically helped on find pod.Status.ContainerStatuses with is a bit difficult to guess if you don’t know before.

Overall I found Github Copilot is super helpful and mostly when you are working with a package and an unknown library  Github Copilot suggestions land you a point quickly which saves a huge time.

Here is the most fun part bellow, Hope very soon I can do the blogpost with it.

//Genarate a paragraph of text about Github Copilot and client-go library
func printGithubCopilot() {
fmt.Println("Github Copilot is a tool to help you to create a kubernetes cluster.\n")
fmt.Println("Github Copilot is developed in github.com/kubernetes-sigs/kops.\n")
fmt.Println("Github Copilot uses client-go library to create a kubernetes cluster.\n")
fmt.Println("client-go library is developed in k8s.io/client-go.\n")

The source code is pushed here https://github.com/nahidupa/GiCoKu