MOPCON
      • 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
    # 從遺留架構動身前往 Kubernetes 的世界 - Luka Huang {%hackmd rG6pzIawQKe5cHU4rycgYg %} :::success :::spoiler TableOfContent [TOC] ::: > Hi, 大家好!我是 Luka,有聽這場演講的與會者如果可以的話麻煩幫我填寫演講體驗調查,讓我可以更增進我的演講技巧。如果有問題也可以在裡面發問,如果你留下 email 我就會回信給你,感謝大家來參加這場議程 [>>點我填寫 演講體驗調查<<](https://airtable.com/shrijutQ6ywyFPYaq) ## 講者介紹 [原來鄰居的 wifi 密碼那麼容易取得](https://reurl.cc/Xk2v3a) [Medium - Luka Huang 寫了一些奇耙的技術文章](https://medium.com/@LukaTW) ## Involve in Large-scale System 1. It's exciting 2. Knowledge is important 3. Can earn more money - Luka補充:公司需要維護大型系統,代表本身的事業是有持續營利的,不然無法持續付出維護的費用。所以大型系統是一個後端工程師滿值得思考,如何前進的一個方向。 ## 原因 - 將近 10 年的系統要轉移到 k8s - 需要承載很大的流量 - 對停機時間非常要求 - 飛到矽谷與架構施、顧問開會,討論、學習架構 - 實際參與『開始』到『上線』的完整的過程 ## 延伸 - 如何將「遺留程式碼」的觀念,用在「遺留架構」上 - 十倍工程師是怎麼樣的存在 - 離國際性人才,距離有多遠 ## 為什麼要轉移到 k8s 擴展歐洲業務:歐盟[GDPR](https://zh.m.wikipedia.org/zh-tw/歐盟一般資料保護規範)(嚴格的個資法) ### 用原來的架構再做一套不好嗎? - Single system - infra layer (EC2, VPC, RDS ... etc.) - Application Layer(API, Web, Worker,...etc) - Testing by QA - 如果要 clone 一個原本的系統,就會通通**變兩倍** - the new system is 90% the same as orignal system > 矽谷顧問兩週後宣布要用 K8S > 怕豹.jpg ## K8S and IaC ![](https://storage.googleapis.com/cdn.thenewstack.io/media/2018/06/e0338760-kubernetes-cicd.png) - 大平台 - 把各個機器視為一體 - infra - before containers - Luka 補充:在 container 之前每個機器是獨立的,並且機器內部的套件需要手動或是透過 Ansible 安裝。 - with containers - 可以把服務分成各種 container - 機器仍然獨立 - with k8s - 整個系統又回歸一體 - 由 k8s 作為中間的抽象層 - 每個單元變成一個一個 Pods ### 簡單介紹 K8S - 一台機器就是一個 Node - Pod 是 K8S 的最小單位 - Service & Deployment - deployment -> pods 數量 - service -> 將 pods 視為一個整體 - 有點類似 reverse proxy 的感覺(? - Luka 補充: - deployment 設定 pods 數量是其中一小部分的功能 - 還可以設定其他的選項,例如:上限使用多少記憶體諸如此累的配置。 - 而 Service 是一個宣告的概念,就是告訴 Ingress,我現在有 API 這個服務,你可以把流量導過來。 #### Helm - 安裝套件的軟體,類似 apt 之於 ubuntu - 那在K8S的世界,你想要安裝一個 wordpress - 只要輸入 `helm install my-wordpress wordpress` (示意,非實際指令) #### [Terraform](https://www.terraform.io/) 幫你提前在deploy前,先架設K8S環境所需要的資源,也可減少人工失誤。 ![](https://geekflare.com/wp-content/uploads/2020/08/terraform-architecture.png) ## 如何轉移至 K8S ### Part 1:. K8S 對應的元件 - Application Layer - API Server - Web server - Outer Service - 大祕寶 - init.d(初始化) - 根據使用者所設定的 Shell script,執行初始化。 - 服務啟動腳本通通放置於 /etc/init.d/ 底下 - init 是開機後核心主動呼叫 - 根據 sevice level,執行不同層級的服務。 - system.d(服務型) - 系統初始化需要做的事很多 - 每一步驟被 system.d 抽象成一個單元 - service 代表一個後台 process - 各種 services,會宣告在這 - monit.d(監控型) - 監控系統 - 不需要人工干預 - 所以這些需要 monit 的 process,是重要的 - Nginx / Apache Config - ingress 的設定 > 發現了大密寶之後,還是要面對 > 搬到 K8s 上面 ~~搬啊,哪次不搬~~ - k8s 對應 - init.d 初始化大秘寶 -> entrypoint - system.d 服務型大秘寶 -> docker / entrypoint (pods 讓 process 設定變得單純) - monit.d 監控型大秘寶 -> 運用 K8S 對 pod 的監控機制 - nginx /apache config -> ingress 的設定 ### Part 2: 通過工具協助 #### 如何更新 code 持續部署... > 以前得方法是把 Code 拉到 Server 上面然後重啟 > 可能透過工具協助,但大概就是這種原理 **使用 Docker 是比較有效益的方法** > Docker v.s. Ansible > Docker 不太會環境相依,Ansible 會莫名其妙地失敗,作業系統不同或某種套件版本不一導致 > 使用 docker + k8s 是最有效率的 #### pod 的生命週期 - readiness probe - 確保 pod 就緒才把流量導進來 - liveness probe - 確保 pod 還是在正常工作,否則K8S會終止這個pod並重啟 ### Part 3: Infrastructure layer #### IaC - Infrastructure as Code - Terraform - 把所有基礎設施變成 code - e.g., EC2, S3, VPC,使用 terraform 來撰寫 - Docker - 把安裝在機器中的東西也變成 code - e.g., apt install nginx 之類的,可以變成使用 Docker / Ansible 來寫 - Kubernetes - 能夠將所有機器變成一個大平台 - 透過修改 K8S 的設定擋即可完成所有所需的架構 #### IAC implement step 1. 用 Docker 建立 test image 2. 用 Ansible 寫出 Staging 伺服器配置 3. 設計新的架構來對應舊架構 -> 對應Kubenetes的結構 4. 實現 IAC 的最終目標 - 所有的改動,都使用 Terrafrom + Helm - Helm: 整合 ## Legacy Code VS Infrastructure ### Legacy Code - 別人寫的 - 但是也有可能是自己寫的 <!-- 自己的坑自己填 --> - 沒有測試覆蓋 - 測試無法表達意圖 ### Keyword - 找 91 大大 ### Legacy Infrastructure - 別人架設的伺服器 - 也可能是自己架的 <!-- 還是自己的坑自己填 --> - 沒有測試覆蓋 - 測試無法表達意圖 ### Testing on Infrastructure 1. End-to-End Test 2. Nightly build 3. Load testing ### Refactor Infrastructure - 降低未來修改成本 - 降低未來理解成本 - 簡化 - 只有內網存取管理員後台 - DB 只能被 application server 存取 ## 10X 工程師 > 有人說我以前不相信十倍工程師,直到我遇到 1/10 倍工程師 [name=Luka] - 技術又深又廣 - Web - Infra - Endpoint - K8S - 強大跨團隊溝通能力 - Backend - DevOps - Ops - QA - Auto Testing - 語言 - 英、日、中 - 說服公司 - 很強的技術不是一切 - 技術強,也要想辦法轉換成價值,讓公司買單 - 並且要真的做出來產生效益 <!-- 不能只有嘴砲 --> - 足夠大的市場 - 市場規模,決定你的想像力 - 技術強,思維也要跟上,才能解決更大市場的問題 - 如何讓自己可以接觸這樣的是常就是一個重要的課題 [建議 Podcast 頻道](https://medium.com/starbugs/%E5%B7%A5%E7%A8%8B%E5%B8%AB%E5%BF%85%E8%81%BD%E7%9A%84-podcast-%E9%A0%BB%E9%81%93-%E7%9F%BD%E8%B0%B7-%E8%8D%B7%E8%98%AD-%E6%BE%B3%E6%B4%B2-%E6%97%A5%E6%9C%AC%E7%94%9F%E6%B4%BB%E9%80%9A%E9%80%9A%E6%9C%89-ff8edc847f4d) ## Conclusion - 了解 K8s、Helm、terraform 等等技術名詞的意義 - 瞭解如何重構舊系統 - 聽到一個十倍工程師的故事 # 聊天區 >如果覺得聲音太小聲,可以在這裡跟我們反應喔~ > [name=Mopcon 工人] > 好唷 ヽ(●´∀\`●)ノ > [name=Mopcon 路人] > 喵喵喵 ヽ(✿゚▽゚)ノ > [name=Mopcon 喵] > 有可愛貓貓來到R3 > [name=Mopcon 工人] > 在哪裏?我要打爆牠 ξ( ✿>◡❛)▄︻▇▇〓▄︻┻┳═一 > [name=Mopcon 狙擊手] > 貓貓很可愛,可以到4樓幹話留言區找可愛貓貓-------Mo孃 > [name=Mopcon 工人] > 喵喵 (ノ>ω<)ノ > [name=Mopcon 喵] ###### tags: `MOPCON 2020`

    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