Skip to content

Latest commit

 

History

History

Rancher

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Setup Rancher server for kubernetes management

Run Rancher on docker

version: '3.7'

networks:
  rancher:
    driver: bridge

volumes:
  rancher_data: {}

x-op-restart-policy: &restart_policy
  restart: unless-stopped

services:
  rancher:
    hostname: rancher
    image: rancher/rancher:latest
    container_name: rancher
    privileged: true
    networks:
      - rancher
    ports:
      - 80:80
      - 443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /etc/timezone:/etc/timezone:ro
      - rancher_data:/var/lib/rancher
    <<: *restart_policy

Execute docker-compose

docker-compose up -d

Access to Rancher server

At first, Rancher will use the generated password by itself; you can grep it with the Docker logs container. Do SSH access to the Rancher server and get the bootstrap password.

docker logs  rancher  2>&1 | grep "Bootstrap Password:"

The result will show like this example:

2023/04/20 14:33:30 [INFO] Bootstrap Password: 7g5s87qc6tfqzzlv92qkcvzcc9s4llxkpqvxvrbzwrz2cj8fp6cflq

rancher_login

After logged in we able to change the password for admin user as well.

rancher_change_password

Cloud credential

To access your cloud resources (AWS, GCP, Azure,...) on Rancher, we might add your own cloud credential into Rancher. To do that, let's click the menu on the top left corner and choose Cluster Management. After moving to a new page, you can see the option Cloud Credentials on the left side; choose it, then Create. Fill in the form, then create (credentials should end up as access key and'secret key`).

cloud_credentials create_credentails

Import existing cluster

Access to the homepage of Rancher, we have the option to create or import for a new cluster. After we had successfully provisioned a Kubernetes cluster we can import that cluster to the Rancher.

rancher_homepage register_cluster available_cluster cluster_dashboard