Skip to content

Interacting with the Rancher API using cURL

This document (000020952) is provided subject to the disclaimer at the end of this document.

Environment

Rancher 2.6.X and above.

Situation

How can I interact with the Rancher API endpoint using cURL?

Resolution

Interacting with the Rancher API using cURL

The Rancher API is an application programming interface that allows users to interact with their Rancher infrastructure without manually logging into their servers. This article will explain how to use cURL to interact with the Rancher API and provide an example command.

What is cURL?

cURL is a command-line tool that transfers data from one system to another. It supports various protocols, including HTTP, HTTPS, FTP, and FTPS. cURL is commonly used for making API requests and interacting with web services.

Using cURL to Interact with the Rancher API

To interact with the Rancher API, you need to use cURL to make an HTTP request. The request must include the authentication token, the URL of the Rancher API endpoint, and any other parameters specific to your request.

The root of the Rancher API endpoint is: https://YOUR_RANCHER_URL/v3

For example, if you want to list all the users in your Rancher infrastructure, you would use the following cURL command:

curl -u "$access_key:$secret_key" -X GET "https://YOUR_RANCHER_URL/v3/users"

The variables in this command, should be replaced with your Access Key and Secret Key. These can be created in the Account and API Keys section of the Rancher UI.

Conclusion

Using cURL to interact with the Rancher API is a convenient way to automate tasks and manage infrastructure. With cURL, you can quickly and easily interact with the Rancher API to list namespaces, create resources, deploy applications, and more.

Additional Information

Disclaimer

This document serves as a disclaimer related to the Rancher API endpoint. Interacting directly with this endpoint is not officially supported. Managing Kubernetes clusters is best done using Kubectl or the UI.

The API should only be used for testing or debugging and not for production-level changes. If you want a supported CLI utility to interact with the Rancher API, please check out Rancher CLI.

You may need to use the insecure option in your cURL command if you're Rancher UI doe not have a trusted cert.

curl --insecure -u "$access_key:$secret_key" -X GET "https://YOUR_RANCHER_URL/v3/users"

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.