How to Execute Curl With Kubectl

The command-line tool cURL or Curl, which refers to client URL, is used by developers to transport data to and from a server. At its most basic level, Curl allows you to communicate with a server by defining the destination in the form of a URL and the data you wish to transmit. Curl operates on practically every platform and supports a variety of protocols, which include HTTP and HTTPS. This makes Curl suitable for testing connectivity from a local server to most edge devices or from practically any device. Curl is nearly ubiquitous, whether it’s for validating an API’s output before sending it to production or just requesting a response from a website to ensure it’s not down. Curl is a popular and powerful command. It comes in handy when you are reliant on the command line. It comes with a variety of features and supports a range of protocols. That’s a compelling reason to master this command. Curl commands are intended to be used as a technique to test URL connectivity and a data transmission tool. On the client-side, Curl is driven by libcurl, a free URL transfer library. Because it is developed to function without user interaction, this technology is preferred for automation. Curl can transport several files at once. In the following guide, we are going to check out the usage of the curl command using kubectl in Ubuntu 20.04 operating system.

Pre-requisites

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:

$ start minikube

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:

# apt-get install curl

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:

# curl http://localhost/

The following command configures kubectl to function as a reverse proxy. It is in process of locating and authorizing the API server.

$ kubectl proxy --port=8080 &

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:

$ curl http://localhost:8080/api/

The output will be almost identical, as you can examine in the attached image above.

Conclusion

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.



from Linux Hint https://ift.tt/3irp8zj

Post a Comment

0 Comments