To use kubectl with curl, ensure you have a Linux distribution installed. In this example, we’re running Ubuntu 20.04 LTS. In addition, a minikube cluster must be deployed and configured to operate Kubernetes services. You should have sudo permissions as well. The smooth implementation of this article requires the installation of kubectl.
Method to Execute Curl With Kubectl
To begin, choose one of the following methods to open the terminal window:
- Use the shortcut key combination of “Ctrl+Alt+T”.
- Use the Ubuntu 20.04 application search box to find what you’re looking for. In our case, we are searching for a “Terminal”.
You may quickly launch the command line terminal using either of these two techniques. To start the minikube cluster, run the command indicated below after it has launched:
This command will require some time to execute. You can examine the version of minikube available on your operating system while executing the command. We can utilize the kubectl exec to get started with the shell. Once you are directed to the shell, you have to install curl in it by checking the following command in the terminal:
The installation will take a few moments based on your internet speed. After installation, the following command will be executed in the terminal of Ubuntu 20.04 LTS along with keyword curl:
The following command configures kubectl to function as a reverse proxy. It is in process of locating and authorizing the API server.
It also allows static data to be served over a given HTTP path. Except for the path matching the static resource path, all incoming information enters from one port, and it is passed to the external Kubernetes API Server port. Then, you may use curl to examine the API, as seen below with the help of affixed command:
The output will be almost identical, as you can examine in the attached image above.
We covered the basics of curl and some of its most helpful settings. In this guide, you may now use Curl to debug your apps and test your URLs. We have tried few commands to get familiar with Curl. The entire article is simple to implement and absorb. Now, I expect that after reading this instruction thoroughly, you will be capable of utilizing the curl command with ease.