Kamil Bregula
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me 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
    • Save as template
    • 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 Create Help
Create Create new note Create a note from template
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me 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
    # Docker --- # Kubernetes Kamil Breguła --- # Co to jest? Kubernetes to przenośna, rozszerzalna platforma open source do zarządzania konteneryzowanymi aplikacjami i usługami, która jest realizowana przez deklarywną konfiguraccje i daleko posuniętą automatyzaccje automatyzację. Ma duży, szybko rozwijający się ekosystem (!!!) Nazwa Kubernetes pochodzi od greckiego, co oznacza sternika lub pilota. Google otworzył projekt Kubernetes w 2014 roku. Kubernetes opiera się na półtorej dekadzie doświadczenia, które Google ma z wykorzystaniem kontenerów produkcyjnie na dużą skalę, w połączeniu z najlepszymi w swojej klasie pomysłami i praktykami społeczności. --- # Dlaczego potrzebujemy Kubernetesa? Kontenery to dobry sposób na pakowanie i uruchamianie aplikacji. W środowisku produkcyjnym musisz zarządzać kontenerami, w których działają aplikacje i upewnić się, że nie ma przestojów. Na przykład, jeśli kontener ulegnie awari, należy uruchomić inny kontener. Czy nie byłoby łatwiej, gdyby to zachowanie było obsługiwane przez system? W ten zadaniu Kubernetes przychodzi na ratunek! Kubernetes zapewnia platformę do niezawodnego uruchamiania systemów rozproszonych. Zajmuje się skalowaniem i przełączaniem awaryjnym aplikacji, zapewnia wzorce wdrażania i wiele więcej. Na przykład Kubernetes może łatwo zarządzać wdrożeniem stopniowym (ang. canary deployment) dla twojego systemu. --- # Co może robić z Kubernetesem? * Wykrywania usług i równoważenie obciążenia (ang. Service discovery and load balancing) * Organizacja dostępu do danych (ang. Storage orchestration) * Automatyczne wdrażanie i wycofywanie (ang. Automated rollouts and rollbacks) * Automatyczne rozmieszczanie kontenerów (ang. Automatic bin packing) * Samo leczenie (ang. Self-healing) * Zarządzanie sekretami i konfiguracją (ang. Secret and configuration management) --- # Czym nie jest Kubernetes? Kubernetes nie jest tradycyjnym, kompleksowym systemem PaaS (Platform as a Service), jak np. Heroku. Ponieważ Kubernetes działa na poziomie kontenera, a nie na poziomie sprzętowym, zapewnia pewne ogólnie stosowane funkcje popularne w rozwiązaniach rozwiązań PaaS, takie jak wdrażanie, skalowanie, równoważenie obciążenia, zbieranie logów i monitorowanie. Są one opcjonalne. Kubernetes nie jest monolityczny. Projekt kładzie duży nacisk na uniezależnienie każdego komponentu, aby mógł dostosować sie do każdego rodzaju projektu. --- * Nie ogranicza typów obsługiwanych aplikacji. * Nie wdraża z kodu źródłowego i nie buduje aplikacji. (CI/CD) * Nie zapewnia usług na poziomie aplikacji, ale ułatwia ich realizacje, takich jak: * nie zapewnia oprogramowanie pośrednie (np. szyny komunikatów ang. message buses) * nie zapewnia struktury przetwarzania danych (na przykład Spark) * nie zapewnia bazy danych (np. MySQL) * nie zapewnia pamięci podręczne ani systemy pamięci masowej w klastrze (np. Ceph) * Nie narzuca rozwiązań w zakresie rejestrowania dziennika, monitorowania ani ostrzegania. * Nie zapewnia konserwacji, zarządzania ani samonaprawiania się **maszyn**. --- # Architektura - Architektura ogólna - Architektura węzła głównego (ang. master/control plane) - Architektura węzła głównego (ang. node) --- ## Architektura ogólna ![](https://i.imgur.com/Hv92CgW.png) --- ## Architektura Control Plane ![](https://i.imgur.com/4zlIGa6.png) --- ## Architektura Node ![](https://i.imgur.com/47nK76k.png) --- # Podstawowe pojęcia --- ## Obiekty Kubernetes Obiekty Kubernetes są trwałymi bytami w systemie Kubernetes. Kubernetes używa tych jednostek do reprezentowania stanu twojego klastra. M.in. mogą opisać: * Jakie aplikacje w kontenerze są uruchomione * Zasoby dostępne dla tych aplikacji * Zasady dotyczące zachowania tych aplikacji Obiekt Kubernetes jest „zapisem intencji” - po utworzeniu obiektu system Kubernetes będzie stale monitorować, aby upewnić się, że obiekt istnieje. Aby pracować z obiektami Kubernetes - czy je tworzyć, modyfikować, czy usuwać - musisz użyć interfejsu API Kubernetes. Można też wykorzystać program `kubectl`, który wykorzystuje te API. --- ### Struktura W pliku ``.yaml`` dla obiektu Kubernetes, który chcesz utworzyć, musisz ustawić wartości dla następujących pól: * `apiVersion` - wymagana wersja API * `kind` - rodzaj obiektu * `metadane` - Dane, które pomagają jednoznacznie zidentyfikować obiekt, w tym ciąg nazwy, identyfikator UID i etykiety * `spec` - specyfikacja obiektu Dodatkowo obiekty mogą zawierać pole: ``status``. --- ### Pod Pod jest podstawową jednostką wykonawczą aplikacji Kubernetes - najmniejszą i najprostszą jednostką w modelu obiektowym Kubernetes, którą tworzysz lub wdrażasz. Pod reprezentuje procesy uruchomione w klastrze. Pod może zawierać wiele opcji np. obrazy, zasady rozmieszczania wezłów. --- ![](https://i.imgur.com/C8Y23vj.png) --- ```yaml apiVersion: core/v1 kind: Pod metadata: name: my-awesome-app spec: containers: - name: master image: my-awesome-app resources: requests: cpu: 100m memory: 100Mi ports: - containerPort: 6379 ``` ``` kubectl apply -f my-awesome-app.yaml ``` --- # Kontrollery W Kubernetes kontrolery są pętlami kontrolnymi, które obserwują stan klastra, a następnie wprowadzają lub żądają zmian w razie potrzeby. Każdy kontroler próbuje przenieść bieżący stan klastra bliżej pożądanego stanu. Nie jest zalecane tworzenie podów samodzielne, ale lepiej skorzystać z specjalistycznego kontrolera. --- # Typy kontrollerów **ReplicaSet**, domyślnie, jest stosunkowo prostym typem. Zapewnia, że działa określona liczba podów **Deployment** to deklaratywny sposób zarządzania podami za pośrednictwem **ReplicaSets**. Obejmuje mechanizmy wycofywania i aktualizacji (ang. rollback and rolling update mechanisms) **Daemonset** to sposób na zapewnienie, że każdy węzeł uruchomi instancję zasobnika. Służy do usług klastrowych, takich jak monitorowanie kondycji i przekazywanie dzienników (ang. monitoring and logging). **StatefulSet** jest dostosowany do zarządzania pod, które muszą utrzymywać lub utrzymywać stan. **Job** i **CronJob** uruchamiają krótkotrwałe zadania jednorazowo lub zgodnie z harmonogramem. --- ```yaml apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment labels: app: nginx spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80 ``` --- # Kubernetes jest rozszerzalny * PrometheusOperator - zapewnia lepsze mechanizmy monitoringu * GitLab CI - może wykorzystywac Kubernetes do uruchamiania zadań z CI * Knative - pozwala na automatyczne skalowanie podów na podstawie ilości ruchu HTTP/TCP, w tym od zera. * AirflowOperator - pozwala na zainstalowanie aplikacji Airflow i zarządzanie jej w sposób deklaratywny * MySqlOperator - pozwala na automatyczne zarządzanie bazą MySQL, w tym tworzy kopie zapasowe, przywraca, realizuje kopie zapasowe. * CertManager - zarządza certyfikatami, a następnie udostepnia je dla innych kontenerów * Config Connector - pozwala na zarządzanie zasobami w chmurze GCP, a takżę zapewnia do nich połączenie i autoryzacje z nimi np. Cloud SQL * Istio - zapewnia rozbudowane mechanizmy kontroli sieci i ruchu sieciowego --- # Pets vs Cattle Dawniej traktowaliśmy nasze serwery jak Zwierzęta domowe, na przykład Bob - serwer pocztowy. Jeśli Bob ulega awaria, wszystko pada. Współcześnie serwery są numerowane, jak bydło w stadzie. Na przykład od www001 do www100. Kiedy jeden serwer przestaje działać, jest usuwany z klastra, i w zamian dodawany jest nowy. Zwierzęta są niezwykle ważne, ale bydło jest wymienne. Przeniesienie infrastruktury oprogramowania produkcyjnego ze zwierząt domowych na bydło jest kluczem do stworzenia systemu o wysokiej dostępności (HA) o zmniejszonej liczbie awarii, mniejszym promieniu rażenia awari i szybszym odzyskiwaniu po awarii. --- # Jak użyć? Każdy duży dostawca chmurowy posiada możliwość utworzenie klastra Kubernetowego(GCP, AWS, Oracle. Dla studentów korzystne może być skorzystanie z Gogole Cloud Platform, ponieważ oferują 300$/rok za darmo. ``` gcloud container clusters create [CLUSTER_NAME] \ --zone [COMPUTE_ZONE] \ --release-channel stable \ --machine-type n1-standard-1 \ --num-nodes [NUM_NODES] ``` Możliwe jest tworzenie również klastra

    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