--- title: CI/CD Demo tags: Ice --- [TOC] # :books: 第一階段Demo :rocket: ## :hammer_and_wrench: <font color="#0000C"> CI + Server/Client/MongoDB </font> ### :heavy_minus_sign: CI > [CI 架構 ](https://hackmd.io/IgXHjX6mTPiaXQbNS9VBxA?both#%E6%8C%81%E7%BA%8C%E6%95%B4%E5%90%88-Continuous-Integration) ### :heavy_minus_sign: Server/Client/MongoDB >  ## :hammer_and_wrench: <font color="#0000C"> 雲端工具使用列表 </font> | 工具名稱 | 應用 | 官網 | | --------------------- | --------------------------------------------------------------------------------------- |:--------------------------------------------------------------------:| | Google Cloud Platform | 機器部署的地方,映像檔儲存庫,映像檔弱點偵測 | [連結](https://console.cloud.google.com/?hl=zh-TW) | | Terraform | 機器部署工具,依你使用的雲端工具選用他的provider來部署機器,有類似git版控,減少人為疏失 | [連結](https://www.terraform.io/) | | Mirosoft Azure | git版控、ci pipeline、nuget repository | [連結](https://azure.microsoft.com/en-us/services/devops/pipelines/) | | Sonarqube | 程式碼檢測工具 | [連結](https://www.sonarqube.org/) | | Bitwarden | 密鑰管理工具 | [連結](https://bitwarden.com/) | | Octopus Deploy| 部署production image版本控制,大家俗稱為:squid: | [連結](https://octopus.com/)| | Kustomize | Infrastructure as Code(IAC)的概念,有一個base的yaml檔,依環境替換掉參數| [連結](https://ellis-wu.github.io/2018/07/26/kustomize-introduction/)| ## :hammer_and_wrench: <font color="#0000C"> 本機環境建置 </font> Step1. Windows 子系統 Linux 版,才可以在 Windows 上安裝任何 Linux 發行版本(要預設為wsl2唷:bangbang: ) * [windows wsl 安裝](https://docs.microsoft.com/zh-tw/windows/wsl/install-win10) * [linux作業系統下載](https://aka.ms/wslstore) Step2. 安裝git,安裝在ubuntu裡 * [git install](https://linuxconfig.org/how-to-install-git-on-ubuntu-20-04-lts-focal-fossa-linux) Step3. 安裝漂亮的終端機,自己選一個裝 * [hyper](https://hyper.is/) + [zsh](https://joechang0113.github.io/2020/03/23/ubuntu-install-oh-my-zsh.html) :100: * [cmder](https://cmder.net/) + [zsh](https://joechang0113.github.io/2020/03/23/ubuntu-install-oh-my-zsh.html) * [powershell and zsh 安裝教學](https://blog.poychang.net/setting-powershell-theme-with-oh-my-posh/) Step4. 安裝漂亮主題以及字型 * [powerlevel10k主題,推推:thumbsup:](https://github.com/romkatv/powerlevel10k) * [字形包,clone下來後選一個裝](https://github.com/powerline/fonts.git) Step5. 安裝windows docker * [docker in windows下載連結](https://docs.docker.com/docker-for-windows/install/) Step6. 安裝gcloud在ubuntu裡 * [gcloud](https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu) Step7. 安裝k8s指令在ubuntu環境裡 * [kuberctl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) Step8. 安裝好用的編輯器 * [visual vtudio vode:thumbsup:](https://code.visualstudio.com/download) Step9. 安裝terraform * [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli) ## :hammer_and_wrench: <font color="#0000C"> CI/CD </font> >### 目的 >1. 降低風險。 >2. 減少人工手動的繁複程序。 >3. 可隨時產生一版可部署的版本。 >4. 增加系統透明度。 >5. 建立團隊信心 ### 持續整合 [Continuous Integration] * 測試 (test) --> unit test * 建置 (build) --> azure build * <font color="EA0000"> 程式碼分析 (source code analysis) --> sonar cloud </font> :::warning :warning: 注意 :warning: 1. 程式碼分析,可能會造成rd人員的困擾,但很重要可以開程式碼的lint功能,至少保證code style大家看得懂 :cold_sweat: 2. 單元測試重要的功能一定要做 :fire: ::: ```flow st=>start: 開發者 e=>end: gcp image repo op=>operation: 提交代碼 op2=>operation: 代碼檢查 cond=>condition: 代碼檢查成功與否? para=>parallel: 圖表警示通知 io=>inputoutput: 建置與推送image st->op->op2->cond cond(yes)->io cond(no)->op para(path1, bottom)->io io->e ``` ### 持續部屬 [Continuous Delivery] * <font color="#EA0000"> 自動部署 (auto deploy) --> octopus </font> * <font color="#EA0000">軟體組建分析 (Software composition analysis) ---> gcp image check</font> * <font color="#EA0000">壓力測試 (stress test) --> sonar??</font> ```flow st=>start: 維運組 e=>end: deploy to prod op=>operation: 軟體組件分析 cond=>condition: 分析成功與否 op2=>operation: 壓力測試 cond2=>condition: 壓力測試成功與否? st->op->cond cond(yes)->op2 cond(no)->op op2->cond2 cond2(no)->op cond2(yes)->e ``` # :books: 第二階段Demo :rocket: ## :hammer_and_wrench: <font color="#0000C"> 排程 </font> - [x] CI / CD 布到章魚 YAML(版本號) - [x] FILBEAT CONFIG ci/cd (包含deamon set) - [x] ice grid 架構部屬 - [x] 跟子倫要pat key的deploy(azure devops) ## :hammer_and_wrench: <font color="#0000C"> CI / CD 布到章魚 YAML + ice grid 架構部屬 + 跟子倫要pat key的deploy(azure devops) </font> * ci/cd作業  * yaml作業  ### 問題1 pipeline連同nuget包一起build,會造成版本retention * 解法1: 在pipeline裡判斷,哪個包是否有變動 > 1.1 使用azure pipeline自己做掉 [連結](https://julie.io/writing/monorepo-pipelines-in-azure-devops/) > 1.2 自己寫腳本 * 解法2: nuget包就抽出來,拆repo ### 問題2 sonar cloud build 時有錯誤 * 解法1: 註解!!!! --- ## :hammer_and_wrench: <font color="#0000C"> FILBEAT CONFIG ci/cd (包含deamon set) </font> - [x] filebeat config + yaml - [x] elastic yaml - [x] kibana yaml - [ ] kafka 雲 --- ## :hammer_and_wrench: <font color="#0000C"> mac demo </font> [前往My github](https://github.com/jj891070/jay-play-go/blob/EFK/main.go) ### 問題1 在mac本機,因新版的docker在mac上不是跑在mac的host,以致於filbeat抓不到log ```shell $ docker inspect jay-play-go_web_1 $ ls /var/lib/docker/containers/cb6df9c0d6f0c24787421d1462ca57cf194bf053ef6b4a7653f4dda596d7c07f/cb6df9c0d6f0c24787421d1462ca57cf194bf053ef6b4a7653f4dda596d7c07f-json.log ```  * 解法1: 再掛一個docker container把 log 掛出來 ```shell $ docker run -it -v /var/lib/docker/containers:/var/lib/docker/containers alpine sh ```  --- ## :hammer_and_wrench: <font color="#0000C"> 今天討論的目標 </font> * 架構圖  * 因掛的disk有點多,往底層方向找    ## :hammer_and_wrench: <font color="#0000C"> 思考 </font> * ## log 的用意!? > 1. debug > 2. 分析使用者 * ## Gcp 的log蒐集 -> debug >### 優點 >1. 降低維護成本 >2. 蒐集方便 >3. 用多少算多少 >5. 建立團隊信心 >### 缺點 >1. 如果使用gcp套件去歸類log的話,就會綁在gcp,但可以不用 >2. 但如果gcp沒幫我們fluent的話,就GG了,但現在沒有雲是沒有這個功能的 * ## MongoDB 的 使用者call api 紀錄 -> 分析使用者 >### 優點 >1. rd的資料庫實踐只需要mongo >2. mongoDB的強項就是來記玩家紀錄 >### 缺點 >1. mongo掛了,就全部沒了
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up