Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Rancher-API uses Zhuji

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Function

What can be achieved by using rancher-api:

You can customize rancher-UI

Various operations on rancher can be triggered in your own business system.

You can customize some of your own automation scripts

classification

Rancher-api currently includes two major categories:

Api of http:///v1 's main service

Catalog api isolated from http:///v1-catalog

If you have logged in to Rancher UI, you can visit the above address directly to see the API page.

Language

In actual development, we prefer to call Client SDk to use Client that API,Rancher provides in the following languages:

Python:gdapi-python / cattle-cli

Golang:go-rancher

Java:gdapi-java-server

Authentication mode

1. Use jwt-token

Send a post request to v1/token to generate token:

Then set the token to cookie, and the subsequent requests on the browser side will be automatically accompanied by token, which is currently used by rancher UI.

two。 Use api key (access_key & access_secret)

Generation of Api key

There are two types of key here: env-key with scope under an env, and global-key with scope under all env under that user.

Here, the advanced options UI is not expanded by default.

The generated api key can be used with client libraries such as cattle-cli/gdapi.

3. Use Basic auth mode

This method also requires api key, but it is used in a slightly different way. First, Base64.encode ("key: secret") is encoded for api key.

Why do you mention this way?

Because currently, catalog api cannot be called directly with client lib, but it can be called in this way.

Advanced options for Rancher

Under V1/setting, there are many advanced options that can be configured for manual editing.

You can modify the validity period of jwt token. By default, token is valid within 16 hours.

Auditlog is an audit log of Rancher. In general, frequent operation of Rancher will lead to a surge of Auditlog. Rancher provides a periodic purge mechanism that can adjust this cycle according to its own database capacity.

Various download addresses of Rancher-compose, especially in China, can be changed to their own address to facilitate download.

The cidr of Rancher VPC can also be modified:

Rancher is currently compatible with docker1.10.3, so Rancher provides a shell script to install this version, which will be used when Add Host uses other driver. We can specify the content sources to China to improve the installation speed of dockerengine, so as to quickly deploy Host.

The advanced features of v1/settings are waiting for you to dig carefully. Finally, Rancher-api has an instruction document that you can see here:

Https://github.com/rancher/api-spec/blob/master/specification.md

The semantic definition and the organizational structure of api are all worth learning.

In addition, api-v2 has also started https://github.com/rancher/v2-api before, but this matter has been shelved for the time being due to the release of GA and the support of multiple orchestration engines. It is believed that the development of v2, which is based on Golang, will be restarted soon.

Finally, it is important to note that there is an ambiguity between the semantics of the v1 version of api and UI, which is also mentioned in rancher-docs.

Original source: Rancher Labs

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report