идель ишбаев
    • 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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # DS-project1. Report ## Introduction The task is to create a cluster for deploying an application. The web application will be called **The Red Button**. The idea of the application: you will get a dilemma, you can agree on the condition and press the red button, or can skip it. Anyway you will get a statistic for this dilemma (number of people who agreed on the suggested condition and number of people who skipped). ## Understanding Docker-machine and Docker Swarm deployment **1.** *What is Docker-machine and what is it used for?* **Docker machine** - the tool to create a remote virtual machine (VM) easily and manage those containers. **It is used to** control docker engine of a virtual machine remotely. It allows to update docker engine, stop VM, view state. **2.** *What is Docker Swarm, what is it used for and why is it important in Containers Orchestration?* **Docker Swarm** is a group of virtual or physical machines that run Docker application and form together one cluster. **It is used for** container orchestration and to magane multiple containers in multiple machines. **It is important** because of its high level of availability offered for applications. It allow developers to manage high amount of nodes in a single ecosystem. **3.** - *Docker Machine, Master* *create master* ![](https://i.imgur.com/rT88Ors.png) **4.** - *Workers* *create workers* *1st worker* ![](https://i.imgur.com/Os5mdRG.png) *2nd worker* ![](https://i.imgur.com/uBM7kSG.png) ***docker-machine ls** - there are 3 running machines* ![](https://i.imgur.com/fadv4xN.png) *with this command we can get info about currently running machines, their ips and their state* ## Container Docker Cluster farm deployment **5.** *docker swarm* initialized on master node ![](https://i.imgur.com/51fTqdy.png) *by using the command from the output of creation swarm we join two more machines to that swarm as workers* ***docker node ls** - observe their states, how they are connected, and the leader - Master node** ![](https://i.imgur.com/lGQ9UOq.png) *Here we see, that we have one manager node and three workers - all are ready and active.* *We can use IPs of workers and master to get visualizer picture. On that step the main problem is that web service did not run* ![](https://i.imgur.com/RcQaPWB.png) *There is a problem that only master is involved* ![](https://i.imgur.com/LJhRzRF.png) *Correct visualization will be provided later* **6.** Docker can be promoted to Master when manager role becomes unavailable. Vice versa action can be done as well. It can be done with ``` docker node promote docker node demote ``` It can be done only on manager node. Because of the fact, that all machines are run on out machine, we can easily get into VMs via ssh and explicitly and initialize docker swarm on master machine. Also, we have option, that specify that if node is down docker should reboot it at that time. **7.** We can observe hostname and host node where web page is running and it spread across the server. ![](https://i.imgur.com/jVyi1Am.png) **8.** Yes it can not be done automatically. Docker Swarm does not support it. Scaling can be done manually with Docker CLI. ``` docker service scale <SERVICE-ID>=<NUMBER-OF-TASKS> ``` But, we can set value *replicas* in docker-compose for every service that we want to scale. # Docker Container migration - Application Distribution **9.** ![](https://i.imgur.com/jVyi1Am.png) ![](https://i.imgur.com/9OnHqCc.jpg) ![](https://i.imgur.com/Qd1dqfc.jpg) ![](https://i.imgur.com/kJYjJ2f.jpg) *We can obserce here that when node is goes down services that were in this node will be distributed to other nodes. And back again when the node will come back to live.* **10.** *Update in web-app* When some changes are made in the application we have to restart our container. **11.** It can be done with both CLI and GUI (example above). We can do ``` docker node ls ``` and as an example we can observe active nodes. # Playing with memory **12.** **OOME** it is when we do not have enough memory to run service. This issue will slow down the work of an application. With the help of Docker Swarm services will be distributed to another node from the one, which do not have enough memory. **13.** We have done it with putting in Docker Compose limite for CPU (15%). ![](https://i.imgur.com/ZuVQXEJ.jpg =450x450) ![](https://i.imgur.com/OPD14vH.jpg =250x200) # Compression **14.** ![](https://i.imgur.com/OPD14vH.jpg =250x200) *The limite of size of images are 50M* This size can be reduces by decreasing the calue of memory limite in docker compose. * Use a smaller base image. * Don't install debug tools like vim/curl. * Minimize Layers. * Use — no-install-recommends on apt-get install. * Add rm -rf /var/lib/apt/lists/* to same layer as apt-get installs. [web site with tips](https://hackernoon.com/tips-to-reduce-docker-image-sizes-876095da3b34) # Web application **15.** Owr web application - **the red button**: Used: * Flask * Python * Mongo * Html * Css * JS *The idea:* you will get an dilemma, you can agree on the condition and press **the red button**, or can skip it. Anyway you will get a statistic for this dilemma, number of people who agreed on the suggested condition and number of people who skipped. ![](https://i.imgur.com/jLPJ3al.png) ![](https://i.imgur.com/KqSunHc.png) ![](https://i.imgur.com/If3ZEVz.png) [GitHub repository](https://github.com/MaEvGoR/red_button_project.git) ## Conclusion We have learn the following things: we can start VM by ```docker-machine```; we can create clusters of machines by ```docker swarm``` which will distribute a load; we can set setting for deploying in docker compose. We have met the following difficulties: find out convenient properties to run services; to deal with diffrences between container, service, node, server, image and etc. ###### Maksim Evgrafov - BS-18-DS-01 ###### Idel Ishbaev - BS-18-SE-02

    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