To use kubectl with curl, make certain you have a Linux distribution set up. In this illustration, we’re functioning Ubuntu 20.04 LTS. In addition, a minikube cluster need to be deployed and configured to run Kubernetes products and services. You must have sudo permissions as properly. The easy implementation of this report requires the installation of kubectl.
Process to Execute Curl With Kubectl
To begin, select just one of the subsequent procedures to open up the terminal window:
- Use the shortcut important mixture of “Ctrl+Alt+T”.
- Use the Ubuntu 20.04 software look for box to obtain what you’re wanting for. In our situation, we are exploring for a “Terminal”.
You could immediately launch the command line terminal employing both of these two techniques. To start out the minikube cluster, run the command indicated underneath following it has launched:
This command will have to have some time to execute. You can examine the version of minikube available on your working procedure though executing the command. We can make the most of the kubectl exec to get begun with the shell. When you are directed to the shell, you have to install curl in it by checking the pursuing command in the terminal:
The set up will just take a couple of times based mostly on your net pace. Immediately after set up, the next command will be executed in the terminal of Ubuntu 20.04 LTS together with keyword curl:
The adhering to command configures kubectl to perform as a reverse proxy. It is in system of locating and authorizing the API server.
$ kubectl proxy –port=8080 &
It also lets static info to be served more than a supplied HTTP path. Other than for the path matching the static useful resource path, all incoming data enters from one particular port, and it is handed to the external Kubernetes API Server port. Then, you might use curl to examine the API, as seen underneath with the assistance of affixed command:
$ curl http://localhost:8080/api/
The output will be almost similar, as you can analyze in the hooked up graphic earlier mentioned.
We coated the basics of curl and some of its most useful settings. In this guideline, you might now use Curl to debug your applications and test your URLs. We have tried handful of commands to get familiar with Curl. The total report is uncomplicated to put into practice and soak up. Now, I be expecting that right after studying this instruction carefully, you will be capable of using the curl command with ease.