星期一, 9月 22, 2025

Terraform in macOS 安裝小記



Terraform in macOS 安裝小記


OS: macOS 14.3

Terraform v1.13.3


最近不管在家還是在公司, 使用 Mac 的時間佔比較多的時間, 故有些工具會轉移到 Mac 上面來作.

今天就紀錄一下 Terraform 在 macOS 上面的安裝


之前的安裝文件是使用 openSUSE Leap 15.5 距今也一年多了


在 macOS 一般來說我都會使用 Homebrew 來進行套件安裝


查詢一下 Terraform 官網的安裝方式


接下來進行 terraform 安裝


% brew  tap  hashicorp/tap


  • brew tap 這個指令是用來新增 Homebrew 的「第三方軟體來源」(third-party repository)的指令。


% brew  install  hashicorp/tap/terraform


 安裝完成後可以透過 terraform 指令檢查版本

% terraform  --version

Terraform v1.13.3


  • 因為是使用 brew 指令安裝, 後續可以透過 brew update 更新清單後, 再使用 brew upgrade terraform 升級 terraform 版本


~ enjoy it



References


星期三, 9月 17, 2025

Gemini CLI Login 方式小記

Gemini CLI Login 方式小記




OS: macOS 14.3

Gemini Cli: 0.4.1


今天來實作 Gemini CLI 使用不同登入方式驗證


Gemini CLI 的驗證方式有 3 種

  • Login with Google

    • Best for

      • Individual developers as well as anyone who has a Gemini Code Assist License.

    • Benefits

      • Free tier: 60 requests/min and 1,000 requests/day

      • Gemini 2.5 Pro with 1M token context window

      • No API key management - just sign in with your Google account

      • Automatic updates to latest models

  • Use Gemini API Key

    • Best for

      • Developers who need specific model control or paid tier access

    • Benefits

      • Free tier: 100 requests/day with Gemini 2.5 Pro

      • Model selection: Choose specific Gemini models

      • Usage-based billing: Upgrade for higher limits when needed

  • Vertex AI

    • Best for

      • Enterprise teams and production workloads

    • Best for

      • Enterprise features: Advanced security and compliance

      • Scalable: Higher rate limits with billing account

      • Integration: Works with existing Google Cloud infrastructure

  • 參考官方網站 https://github.com/google-gemini/gemini-cli 


可以在執行 /auth 看到相關選項



驗證參考文件


根據詢問 Gemini CLI 的結果, 驗證順序為

  • Vertex AI > Gemini API Key > Google login

  • 這個部分也可以理解, Vertex AI 是給 企業使用 優先性肯定比較高


==== 首先來實作 Vertex AI 方式驗證 ====


無組織的專案無法使用 API KEY, 所以無法使用 API KEY 方式執行


故要改用應用程式預設憑證  Application Default Credentials  (ADC)


使用以下指令設定

  • gcloud  auth  application-default  login


這樣的方式要在 ~/.zshrc ( 或是 ~/.bashrc )內設定環境變數


export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_NAME"

# gemini cli 因為要使用 vertex ai 模式還要多設定 GOOGLE_CLOUD_LOCATION

export GOOGLE_CLOUD_LOCATION="us-central1"


  • location 的部分建議設定 us-central1, 我有遇過設定 asia-east1 沒有 Gemini Pro 2.5 模型的設定

  • 如果想要確認相關 log, 可以將 IAM -- > Audit log 內的 Vertex API 的 Data read 打開, 然後在 Log Explorer 觀察


設定好之後, 啟動 gemini

輸入 /auth

選擇 Vertex AI 方式驗證即可



然後可以到 Billing 觀察相關費用



==== 接下來嘗試 Use Gemini API Key ====


從   AI Studio 取得 API Key


點選 Create API key


選取 要建立 API Key 的 GCP 專案


複製 API Key

沒有即時複製到也不同害怕, 在同一個頁面也有相關訊息可以再查看



準備開始實作

這個時候確認你的環境變數 已經 unset  Vetext AI 的相關變數


準備好剛剛建立的 API KEY


export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"


  • 或是將這段寫入 ~/.zshrc 或是 ~/.bashrc 內


使用 gemini 指令

使用 /auth 選取 Use Gemini API Key


沒有意外就可以開始運作了

同時也可以在 AI Studio API Key 那個頁面觀察到 使用情況


或是在專案的 API & Services 觀察



==== 最後回到 Login with Google ====


最後回到 Login with Google

這個也可以參考之前的文章


大概就是要注意兩件事情

  • 會進行 Google 帳號登入驗證

  • 某些情況下要 export  GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"


一樣使用 gemini 指令啟動

使用 /auth 選取驗證方式 -- > Login with Google



這個時候會跳出瀏覽器 要求登入驗證



授權完畢就可以使用


以上整理 3 種登入方式

感覺離  Gemini CLI 又前進一步


~ enjoy it



References

星期六, 8月 30, 2025

Rancher Desktop 安裝小記


Rancher Desktop 安裝小記


OS: macOS 14.3


因練習 Cloud Run with Cloud Code,  其中有個功能是 Run/Debug on Cloud Run Emulator - 主要作用是讓您在自己的電腦上,模擬出一個與真實 Google Cloud Run 環境幾乎一樣的執行環境。


這個需要有 container 的環境, 但是目前在 MacOS 安裝 Docker Desktop 的意願沒有很高 ( 公司的 Windows 筆電有裝 Docker Desktop, 但覺得吃很多資源 ), 所以規劃使用 Rancher Desktop 來建置筆電的 Container 環境.


提到 Rancher 大家第一個應該想到 Kubernetes 的管理與建置 :) 


Rancher Desktop 官網


使用 Racher Desktop 的理由, 官網上說明的很清楚


  • Rancher Desktop 是 open source 並使用 k3s , 比較 Docker Desktop 是比較輕量化的選擇.

  • 與 Cloud Code 相容, 方便我後續測試


差異的部分我也直接使用官網的表格



  • 主要是可以自由選擇 containerd 或 dockerd 為執行環境

  • 並可以選擇要執行的 kubernetes 版本 (如果有啟動 kubernetes)



安裝方式很簡單, 根據自己的 OS 下載安裝


  • 我是下載 macOS(Apple silicon)



  • 直接拖曳到 Applications 打開


開啟預設的設定畫面


  • 我先取消勾選 Enable Kubernetes, 因為只想先有 container 環境

  • Container Engine 維持預設 dockerd (moby)

  • 點選 OK


顯示 Rancher Desktop 介面




  • 介面上可以看到目前 Rancher Desktop 版本 / 網路狀態 / Kubernetes 是否啟動 / Container Engine 使用哪個


安裝完之後 在 macOS 內就可以使用 docker 相關指令了


% docker  search  ubuntu


NAME                             DESCRIPTION                                      STARS     OFFICIAL

ubuntu                           Ubuntu is a Debian-based Linux operating sys…   17670     [OK]


看起來又往 Cloud Run 又前進一步


~ enjoy it



References