Score:0

Create Rancher API Key with kubectl

ru flag

Given access to the kubernetes cluster, but no API key, how can I programatically create a API key for rancher server?

The method described in documentation here requires a password login an a web browser. I would like to get the same outcome programatically. Given that all the state should be on etcd, it should, in theory, be possible through kubectl.

Score:0
ru flag

I found a way to make this work:

Create a JSON file to define the token (i.e token.json):

{
  "apiVersion": "management.cattle.io/v3",
  "authProvider": "local",
  "current": false,
  "description": <enter description>,
  "expired": false,
  "expiresAt": "",
  "isDerived": true,
  "kind": "Token",
  "metadata": {
    "labels": {
      "authn.management.cattle.io/token-userId": <enter user id>,
      "cattle.io/creator": "kubectl"
    },
    "name": <enter a token id>,
  },
  "token": <enter token>,
  "ttl": 0,
  "userId": <enter user id>,
}

The token ID can be any unique string to give a name of the token. For the user-id, choose a user to which this token should be long to. (see user list with kubectl get users -n cattle-system).

kubectl apply -f token.json
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.