iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 15
0
DevOps

從開源雲到邊緣運算系列 第 15

[Day 15]K3s 安裝

實驗環境

  • Agent 請準備兩台以上 (這樣才能看得出來調度在不同節點)
  • 使用 root 權限進行操作
  • 分為 低階入門PC 與 Raspberry Pi (ARM) 兩個平台做實驗

PC 平台環境

Server 端

  • Platform:x86_64 PC
  • CPU:2 core
  • RAM:4 GB
  • Disk:10 GB
  • OS:ubuntu:16.04

Agent 端

  • platform:x86_64 PC
  • CPU:1 core
  • RAM:2 GB
  • Disk:5 GB
  • OS:ubuntu:16.04

ARM 平台環境

Server 端

  • platform:Raspberry Pi 3 Model B+
  • CPU:4 core
  • RAM:1 GB
  • Disk:16 GB (microSD card)
  • OS: Raspbian stretch

Agent 端

  • platform:Raspberry Pi 3 Model B+
  • CPU:4 core
  • RAM:1 GB
  • Disk:16 GB (microSD card)
  • OS: Raspbian stretch

OS 網路環境調整

添加網路識別

設備 IP 查詢

ifconfig
  • 查詢結果 (示意圖)
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071G4YdpDuoM6.png

查詢 設備名稱

cat /etc/hostname
  • 查詢結果 (示意圖)
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071BSMZTPP006.png

增加識別項目

nano /etc/hosts
  • 添加項目
192.168.1.29 k3s-master
  • 調整後的檔案內容
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071yISMo1A7E3.png

調整DNS解析Server

修改 OS 中的解析設定檔

nano /etc/resolv.conf
  • 修改 nameserver 項目後方 IP
nameserver 8.8.8.8
  • 修改後結果 (示意圖)
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071Ggajl4W6jY.png

k3s 環境安裝方案

1. 官方線上抓取並搭建環境 (快速搭建)

參考網站:https://github.com/rancher/k3s/blob/master/README.md

Server 端

  • 安裝與執行 (這邊會直接啟動 k3s 服務)
curl -sfL https://get.k3s.io | sh -

https://ithelp.ithome.com.tw/upload/images/20191001/20121071pNDR8GisH7.png

  • 基礎功能驗證
k3s kubectl get nodes
  • 測試結果 (Server 端自己會是一個 Woker Node 的狀態)
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071LtjAVnZK3y.png

Agent 端 (先不用動作)

  • Agent 加入到 Server 之中 與 認證Token取得,將在明天講解~
curl -sfL https://get.k3s.io | K3S_URL=https://k3s-Server:6443 K3S_TOKEN=XXX sh -

2. Github 上的 Relaese 包下載使用

k3s Github 參考網址:https://github.com/rancher/k3s/releases
https://ithelp.ithome.com.tw/upload/images/20191001/20121071xmCjTgMj00.png

  • PC 平台使用 k3s (紅筐處)
  • ARM 系列平台使用 k3s arm (橘筐處)
  • Rasberry Pi 使用 k3s armhf

下載安裝包 (Master / Worker 皆相同)

PC 平台

wget https://github.com/rancher/k3s/releases/download/v0.9.1/k3s
  • 下載完會出現 k3s 應用程式
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071Sasnm2e1XN.png

Raspberry Pi 平台

wget https://github.com/rancher/k3s/releases/download/v0.9.1/k3s-armhf
  • 下載完會出現 k3s-armhf 應用程式
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071MUiTzvf1KA.png

k3s 轉移成 OS 全域可用應用程式

PC 平台

mv ./k3s /usr/bin/k3s

Raspberry Pi 平台

mv ./k3s-armhf /usr/bin/k3s
  • 為確保之後在 OS 中呼叫的名稱,因此都將應用程式更名為 k3s

權限調整

chmod 755 /usr/bin/k3s

環境測試

k3s version
  • 測試結果
    https://ithelp.ithome.com.tw/upload/images/20191001/20121071VMyj9h2ag8.png

  • 到這邊已經會有 k3s 基礎環境了,明天會再介紹 Server建立 與 Agent串接 的使用。

上一篇
[Day 14]K3s 介紹
下一篇
[Day 16]K3s 叢集搭建
系列文
從開源雲到邊緣運算30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言