DEV Community

ChungWei Wei
ChungWei Wei

Posted on • Originally published at kmp.tw on

[Linux] How To Install RKE

What Is RKE

Rancher Kubernetes Engine (RKE) is a CNCF-certified Kubernetes distribution that runs entirely within Docker containers. It works on bare-metal and virtualized servers. RKE solves the problem of installation complexity, a common issue in the Kubernetes community.

Download RKE Binary

Go To Here Download Binary

# Linux Platform
wget https://github.com/rancher/rke/releases/download/v1.4.1-rc2/rke_linux-amd64

mv rke_linux-amd64 rke && chmod +x rke
Enter fullscreen mode Exit fullscreen mode

Create RKE Configuration

Option 1 : Use minimal cluster.yml config from rancher

# cluster.yml
nodes:
    - address: 1.2.3.4
      user: ubuntu
      role:
        - controlplane
        - etcd
        - worker
Enter fullscreen mode Exit fullscreen mode

Option 2 : Use rke config Create New Config

# ./rke config --name cluster.yml
[+] Cluster Level SSH Private Key Path [~/.ssh/id_rsa]:
[+] Number of Hosts [1]:
[+] SSH Address of host (1) [none]:
[+] SSH Port of host (1) [22]:
[+] SSH Private Key Path of host () [none]:
[-] You have entered empty SSH key path, trying fetch from SSH key parameter
[+] SSH Private Key of host () [none]:
[-] You have entered empty SSH key, defaulting to cluster level SSH key: ~/.ssh/id_rsa
[+] SSH User of host () [ubuntu]:
[+] Is host () a Control Plane host (y/n)? [y]:
[+] Is host () a Worker host (y/n)? [n]:
[+] Is host () an etcd host (y/n)? [n]:
[+] Override Hostname of host () [none]:
.
.
.
.
Enter fullscreen mode Exit fullscreen mode

Create RKE Cluster

Attentions !!! You Need Close Node's swap, Install docker, and Make Sure The master node & work node Can Access Each Other Before Create

# ./rke up

INFO[0000] Building Kubernetes cluster
INFO[0000] [dialer] Setup tunnel for host [10.0.0.1]
INFO[0000] [network] Deploying port listener containers
INFO[0000] [network] Pulling image [alpine:latest] on host [10.0.0.1]
...
INFO[0101] Finished building Kubernetes cluster successfully
Enter fullscreen mode Exit fullscreen mode

Install kubectl

Download

curl -LO "https://dl.k8s.io/release/$(curl -L -s \
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Enter fullscreen mode Exit fullscreen mode

Install Command

install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Enter fullscreen mode Exit fullscreen mode

Verify Command

./kubectl version --client
#or
kubectl version --client
Enter fullscreen mode Exit fullscreen mode

Check RKE Cluster Status

./kubectl --kubeconfig kube_config_cluster.yml get nodes
#or
cat kube_config_cluster.yml > ~/.kube/config
kubectl version --client
Enter fullscreen mode Exit fullscreen mode

Try Deploy Pod To RKE Cluster

cat demo/nginx.yml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    # pod metadata
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80
Enter fullscreen mode Exit fullscreen mode

Deployment

# kubectl apply -f demo/nginx.yml

deployment.apps/nginx-deployment created
Enter fullscreen mode Exit fullscreen mode

Check Pods

~ # kubectl get po
NAME                                READY   STATUS    RESTARTS   AGE
nginx-deployment-6c8b449b8f-6mds6   1/1     Running   0          59s
nginx-deployment-6c8b449b8f-ct6lx   1/1     Running   0          59s
nginx-deployment-6c8b449b8f-j8lrf   1/1     Running   0          59s
Enter fullscreen mode Exit fullscreen mode

Remove Deployment

# kubectl delete deployment nginx-deployment
Enter fullscreen mode Exit fullscreen mode

Top comments (0)