iT邦幫忙

2021 iThome 鐵人賽

DAY 23
0
DevOps

關於我幫新公司建立整套部屬流程那檔事系列 第 23

EP23 - 持續部署使用 Octopus Deploy 三部曲,新增 Octopus 專案及調整 Jenkins 環境

  • 分享至 

  • twitterImage
  •  

前幾天我們為 Octopus Server 建置基礎設施,
今天我們則是設定專案內容,
並在 Jenkins 安裝 ocotpus 所需套件,
本來以為今天可以將整個部署流程拼完,
但是無奈步驟太多,
又硬生生把專案 Pipeline 的調整另外拆出去做。

設定 Octopus Deploy Server

登入

https://ithelp.ithome.com.tw/upload/images/20211005/20141518twrWtGPEhK.png

https://ithelp.ithome.com.tw/upload/images/20211005/201415188Z6jUCIxxT.png

更改 default space 名稱

https://ithelp.ithome.com.tw/upload/images/20211005/20141518KfvBJtPEwl.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518evMuYWKIOy.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518ErRoAOSgWh.png

設定 Environment

先點選上方的 Infrastructure

https://ithelp.ithome.com.tw/upload/images/20211005/20141518Cv1EmrsOb6.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518BpJn7Jf9In.png

https://ithelp.ithome.com.tw/upload/images/20211005/201415187IG0JntBIa.png

新增 Accounts

https://ithelp.ithome.com.tw/upload/images/20211005/20141518QvNWT0PF3Y.png

https://ithelp.ithome.com.tw/upload/images/20211005/201415187R3ybPK7D8.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518lnyxG1xfjf.png

新增 Deployment Target

https://ithelp.ithome.com.tw/upload/images/20211005/201415187Lntd7tq3W.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518e5XE7i4bls.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518Q8K8ozYysP.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518L1wHh54ZQg.png

EKS 的網址可以在 aws cloud console 的 eks 頁面中找到
https://ithelp.ithome.com.tw/upload/images/20211005/20141518vMrWv0eEch.png

記得 deployment rolecluster name 要填寫
不然會報錯
https://ithelp.ithome.com.tw/upload/images/20211005/20141518K7YehKSk33.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518cNuiLlQgit.png

Octopus Server 設定 kubectl 和 aws-iam-authenticator

遠端登入Octopus Server
https://ithelp.ithome.com.tw/upload/images/20211005/20141518p1b8o4gge9.png

到 Kubernetes 官網下載 kubectl
https://ithelp.ithome.com.tw/upload/images/20211005/20141518YYJRXNiK2d.png

搜尋 aws-iam-authenticator 到 aws 文件頁面下載
https://ithelp.ithome.com.tw/upload/images/20211005/20141518WljaXQgoCr.png

在 C 槽新增 kubernetes 資料夾
https://ithelp.ithome.com.tw/upload/images/20211005/20141518KpotiJd7Ds.png

C:\kubernetes 加到環境變數中
https://ithelp.ithome.com.tw/upload/images/20211005/20141518AypMqqyt4B.png

重新啟動 Octopus Server
https://ithelp.ithome.com.tw/upload/images/20211005/201415188M5gzqFQIs.png

重新檢查健康狀態

https://ithelp.ithome.com.tw/upload/images/20211005/20141518kc9iAAs1TV.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518bxDwRI1l8t.png

在 Octopus 上設定專案

新增專案

首頁上方點選 project
https://ithelp.ithome.com.tw/upload/images/20211005/20141518Mv9fCepPfR.png

點選右邊的 ADD Project
https://ithelp.ithome.com.tw/upload/images/20211005/20141518JIGiHuSUSi.png

輸入 project 名稱
https://ithelp.ithome.com.tw/upload/images/20211005/20141518ZZpN6lhHNF.png

輸入完成後就會建好一個專案
https://ithelp.ithome.com.tw/upload/images/20211005/20141518QD5kRSOVgO.png

新增參數群組

點選上方的 Library
https://ithelp.ithome.com.tw/upload/images/20211005/201415188zHre1QTQ6.png

點選左邊的 Variables Set
https://ithelp.ithome.com.tw/upload/images/20211005/20141518OeFLTmqL71.png

點按中間的 ADD VARIABLE SET 按鈕
https://ithelp.ithome.com.tw/upload/images/20211005/20141518aaA4QBjlMi.png

輸入名稱並儲存
https://ithelp.ithome.com.tw/upload/images/20211005/20141518Tj2tpkgoy5.png

儲存後可見空白的 VARIABLE SET
https://ithelp.ithome.com.tw/upload/images/20211005/20141518lOHtHTJgR7.png

輸入資料庫的參數
密碼類的也可以在 Type 選擇 Sensative 做隱藏
https://ithelp.ithome.com.tw/upload/images/20211005/20141518E70eM4US85.png

Jenkins pipeline

產生 Octopus API Key

點選右上角選擇 profile
https://ithelp.ithome.com.tw/upload/images/20211005/20141518MIDqYYv33T.png

點選左側 My API Keys
https://ithelp.ithome.com.tw/upload/images/20211005/20141518tMgLMcB6cf.png

點按 NEW API KEY,並填入所需資訊
https://ithelp.ithome.com.tw/upload/images/20211005/20141518q0OhGL8h0Y.png

按下 GENERATE NEW,並複製 Key 備用
https://ithelp.ithome.com.tw/upload/images/20211005/20141518amsWpaWxoH.png

Close
https://ithelp.ithome.com.tw/upload/images/20211005/20141518y43y6YXRwY.png

安裝 Octopus Deploy 套件

登入 Jenkins
https://ithelp.ithome.com.tw/upload/images/20211005/20141518s01HNown7w.png

管理 Jenkins
https://ithelp.ithome.com.tw/upload/images/20211005/20141518fpaPchqI8D.png

外掛程式管理
https://ithelp.ithome.com.tw/upload/images/20211005/20141518AmjyqQqeSV.png

搜尋並安裝 Octopus Deploy
https://ithelp.ithome.com.tw/upload/images/20211005/20141518uyQF87UTby.png

設定 Octopus 系統參數

登入 Jenkins > 管理 Jenkins
https://ithelp.ithome.com.tw/upload/images/20211005/20141518aCcqd6BK8A.png

在設定系統中間填入 Octopus Server 參數
https://ithelp.ithome.com.tw/upload/images/20211005/20141518Xe488jpQ0B.png

Jenkins Server 設定 octopus cli

Jenkins Server 在部署上需要透過 octopus 自己開發的 command line
我們之前都是透過 portal 跳板到 Jenkins 上
但是在 Terminate 之後
目前唯一有對外的只剩下 octopus server
而我們今天也預計遠端登入到 octopus server
並把 pem key 傳上去後
再透過 octopus server ssh 到 jenkins 去安裝 octopus cli
這的確不是個好方法
未來會再修掉
目前就先這樣

https://ithelp.ithome.com.tw/upload/images/20211005/20141518MCqdv64VSn.png

https://ithelp.ithome.com.tw/upload/images/20211005/20141518w6blkIDjbG.png

sudo apt update && sudo apt install --no-install-recommends gnupg curl ca-certificates apt-transport-https && \
curl -sSfL https://apt.octopus.com/public.key | sudo apt-key add - && \
sudo sh -c "echo deb https://apt.octopus.com/ stable main > /etc/apt/sources.list.d/octopus.com.list" && \
sudo apt update && sudo apt install octopuscli

安裝完後,記得再下 whereis octo
查看路徑
https://ithelp.ithome.com.tw/upload/images/20211005/20141518SEwsdpfsNb.png

回到 Jenkins Server 網頁畫面
設定 Jenkins 中點按 Global Tool Configuration
https://ithelp.ithome.com.tw/upload/images/20211005/201415181kRkf7EHQv.png

填完路徑後按下儲存
https://ithelp.ithome.com.tw/upload/images/20211005/20141518iheLQ85Use.png

本來以為今天可以寫完,
但是內容實在太多了,
未完待續...

參考資料:

  1. Octopus how-to-create-an-api-key
  2. Octopus Jenkins plugin

上一篇
EP22 - 持續部署使用 Octopus Deploy 二部曲,安裝 Octopus Deploy
下一篇
EP24 - 持續部署使用 Octopus Deploy 四部曲,整合 Jenkins 自動部署到 EKS
系列文
關於我幫新公司建立整套部屬流程那檔事30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言