zoukankan      html  css  js  c++  java
  • docker swarm+register-web+shipyard搭建

    1.swarm安装

    swarm安装有很多种服务注册的方式,token、etcd、zookeeper,本文主要以swarm默认的token方式进行安装。因为最新的docker已经集成了swarm,所以从安装docker开始,本文所用操作系统为ubuntu14.04。

              IP           name     service

    10.241.81.233 swarm-1  manage

    10.241.81.234 swarm-2  worker

    10.241.81.235 swarm-3  worker

    参考文档:https://store.docker.com/editions/community/docker-ce-server-ubuntu

    (1).set up the repository

    sudo apt-get -y install 
      apt-transport-https 
      ca-certificates 
      curl
    
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository 
           "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
           $(lsb_release -cs) 
           stable"
    sudo apt-get update

    (2)Install the latest version of Docker CE on Ubuntu:

    sudo apt-get -y install docker-ce

    (3)Run the following command to create a new swarm:

    (参考:https://docs.docker.com/engine/swarm/swarm-tutorial/create-swarm/)

    mananger:
    # docker swarm init --advertise-addr 10.241.81.233
    Swarm initialized: current node (cpds4fjp7vv6ttqm4y77vmhae) is now a manager.
    
    To add a worker to this swarm, run the following command:
    
    docker swarm join 
    --token SWMTKN-1-5gmmq1w6qsm2zm3wfjkx5at3j2a5mwy1k0qjfp16womwgkqeqj-4ttti9ppo6aqebuw4b1m46vo7 
    10.241.81.233:2377
    
    To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
    
    worker:
    docker swarm join 
    --token SWMTKN-1-5gmmq1w6qsm2zm3wfjkx5at3j2a5mwy1k0qjfp16womwgkqeqj-4ttti9ppo6aqebuw4b1m46vo7 
    10.241.81.233:2377

    在manage上执行docker node ls,查看node的状态:

    # docker node ls
    ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
    7gzxsm1kmzf92bz8tply3j6dj     swarm-2             Ready               Active              
    cpds4fjp7vv6ttqm4y77vmhae *   swarm-1             Ready               Active              Leader
    ejrnqul66xm1xy62ankhuhvn1     swarm-3             Ready               Active  

    2.安装register及register-web (参考:https://hub.docker.com/r/hyper/docker-registry-web/)

    docker run -itd --restart=always -p 5000:5000 --name registry-srv registry:2

    docker run -idt
    --restart=always -p 8090:8080 --name registry-web --link registry-srv -e REGISTRY_URL=http://10.241.81.233:5000/v2 -e REGISTRY_NAME=localhost:5000 

    可以访问register-web,http://10.241.81.233:8090。

    修改配置docker配置文件,在DOCKER_OPTS加入--insecure-registry=10.241.81.233:5000,我的原先为空,所以改后状态如下:

    # vi /etc/default/docker
    
    DOCKER_OPTS="--insecure-registry=10.241.81.233:5000"

    重启docker 就 可以往registerpush镜像了。

    3.shipyard安装方式有俩种,一种是脚本,一种是手动,这里选择的脚本安装。

    (参考:https://shipyard-project.com/docs/deploy/)

    shipyard界面:
    
    curl -sSL https://shipyard-project.com/deploy | bash -s

    然后访问 http://10.241.81.233:8080  就有界面了。

     如果需要加入新的节点:

    curl -sSL https://shipyard-project.com/deploy | ACTION=node DISCOVERY=etcd://10.241.81.233:4001 bash -s

    就能看到有多个节点了,如下图:

    也可把register加进去管理:

    整个安装部署到此就结束了,后续监控也可以用prometheus收集cadvisor监控swarm的集群状态。

  • 相关阅读:
    元素类型
    PS
    盒模型
    文本样式
    WebStorm、IntelliJ IDEA、JetBrains、PhpStorm、RubyMine、PyCharm
    微信iOS WKWebview 网页开发适配指南
    js取url参数
    windows 80 端口占用
    前端Demo常用库文件链接
    MAC下利用Github 、hexo、 多说、百度统计 建立个人博客指南
  • 原文地址:https://www.cnblogs.com/sfnz/p/6930376.html
Copyright © 2011-2022 走看看