Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env sh
docker-machine rm -f rancher host1
docker-machine create rancher --driver virtualbox --virtualbox-cpu-count "-1" --virtualbox-disk-size "8000" --virtualbox-memory "512" --virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.11.2/boot2docker.iso
docker-machine scp scripts/rancher-net.sh rancher:.
docker-machine ssh rancher sh rancher-net.sh
docker-machine regenerate-certs rancher -f
eval $(docker-machine env rancher)
docker-compose up -d
eval $(docker-machine env -u)
docker-machine create host1 --driver virtualbox --virtualbox-cpu-count "-1" --virtualbox-disk-size "54000" --virtualbox-memory "2048" --virtualbox-boot2docker-url=https://github.com/boot2docker/boot2docker/releases/download/v1.11.2/boot2docker.iso
@superseb
superseb / delete-disconnected.sh
Created February 12, 2018 15:00
Delete disconnected hosts in Rancher environment
#!/bin/bash
RANCHER_URL=http://rancher_server:8080
ENV=1a7
for host in `curl -s http://$RANCHER_URL/v2-beta/projects/$ENV/hosts/ | jq -r '.data[] | select(.state == "disconnected") | .id'`; do echo Deactivating $host; curl -X POST -d '{}' http://$RANCHER_URL/v2-beta/projects/$ENV/hosts/$host/?action=deactivate; echo Deleting $host; curl -X DELETE -H 'Accept: application/json' http://$RANCHER_URL/v2-beta/projects/$ENV/hosts/$host; done
@jgreat
jgreat / 00-notes.md
Last active February 15, 2024 20:25
Rancher-Azure-Cloud-Provider-Storage-Classes

storageClass with PersistentVolumeClaims are really the way to do storage with Kubernetes.

For Azure There are 3 types of storage avalible.

  • (Slow, Limited, Going to cause tears) AzureFiles - CIFS share, with all the limitaions of CIFS :(
  • (Better) Azure Disk (Storage Account) - You can use this type with Azure "Node Driver" VMs in Rancher.
  • (Best) Azure Disk (Managed) - You will need to create your own VMs that support managed disk with premium storage, then use the "Custom" option.
@superseb
superseb / README.md
Last active April 17, 2022 09:01
Deploy kubernetes-dashboard on Rancher 2.x cluster exposed using NodePort

Deploy kubernetes-dashboard on Rancher 2.x cluster exposed using NodePort

This has been updated to install Dashboard v2.0.0, see below for pre v2.0.0 instructions

Requirements

Step 1: Generate kubeconfig from the UI

Generate the kubeconfig file for your cluster using the Kubeconfig File button in the Cluster view of your cluster.

@superseb
superseb / check-rancher.sh
Last active November 12, 2020 19:46
Check Rancher connectivity and certificate chain (check-rancher.sh https://rancher.yourdomain.com or docker run superseb/rancher-check https://rancher.yourdomain.com)
#!/bin/bash
if [[ $DEBUG == "true" ]]; then
set -x
fi
# Check if tools exist
command -v jq >/dev/null 2>&1 || { echo "jq is not installed. Exiting." >&2; exit 1; }
command -v dig >/dev/null 2>&1 || { echo "dig is not installed. Exiting." >&2; exit 1; }
command -v curl >/dev/null 2>&1 || { echo "curl is not installed. Exiting." >&2; exit 1; }
command -v sed >/dev/null 2>&1 || { echo "sed is not installed. Exiting." >&2; exit 1; }
@Oats87
Oats87 / generate_new_kubeconfig.sh
Created October 27, 2018 05:19
This bash script will sign an x509 certificate using the kube-ca located on any rancher node. This allows you to gain access back to your RKE-created kubernetes cluster should you lose the kube_config and cluster.yml for it, but still have SSH access to the hosts.
#!/bin/bash
echo "This will generate a new kube config for accessing your RKE-created kubernetes cluster. This script MUST be run on a Kubernetes node."
echo "Please enter the IP of one of your control plane hosts, followed by [ENTER]:"
read cphost
openssl genrsa -out kube-admin.key 2048
openssl req -new -sha256 -key kube-admin.key -subj "/O=system:masters/CN=kube-admin" -out kube-admin.csr
sudo openssl x509 -req -in kube-admin.csr -CA /etc/kubernetes/ssl/kube-ca.pem -CAcreateserial -CAkey /etc/kubernetes/ssl/kube-ca-key.pem -out kube-admin.crt -days 365 -sha256
sudo rm -f /etc/kubernetes/ssl/kube-ca.srl
@Oats87
Oats87 / gist:b056c1976fd0484e4f161ab063deb1b0
Created January 11, 2019 19:44
docker centos/rhel recommendations
# Docker 17.03.2 on RHEL/CentOS 7
Rancher has discovered a few issues when running Upstream Docker 17.03.2 on RHEL/CentOS 7. This document is being written to document recommendations for Docker configuration in order to ensure reliability while operating Kubernetes and Rancher with RHEL/CentOS 7.
### Overlay2 Storage Driver
Currently, Upstream Docker 17.03.2 performs kernel version validations to enable overlay2. As official overlay2 support from the upstream Linux kernel was not enabled until version 4.0 or higher than the kernel. Red Hat backported overlay2 support to 3.10.0-514 of their kernel.
Overlay2 support can be enabled by setting the following contents in the `/etc/docker/daemon.json` file and restarting Docker. Please note that you must do this on a fresh docker installation, or remove all running containers before performing this action.
```{
@Oats87
Oats87 / docker.json
Created January 17, 2019 21:38
centos/rhel docker.json config
{
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"exec-opts": [
"native.cgroupdriver=systemd"
]
}
@janeczku
janeczku / rancher-url-change.md
Last active March 18, 2024 17:37
Change the hostname/URL and certificate of an existing Rancher installation

Steps to change the URL of Rancher installation and switch from a self-signed certificate to a certificate signed by recognized CA.

  1. Change the Rancher server-url setting to the new URL:
    • Navigate to https://<old_rancher_hostname>/g/settings/advanced
    • Edit server-url to https://<new_rancher_hostname>
  2. Clear the private CA certificate for the old certificate
    • Navigate to https://<old_rancher_hostname>/g/settings/advanced
    • Next to cacerts click context menu -> View in API
    • Click Edit
    • Clear the content of the value field
@superseb
superseb / troubleshooting_kubernetes_commands.md
Last active August 12, 2023 17:10
Troubleshooting Kubernetes commands

Troubleshooting Kubernetes commands

Commands belonging to the Rancher webinar Troubleshooting Kubernetes

etcd

Check etcd members

docker exec etcd etcdctl member list