SITCON
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- GA: UA-34467841-15 --- # 混亂中的和諧:Kubernetes、DevOps 和 SRE - Patrickuuuu ###### tags: `SITCON 2024 共筆` `SITCON 2024` `2024` `共筆` `軟體開發` `新手適合` `R0` <blockquote> 在現代化 IT 中,Kubernetes、DevOps、和 SRE 三者發揮了關鍵的作用。我們來了解在程式開發過程中,這三者帶來的影響。了解它們如何調解 RD、QA、IT 間的溝通困難,緩解相互制衡的力量。關注這些技術如何融合以簡化營運、增強網站可靠性來幫助團隊應對不同的挑戰, 以此提升開發效率,減少人力資源,在提升網站可靠性的同時,還能讓工程師有多出來的時間去「喝杯咖啡!」 </blockquote> > ==Q & A== > https://app.sli.do/event/auAh8ga34dsqNtNmPhvmy9 {%hackmd FzhCnW3FSc-NVS2niHqaCA %} > 請從這裡開始 簡報: # QA :::spoiler ::: ## 想要在最後K8s時間一起動手做的可以安裝以下軟體 ### 1. Kubectl [在 Windows 安裝 kubectl](https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-windows/) [在 macOS 安裝 kubectl](https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-macos/) [在 Linux 安裝 kubectl](https://kubernetes.io/zh-cn/docs/tasks/tools/install-kubectl-linux/) :::success 成功安裝後在終端機執行 `kubectl version --client` 應該可以看到 Client Version: ... Kustomize Version: ... ::: ### 2. Docker Desktop [在 Windows 安裝 Docker Desktop](https://docs.docker.com/desktop/install/windows-install/) [在 macOS 安裝 Docker Desktop](https://docs.docker.com/desktop/install/mac-install/) [在 Linux 安裝 Docker Desktop](https://docs.docker.com/desktop/install/linux-install/) ### 3. 開啟 Docker Desktop Kubernetes 開啟 **Docker Desktop**,點擊右上角設定進到**Settings**,點擊左邊第四項**Kubernetes**,勾選 `Enable Kubernetes`,最後點選 `Apply & restart`,重啟後應該可以在最左下角看到 `Kubernetes running` ![image](https://hackmd.io/_uploads/r1d-A9OTT.png) ![image](https://hackmd.io/_uploads/r1_f0qua6.png) ### 4. 確認 Contexts 在正確的位置 執行 `kubectl config get-contexts` 應該要顯示 docker-desktop 的 CURRENT 為 * 才是正確的 ![image](https://hackmd.io/_uploads/BJ_YxoOp6.png) 如果不在正確的 context 上,則執行 `kubectl.exe config use-context docker-desktop` 切換至 `docker-desktop` ![image](https://hackmd.io/_uploads/r1OAei_ap.png) ### 5. 下載 deployment 的 YAML 檔 [GitHub 連結](https://github.com/Grapycal/Grapycal/tree/dev/charts/docker-kubernetes) 下載 `frontend.yaml` 以及 `backend.yaml` --- ## 以下會在議程中一起操作,怕跟不上的也可以先玩玩看 ### 6. 在 K8s 部署 deployment 1. 部署前端 `kubectl apply -f frontend.yaml` 2. 部署後端 `kubectl apply -f backend.yaml` ## 7. 檢查 deploymeny 部署情況 1. 列出所有在 default namespace 的 deployment `kubectl get deploy -n default` 2. 列出 frontend deployment 的 詳細資訊 `kubectl describe deploy frontend -n default` 3. 列出 backend deployment 的 詳細資訊 `kubectl describe deploy frontend -n default` 4. 列出所有 pods `kubectl get pods -n default ## 8. 成功部署 Grapycal 在本地的 K8s 了! 訪問 http://localhost:8766 ## 9. 檢查 pods 1. `kubectl get pods -n default` 2. 刪除backend其中一個看看 `kubectl delet pod grapycal-backend-xxx-xx` 3. 檢查目前 pods 狀況 `kubectl get pods -n default` ## 10. 更新 image 1. 將 frontend.yaml 中 `docker.io/patrickuuuu/grapycal-frontend:latest` 改為 `docker.io/grapycal/grapycal-frontend:latest` 2. 將 backend.yaml 中 `docker.io/patrickuuuu/grapycal-backend:latest` 改為 `docker.io/grapycal/grapycal-workspace:latest` 3. 重新 apply `kubectl apply -f frontend.yaml` `kubectl apply -f backend.yaml` :::info 等待更新過程中可以檢查看deployment 的可用性 ::: 4. 檢查目前 pods 狀況 `kubectl get pods -n default` ### DevOps Develop - 設計新功能 - 寫程式 - 找 Bug - 修 Bug - 生出更多的 Bug Operations - 確保系統穩定 - 監控系統效能 - 排除故障 - 緊急應對 &rarr; 能動就不要動! * 溝通不良 * 交付速度慢 * 開發速度慢 * 協作障礙 &rarr; DevOps - 解決衝突 - 提升效率 開發人員也要有維運的概念 ### DevOps 的階段 #### 計畫 Plan * 決定目標 * 釐清要做的事 * 工具: * Jira * Git * Google Docs 也沒有問題 #### 程式碼 Code * 程式碼建立 * 軟體建立 * 版本控制 * 工具: * GitHub * GitLab * Bitbucket #### 建置 Build * 編譯、封裝程式碼 * 工具: * Docker * npm * Gradle * ... #### 測試 Test * 確保函式可行性 * 確保程式可行性 * 工具: + pytest + Selenium + JUnit * 單元測試 Unit test vs. 整合測試 Integration test * 單元測試:個別功能運作 + 整合測試:不同單元之間運作正常 #### 發布 Release * 新版本(Python 3.11→3.12) #### 部署 Deploy * 將軟體部署至生產環境 * 工具: * Kubernetes * Jenkins * argo * ~~Powershell 也算~~ #### 操作/維運 Operate * 緊急事件回應 * 日誌管理 * 故障排除 * 工具: * Kubernetes * ... #### 監控 Monitor * 發生錯誤時警報 * 分析趨勢 * 建立{儀表板|dashboard}(四項黃金指標) * 工具: * Sentry * Grafana * Prometheus * 監控之後就是制定新的計畫(Plan) ### DevOps lifecycle ### 自動化 把重複的事情交給機器去做 CI/CD #### Continuous Integration(CI) 持續整合 - Build - Unit Tests - Integration Tests * 工具: * GitHub Actions * GitLab Runner * Jenkins #### Continuous Deployment(CD) 持續部署 Continuous Delivery 持續交付 * 自動發布至儲存庫 * 自動部署至預備環境 **手動**部署至生產環境 Continuous Deployment * 自動部署至生產環境 ### CI/CD 跟 DevOps 的關係 * DevOps 還有以下流程: * Continuous Development * Continuous Testing ### DevOps 原則 * 系統思維 * 考慮整個系統,而非自己的團隊或個人 * 自動化 * 將重複且耗時的工作自動化,將一切盡可能自動化 * 文化 * 一個成功的 DevOps文化... ### 如何評斷應用程式的服務水準? ### SRE 的專有名詞 #### SLI 服務水準指標 * 正常執行時間 * 系統輸送量 * 下載速率 * 應用程式載入速度 * API 回傳 500 的比率 #### SLO 服務水準目標 - SLI + 一段時間 + 目標 #### SLA 服務水準協議 - 基於 SLO ### SRE在做什麼? - 緊急事件回應/處理 - 變更管理 - 自動化 - 性能優化 - 監控及緊報 ### 跟 DevOps 是不是很像? DevOps 是想法、SRE 是 DevOps 的一種實現 ### Kubernetes 自動化部署擴展與管理容器的開源管理系統 ### Node ##### Master node 負責發號施令的中樞 ##### Worker node * 範例: * kubelet * kube-proxy * ... Deployment 是 pod 的封裝 ### 為什麼要用DevOps - 速度 - 安全 - 可靠 - 協作 ### 根本原因 > 這是一個軟體或人類系統中的缺陷,如果問題在修復後,會讓人有自信,相信該事件不會再次發生 {%hackmd X1AoDbijSLydAgS1sLbdBw %}

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    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

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully