### Create Multiple Orchestration Clusters Source: https://context7.com/context7/rancher_rancher_v1_6_en/llms.txt This bash script outlines the process of creating multiple orchestration clusters (Kubernetes and Swarm) within Rancher. It details the steps for creating environments in the Rancher UI, configuring cluster parameters, assigning hosts, and accessing the created clusters using their respective native tools (kubectl for Kubernetes and docker for Swarm). ```bash # Creating Multiple Orchestration Clusters # Example workflow: # 1. Create Kubernetes environment in Rancher UI # - Select "Kubernetes" as orchestration # - Configure cluster parameters (etcd, controller count) # - Assign hosts to environment # 2. Create Swarm environment # - Select "Swarm" as orchestration # - Configure Swarm parameters # - Assign different hosts to Swarm environment # 3. Access clusters with native tools: # For Kubernetes: # Download kubeconfig from Rancher UI export KUBECONFIG=./kubeconfig-rancher-k8s.yml kubectl get nodes kubectl apply -f deployment.yaml # For Swarm: # Use Swarm endpoint from Rancher export DOCKER_HOST=tcp://rancher-swarm:2376 docker service create --replicas 3 nginx:latest docker service ls ``` -------------------------------- ### Add Hosts to Rancher Source: https://context7.com/context7/rancher_rancher_v1_6_en/llms.txt This bash script demonstrates how to add hosts to a Rancher server. It requires obtaining a custom registration command from the Rancher UI, which includes unique tokens. The script then runs a Docker container with necessary volume mounts and environment variables to register the host. Finally, it shows how to verify the host registration using the Rancher API. ```bash # Example: Adding hosts to Rancher # 1. Obtain custom registration command from Rancher UI # (Generated per environment with unique tokens) sudo docker run -e CATTLE_AGENT_IP="192.168.1.10" \ -e CATTLE_HOST_LABELS='env=production&role=compute' \ -d --privileged \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/lib/rancher:/var/lib/rancher \ rancher/agent:v1.6.x \ http://rancher-server:8080/v1/scripts/UNIQUE_TOKEN # 2. Host registers with Rancher server # 3. Infrastructure services automatically deploy # 4. Host becomes available for workload scheduling # Verify host registration curl -u "${API_KEY}:${API_SECRET}" \ http://rancher-server:8080/v2-beta/projects/${PROJECT_ID}/hosts # Expected response: JSON array of registered hosts ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.