This is not official documentation/tooling, use with caution
This generate the Kubernetes definitions of the cattle-cluster-agent
Deployment and cattle-node-agent
DaemonSet, in case it's accidentally removed/server-url was changed/certficates were changed. It is supposed to run on every cluster Rancher manages. If you have custom clusters created in Rancher, see Kubeconfig for Custom clusters created in Rancher
how to obtain the kubeconfig to directly talk to the Kubernetes API (as usually it doesn't work via Rancher anymore). For other clusters, use the tools provided by the provider to get the kubeconfig.
IMPORTANT: You get the cluster/node agents definitions from Rancher, and you apply them to the cluster that is created/managed so you need to switch kubeconfig to point to that cluster before applying them.
- Supported OS: Linux and MacOS
Note: as the definitions get out of date, please see https://gist.github.com/superseb/076f20146e012f1d4e289f5bd1bd4971 how to dynamically generate them instead
This uses docker ps
to find the rancher/rancher
container, so it should be run on the node running the rancher/rancher
container.
Use the file content from get_agents_yaml_single.sh
and append the cluster name to it, i.e. custom
. The definitions will be created in rancher-agents-custom.yml
.
bash get_agents_yaml_single.sh custom
Container ID running Rancher is 41a636e9bdc2
'kubectl get cluster' returns clusters available
Clusters found:
custom rancherKubernetesEngine c-9tc6c
yyy azureKubernetesService c-ps4c4
local imported local
You can now configure kubeconfig to your created/managed cluster and run kubectl apply -f rancher-agents-custom.yml to restore cluster/node agents
Note: as the definitions get out of date, please see https://gist.github.com/superseb/076f20146e012f1d4e289f5bd1bd4971 how to dynamically generate them instead
To use this approach, you need kubectl
configured pointing the the RKE cluster created to run Rancher. If it's correct, you should get output from kubectl get clusters
.
Use the file content from get_agents_yaml_ha.sh
and append the cluster name to it, i.e. custom
. The definitions will be created in rancher-agents-custom.yml
.
$ bash get_agents_yaml_ha.sh custom
'kubectl get cluster' returns clusters available
Clusters found:
custom rancherKubernetesEngine c-9tc6c
yyy azureKubernetesService c-ps4c4
local imported local
You can now configure kubeconfig to your created/managed cluster and run kubectl apply -f rancher-agents-custom.yml to restore cluster/node agents
Note: as the definitions get out of date, please see https://gist.github.com/superseb/076f20146e012f1d4e289f5bd1bd4971 how to dynamically generate them instead
To launch the cluster/node agent definitions on Custom clusters created in Rancher, you have to obtain the kubeconfig to talk directly to the Kubernetes API for that cluster using this gist and the name of the cluster (in this case, custom
)
curl https://gist.githubusercontent.com/superseb/f6cd637a7ad556124132ca39961789a4/raw/c2bb60a51fa4dafef2964589ce0bc9d923653aa1/get_kubeconfig_custom_cluster_rancher2.sh | bash -s -- custom
Then apply the definitions:
kubectl --kubeconfig kubeconfig apply -f rancher-agents-custom.yml