Skip to content

SRDeveloperVishal/rancher

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 

Repository files navigation

rancher

RKE

Setup Node

# Disable swap:
sudo swapoff -a

# Install docker for rancher:
curl https://releases.rancher.com/install-docker/20.10.sh | sh

sudo usermod -aG docker $USER

Increase pod limit:

services:
  kubelet:
    extra_args:
      max-pods: 250

https://rancher.com/docs/rancher/v2.6/en/installation/requirements/installing-docker/
https://github.com/rancher/rke/releases

Download rke for Ubuntu:

sudo wget https://github.com/rancher/rke/releases/download/v1.3.0/rke_linux-amd64 \
  -O /usr/local/bin/rke

sudo chmod +x /usr/local/bin/rke

Generate config for RKE cluster:

rke config -a

Setup cluster:

rke up

Update cluster.yml for adding or removing nodes, then run:

rke up --update-only

Merge rancher config file:

# Make a copy of your existing config
cp ~/.kube/config ~/.kube/config.bak

# Merge the two config files together into a new config file
KUBECONFIG=~/.kube/config:${PWD}/kube_config_cluster.yml kubectl config view --flatten > /tmp/config

# Replace your old config with the new merged config
mv /tmp/config ~/.kube/config

# (optional) Delete the backup once you confirm everything worked ok
rm ~/.kube/config.bak

# rename context of rancher cluster
kubectx rancher-cluster=local

Rancher

Docker setup

Install rancher:

docker run -d --restart=unless-stopped \
  --name rancher \
  -p 80:80 -p 443:443 \
  -v /opt/rancher:/var/lib/rancher \
  rancher/rancher:v2.5.5 \
  --acme-domain \
  rancher.shubhamtatvamasi.com

Kubernetes Setup

Add Rancher and Nginx Ingress helm repo:

helm repo add nginx-stable https://helm.nginx.com/stable
helm repo add rancher-stable https://releases.rancher.com/server-charts/stable
helm repo update

Delete default ingress controller:

kubectl delete ns ingress-nginx

Install cert-manager:

kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.1.0/cert-manager.yaml

Install metallb:

kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/namespace.yaml
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.5/manifests/metallb.yaml

kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)"

Setup IP range. Giving only 1 IP which is of the node IP

kubectl create -f - << EOF
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb-system
  name: config
data:
  config: |
    address-pools:
    - name: address-pool-1
      protocol: layer2
      addresses:
      - $(kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="InternalIP")].address }')/32
EOF

type can also be ExternalIP based on your node

create namespace

# Create new namespace
kubectl create namespace nginx-ingress

helm install nginx-ingress nginx-stable/nginx-ingress \
  --namespace nginx-ingress \
  --version=0.6.1

Install rancher:

# Create new namespace
kubectl create namespace cattle-system

helm install rancher rancher-stable/rancher \
  --namespace cattle-system \
  --set hostname=rancher.shubhamtatvamasi.com \
  --set ingress.tls.source=letsEncrypt \
  --set letsEncrypt.email=info@shubhamtatvamasi.com \
  --version=2.5.5

Enable websocket for rancher ingress:

kubectl patch ingress rancher -n cattle-system \
  --patch='{
    "metadata": {
      "annotations": {
        "nginx.org/websocket-services": "rancher"
      }
    }
  }'

Access Ingernal Services this way:

https://rancher.shubhamtatvamasi.com/api/v1/namespaces/default/services/http:nginx:80/proxy/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published