EP23 - 持续部署使用 Octopus Deploy 三部曲,新增 Octopus 专案及调整 Jenkins 环境

前几天我们为 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

<<:  Day 32 | 常见 Livewire 问题:与 Controller 兼容的几种方式

>>:  DAY20 - 档案处理 - 利用jszip和file-saver,制作网页下载zip档案

[ Day 18 ] 条件 Render - Conditional Rendering

在前面元件以及生命周期的章节中我们提过 render() 这个方法,而且有特别指出它是在 Clas...

[Day_7]资料储存容器 (1) - tuple

Python的资料储存容器, 可以分为tuple、串列(list)、字典(dict)与集合(set)...

Day18:SwiftUI Picker

前言 SwiftUI Picker 可以让我们自行选择项目, 也可以选择不同的呈现方式, 这篇文章来...

DAY21 - 网页可以操作电脑里的档案?!本地端档案覆写 - The File System Access API

其实也是某天收到这个需求,一开始觉得怎麽可能,网页要存我电脑的档案!什麽情境才会用到这个功能...还...

HTTP Method(HTTP动词/HTTP方法)10/28更新

因为自己常记不住HTTP的几个动词所以自己来这边写一下 因为目前还没做出自己的网出来所以会偏向在IT...