星期二, 1月 28, 2025

tmux 小記


tmux 小記


OS: ubuntu 22.04 LTS

OS: macOS Sonoma


上次用 tmux 是好幾年前, 今天看到 youtube 的一個影片, 所以重新來試試看, 主要兩個原因

  • Linux and Mac 都支援

  • 可以分享終端機的資訊, 方便 demo 使用


tmux Github https://github.com/tmux/tmux


安裝 tmux in Ubuntu 22.04 LTS


搜尋套件

# apt-cache  search  tmux


tmux - terminal multiplexer


安裝 tmux

# apt-get  install  tmux


Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

tmux is already the newest version (3.2a-4ubuntu0.2).

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.


這邊會發現沒有安裝套件, 因為 ubuntu 22.04 LTS 預設應該已經安裝


再次確認

# apt  list --installed  | grep tmux


tmux/jammy-updates,jammy-security,now 3.2a-4ubuntu0.2 amd64 [installed]


基本的技巧可以看網路的影片或是文章


讓我比較有興趣的還是 share terminal 這塊

這邊我找到一個文章

以下是 lab 方式 (前提為 2 個用戶端都連線同一台機器 SSH)


確認目前 tmux session

# tmux  ls


error connecting to /tmp/tmux-0/default (No such file or directory)


建立一個 新的 session 命名為 demo

# tmux  new  -s  demo




這個時候再次觀察, 可以發現有新的 session 資訊


# tmux  ls


demo: 1 windows (created Tue Jan 28 05:23:43 2025) (attached)


在要觀察的另外一個用戶端終端機


# tmux  attach-session  -t  demo


這個時候就會發現, 已經掛載到同一個 session 然後兩邊的輸出都是同步


剛剛這樣的方式會發現兩個用戶端都可以下指令與輸出

如果不希望其中的用戶端可以下指令的話, 可以在 attach session 的時候加上 -r , 就會是使用 read only 的方式


另外小補充一個影片

  • you need to learn tmux RIGHT NOW!!

  • 這邊針對要練習一開始如何按按鍵有幫助, 例如要開新的視窗是 Ctrl + b c , 實際上的做法不是同時按住 Ctrl + b + c , 而是先按 Ctrl + b 放開之後再按 c, 要抓一下速度習慣

  • 喜歡的小快速鍵 Ctrl + b q 列出編號, Ctrl + b q 編號, 切換到該 terminal


另外就是 很重要的讓 tmux 支援滑鼠


# vi  ~/.tmux.conf 


加入 

set  -g mouse on



  • 之後的 session 就可以點選視窗來切換 terminal / 點選下方的 window 切換 window / 中間的線條調整大小


~ enjoy it



Reference


星期六, 11月 23, 2024

Azure AKS 升級小記



Azure AKS 升級小記


Azure Cloud Shell


有在 Azure 上面執行 AKS 來進行 Kubernetes 的練習

1.28  到明年 1 月, 所以繼續來更新 AKS


AKS 發行的行事曆可以參考


  • 之前支援的方式是支援前 3 個GA 版本, 目前  Azure 從 1.19 開始就遵循 12 個月的版本支援原則, 也就是至少一年升級一次 :)

  • 另外也可以考慮 LTS 版本


升級的部份, 主要參考官方文件


首先查詢 az 版本

$ az  --version


azure-cli                         2.65.0 *


等等要取得可以升級的 AKS Kubernetes 版本需要 Resource Group 與 AKS 名稱


如果要列出 Resource Group 可以使用 az group 指令


$ az  group  list --output  table


Name                                  Location      Status

------------------------------------  ------------  ---------

k8s-lab-2022                                    eastus         Succeeded

MC_k8s-lab-2022_sakana-20230617_eastus  eastus         Succeeded




如果要列出某個 Resource Group 下面的資源可以使用 az resource list 指令


> az  resource  list  --resource-group  k8s-lab-2022 --output  table


Name                                             ResourceGroup    Location    Type                                        Status

-----------------------------------------------  ---------------  ----------  ------------------------------------------  --------

sakana-20230617                                  k8s-lab-2022     eastus      Microsoft.ContainerService/managedClusters

CPU Usage Percentage - sakana-20230617           k8s-lab-2022     global      microsoft.insights/metricalerts

Memory Working Set Percentage - sakana-20230617  k8s-lab-2022     global      microsoft.insights/metricalerts




接下來就是取得可用的叢集版本


> az  aks  get-upgrades  --resource-group  k8s-lab-2022  --name  sakana-20230617


{

  "agentPoolProfiles": null,

  "controlPlaneProfile": {

    "kubernetesVersion": "1.28.3",

    "name": null,

    "osType": "Linux",

    "upgrades": [

      {

        "isPreview": null,

        "kubernetesVersion": "1.29.10"

      },

      {

        "isPreview": null,

        "kubernetesVersion": "1.28.0"

      }

    ]

  },



恕略


升級叢集

  • 一次只能升級一個次要版本。 例如,您可以從 1.23.x 升級至 1.24.x,但無法直接從 1.23.x 升級至 1.25.x。

  • 以我這個例子就是只能先升級到 1.29.x


> az  aks  upgrade  --resource-group  k8s-lab-2022  --name  sakana-20230617 --kubernetes-version  1.29.10


Kubernetes may be unavailable during cluster upgrades.

 Are you sure you want to perform this operation? (y/N): y

Since control-plane-only argument is not specified, this will upgrade the control plane AND all nodepools to version 1.28.3. Continue? (y/N): y


  • 我的實驗 cluster 是單一 node, 所以升級的時候節點是先建後拆, 所以交換的時候可能會有短暫服務 connection timeout


執行完畢之後, 驗證升級


> az  aks  show  --resource-group  k8s-lab-2022  --name  sakana-20230617 --output  table


Name                     Location    ResourceGroup    KubernetesVersion    CurrentKubernetesVersion    ProvisioningState    Fqdn

-----------------------  ----------  ---------------  -------------------  --------------------------  -------------------  ------------------------------------------------------------

sakana-20230617  eastus      k8s-lab-2022     1.29.10               1.20.10                      Succeeded 



  • 依照輸出的訊息可以知道已經升級成功


再次確認可升級的版本


$ az  aks  get-upgrades  --resource-group  k8s-lab-2022  --name  sakana-20230617


看了一下決定升級到 1.30.6


$ az  aks  upgrade  --resource-group  k8s-lab-2022  --name  sakana-20230617 --kubernetes-version  1.30.6


升級速度安排就看個人了



先記下來

~ enjoy it


Reference: