Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michaelstanton/601db367446ae7c11b5c34e11557d718 to your computer and use it in GitHub Desktop.
Save michaelstanton/601db367446ae7c11b5c34e11557d718 to your computer and use it in GitHub Desktop.

WARNING MAY BE INCORRECT AND INCOMPLETE, USE AT YOUR OWN RISK

Install Proxmox, RancherOS, in a VM with Rancher 2.0 and Portainer

Setup Proxmox

  1. Install Proxmox 5.3
  2. Console/SSH into Proxmox
  3. nano /etc/apt/sources.list
  4. edit the file to look like this
deb http://ftp.debian.org/debian stretch main contrib

# PVE pve-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian/pve stretch pve-no-subscription

# security updates
deb http://security.debian.org stretch/updates main contrib
  1. apt update && apt dist-upgrade -y
  2. reboot system

Install RancherOS

  1. Download RancherOS ISO
  2. Upload the iso to (local)pve
  3. Setup a VM with RancherOS ISO as CD. Give it at least 3gb ram to start. Rancher Server failed with low ram
  4. Boot
  5. From Console change password
  • sudo bash
  • passwd rancher
  1. SSH to rancher@
  2. prepare your ssh keys with putty gen
  • vi cloud-config.yml
  1. past the cloud config edited with your settings, make sure the pasted data is pated correctly, add your key in a single line
  2. press exit exit :wq to save
#cloud-config

hostname: rancheros
rancher:
  network:
    interfaces:
      br0:
        bridge: true
        dhcp: false
        address: 10.0.1.50/24
        gateway: 10.0.1.1
        mtu: 1500
      eth0:
        bridge: br0
  console: ubuntu
    dns:
      nameservers:
      - 10.0.1.2
write_files:
  - path: /etc/rc.local
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash
      apt-get -y update
      apt-get -y install python
ssh_authorized_keys:
  - ssh-rsa <YOUR KEY>  
  • sudo ros config validate -i cloud-config.yml
  • sudo ros install -c cloud-config.yml -d /dev/sda
  1. Remove CD Image from VM, and then reboot.
  2. SSH back into RancherOS (rancher@) using your new ssh private key

Intsall Rancher

  • sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher

log in to ranhcer thorugh the web browser Add Cluster. Choose Custom. Enter a Cluster Name. Click Next. From Node Role, select all the roles: etcd, Control, and Worker. Copy the command displayed on screen to your clipboard. Log in to your Rancher host with PuTTy. Run the command copied to your clipboard. When you finish running the command on your Linux host, click Done. Wait for your cluster to finish provisioning Reboot to make sure everything is working right

Creating your first container

  1. In your cluster drop down tab select default then deploy
  2. give it a name and add the ports and env needed

Install Portainer with NFS share

sudo docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart always --name portainer -v /mnt/appsNFS/portainer:/data portainer/portainer

select local

when adding volumes select bind and use the path /mnt/appsNFS/whateveryouwanthere

NFS Shares on FreeNAS

create a unix dataset called appsNFS with root and wheel as the user, set a quota for 50gb create a nfs share to the dtatset you created, select all dirs, mapall user:group to root:wheel enable nfs sharing and select nfsv4, allow non-root, nfsv3 owner ship reboot freenas

Add NFS mnt to rancherOS

sudo ros config set mounts '[["10.68.69.2:/mnt/MyVol/appsNFS", "/home/rancher/appsNFS", "nfs4",""]]'

Add macvlan so containers are given an IP and mac from your LAN

click add network select macvlan enter in your lan network select enable manual connection when creating a container select the network you just added and give it an availble static IP

Help

sudo vi /var/lib/rancher/conf/cloud-config.yml

https://medium.com/the-code-review/clean-out-your-docker-images-containers-and-volumes-with-single-commands-b8e38253c271

@ArgonQQ
Copy link

ArgonQQ commented Mar 6, 2021

Interesting. Thanks (⌐■_■)

@andrewiankidd
Copy link

just FYI newer versions of rancher require privileged access

docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher:latest

@ju4nmg
Copy link

ju4nmg commented Jul 18, 2021

Read what andrewiankidd wrote, i had to do the same,

also in the cloud-config file, change the position of console, as it throws error, i used the following

#cloud-config

hostname: rancher.homelab.com
rancher:
  console: centos
  network:
    interfaces:
      br0:
        bridge: true
        dhcp: false
        address: 192.168.0.19/24
        gateway: 192.168.0.1
        mtu: 1500
      eth0:
        bridge: br0
    dns:
      nameservers:
      - 8.8.8.8
      - 8.8.4.4
write_files:
  - path: /etc/rc.local
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash
      apt-get -y update
      apt-get -y install python
ssh_authorized_keys:
  - ssh-rsa <PUBLIC KEY>
  

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment