

The process shown in this article runs on the remote server in Kubernetes (maybe in a staging environment similar to the production environment). This method consists of using a classical debugger to get information that reveals the cause of your problem quickly.

In short, you could waste a lot of time with this method if you don't have a good understanding of the code. Using print statements, you can easily miss the hot points and fail to see the information you need. It might take you several tries until you locate the issue and can debug it. You also have to consider the time required to deploy the operator to your cluster before testing it.įor example, with the reconcile loops of complex operators (more than a thousand lines per reconcile loop), it could be difficult to print the exact information you need. The problem with this procedure is the time required to build a new image each time you want to print new information. You just need to identify the hot points in the code and print the information you want to debug. Reviewing output is the simplest way to deploy and debug an application or operator. Debugging optionsįirst, let's analyze the basics of the debugging methods I mentioned in order to understand the advantages of the method I chose. We'll debug a Go program, but the principles apply to other languages and debuggers. This article shows how to use the second option, running a debugger on Kubernetes through the Visual Studio Code (VS Code) IDE. More elegantly, you can use a debugger on a remote server, setting a breakpoint to look for the problematic behavior.

You decide to deploy the operator on a Kubernetes cluster running on your local machine, to verify what's happening in your production cluster.Īt this point, you can write some code to debug the operator, build the new debug image, and deploy it on the local cluster to check the output and logs. As an example, imagine that you have a Kubernetes Operator that you want to debug because the reconciliation process is not working properly, or because the operator is not working as expected. Debugging in a container environment can be hard, and developers sometimes resort to ineffective methods to discover bugs during the deployment phase. These days, most developers deploy applications on Kubernetes.
