github.com/spg/deis@v1.7.3/contrib/coreos/user-data.example (about)

     1  #cloud-config
     2  ---
     3  coreos:
     4    etcd:
     5      # generate a new token for each unique cluster from https://discovery.etcd.io/new
     6      # uncomment the following line and replace it with your discovery URL
     7      # discovery: https://discovery.etcd.io/12345693838asdfasfadf13939923
     8      addr: $private_ipv4:4001
     9      peer-addr: $private_ipv4:7001
    10      # give etcd more time if it's under heavy load - prevent leader election thrashing
    11      peer-election-timeout: 2000
    12      # heartbeat interval should ideally be 1/4 or 1/5 of peer election timeout
    13      peer-heartbeat-interval: 500
    14    fleet:
    15      # We have to set the public_ip here so this works on Vagrant -- otherwise, Vagrant VMs
    16      # will all publish the same private IP. This is harmless for cloud providers.
    17      public-ip: $private_ipv4
    18      # allow etcd to slow down at times
    19      etcd_request_timeout: 3.0
    20    units:
    21    - name: etcd.service
    22      command: start
    23    - name: docker-tcp.socket
    24      command: start
    25      enable: true
    26      content: |
    27        [Unit]
    28        Description=Docker Socket for the API
    29  
    30        [Socket]
    31        ListenStream=2375
    32        BindIPv6Only=both
    33        Service=docker.service
    34        [Install]
    35        WantedBy=sockets.target
    36    - name: stop-update-engine.service
    37      command: start
    38      content: |
    39        [Unit]
    40        Description=stop update-engine
    41  
    42        [Service]
    43        Type=oneshot
    44        ExecStart=/usr/bin/systemctl stop update-engine.service
    45        ExecStartPost=/usr/bin/systemctl mask update-engine.service
    46    - name: graceful-deis-shutdown.service
    47      content: |
    48        [Unit]
    49        Description=Clean up
    50        DefaultDependencies=no
    51        After=fleet.service etcd.service docker.service docker.socket deis-store-admin.service deis-store-daemon.service deis-store-volume.service deis-store-monitor.service
    52        Requires=fleet.service etcd.service deis-store-admin.service deis-store-daemon.service deis-store-volume.service docker.service docker.socket deis-store-monitor.service
    53  
    54        [Install]
    55        WantedBy=shutdown.target halt.target reboot.target
    56  
    57        [Service]
    58        ExecStop=/opt/bin/graceful-shutdown.sh --really
    59        Type=oneshot
    60        TimeoutSec=1200
    61        RemainAfterExit=yes
    62    - name: install-deisctl.service
    63      command: start
    64      content: |
    65        [Unit]
    66        Description=Install deisctl utility
    67        ConditionPathExists=!/opt/bin/deisctl
    68  
    69        [Service]
    70        Type=oneshot
    71        ExecStart=/usr/bin/sh -c 'curl -sSL --retry 5 --retry-delay 2 http://deis.io/deisctl/install.sh | sh -s 1.7.3'
    72    - name: debug-etcd.service
    73      content: |
    74        [Unit]
    75        Description=etcd debugging service
    76  
    77        [Service]
    78        ExecStartPre=/usr/bin/curl -sSL -o /opt/bin/jq http://stedolan.github.io/jq/download/linux64/jq
    79        ExecStartPre=/usr/bin/chmod +x /opt/bin/jq
    80        ExecStart=/usr/bin/bash -c "while true; do curl -sL http://127.0.0.1:4001/v2/stats/leader | /opt/bin/jq . ; sleep 1 ; done"
    81    - name: increase-nf_conntrack-connections.service
    82      command: start
    83      content: |
    84        [Unit]
    85        Description=Increase the number of connections in nf_conntrack. default is 65536
    86  
    87        [Service]
    88        Type=oneshot
    89        ExecStartPre=/usr/sbin/modprobe nf_conntrack
    90        ExecStart=/bin/sh -c "sysctl -w net.netfilter.nf_conntrack_max=262144"
    91    - name: load-overlay-module.service
    92      command: start
    93      content: |
    94        [Unit]
    95        Description=Load overlay module before docker start
    96        Before=docker.service
    97  
    98        [Service]
    99        ExecStart=/bin/bash -c "lsmod | grep overlay || modprobe overlay"
   100    - name: fleet.service
   101      command: start
   102  write_files:
   103    - path: /etc/deis-release
   104      content: |
   105        DEIS_RELEASE=v1.7.3
   106    - path: /etc/motd
   107      content: " \e[31m* *    \e[34m*   \e[32m*****    \e[39mddddd   eeeeeee iiiiiii   ssss\n\e[31m*   *  \e[34m* *  \e[32m*   *     \e[39md   d   e    e    i     s    s\n \e[31m* *  \e[34m***** \e[32m*****     \e[39md    d  e         i    s\n\e[32m*****  \e[31m* *    \e[34m*       \e[39md     d e         i     s\n\e[32m*   * \e[31m*   *  \e[34m* *      \e[39md     d eee       i      sss\n\e[32m*****  \e[31m* *  \e[34m*****     \e[39md     d e         i         s\n  \e[34m*   \e[32m*****  \e[31m* *      \e[39md    d  e         i          s\n \e[34m* *  \e[32m*   * \e[31m*   *     \e[39md   d   e    e    i    s    s\n\e[34m***** \e[32m*****  \e[31m* *     \e[39mddddd   eeeeeee iiiiiii  ssss\n\n\e[39mWelcome to Deis\t\t\tPowered by Core\e[38;5;45mO\e[38;5;206mS\e[39m\n"
   108    - path: /etc/profile.d/nse-function.sh
   109      permissions: '0755'
   110      content: |
   111        function nse() {
   112          docker exec -it $1 bash
   113        }
   114    - path: /etc/systemd/system/docker.service.d/50-insecure-registry.conf
   115      content: |
   116          [Service]
   117          EnvironmentFile=/etc/environment_proxy
   118          Environment="DOCKER_OPTS=--insecure-registry 10.0.0.0/8 --insecure-registry 172.16.0.0/12 --insecure-registry 192.168.0.0/16 --insecure-registry 100.64.0.0/10"
   119    - path: /run/deis/bin/get_image
   120      permissions: '0755'
   121      content: |
   122        #!/bin/bash
   123        # usage: get_image <component_path>
   124        IMAGE=`etcdctl get $1/image 2>/dev/null`
   125  
   126        # if no image was set in etcd, we use the default plus the release string
   127        if [ $? -ne 0 ]; then
   128          RELEASE=`etcdctl get /deis/platform/version 2>/dev/null`
   129  
   130          # if no release was set in etcd, use the default provisioned with the server
   131          if [ $? -ne 0 ]; then
   132            source /etc/deis-release
   133            RELEASE=$DEIS_RELEASE
   134          fi
   135  
   136          IMAGE=$1:$RELEASE
   137        fi
   138  
   139        # remove leading slash
   140        echo ${IMAGE#/}
   141    - path: /run/deis/bin/preseed
   142      permissions: '0755'
   143      content: |
   144        #!/bin/bash
   145  
   146        COMPONENTS=(builder cache controller database logger logspout publisher registry router store-daemon store-gateway store-metadata store-monitor)
   147        for c in "${COMPONENTS[@]}"; do
   148          image=`/run/deis/bin/get_image /deis/$c`
   149          docker history $image >/dev/null 2>&1 || docker pull $image
   150        done
   151    - path: /opt/bin/deis-debug-logs
   152      permissions: '0755'
   153      content: |
   154        #!/bin/bash
   155  
   156        echo '--- VERSIONS ---'
   157        source /etc/os-release
   158        echo $PRETTY_NAME
   159        source /etc/deis-release
   160        echo "Deis $DEIS_RELEASE"
   161        etcd -version
   162        fleet -version
   163        printf "\n"
   164  
   165        echo '--- SYSTEM STATUS ---'
   166        journalctl -n 50 -u etcd --no-pager
   167        journalctl -n 50 -u fleet --no-pager
   168        printf "\n"
   169  
   170        echo '--- DEIS STATUS ---'
   171        deisctl list
   172        etcdctl ls --recursive /deis
   173        printf "\n"
   174    - path: /home/core/.toolboxrc
   175      owner: core
   176      content: |
   177        TOOLBOX_DOCKER_IMAGE=alpine
   178        TOOLBOX_DOCKER_TAG=3.1
   179        TOOLBOX_USER=root
   180    - path: /etc/environment_proxy
   181      owner: core
   182      content: |
   183        HTTP_PROXY=
   184        HTTPS_PROXY=
   185        ALL_PROXY=
   186        NO_PROXY=
   187        http_proxy=
   188        https_proxy=
   189        all_proxy=
   190        no_proxy=
   191    - path: /etc/systemd/coredump.conf
   192      content: |
   193        [Coredump]
   194        Storage=none
   195    - path: /opt/bin/graceful-shutdown.sh
   196      permissions: '0755'
   197      content: |
   198        #!/usr/bin/bash
   199        if [ "$1" != '--really' ]; then
   200          echo "command must be run as: $0 --really"
   201          exit 1
   202        fi
   203        # procedure requires the store-admin
   204        ADMIN_RUNNING=$(docker inspect --format="{{ .State.Running }}" deis-store-admin)
   205        if [ $? -eq 1 ] || [ "$ADMIN_RUNNING" == "false" ]; then
   206          echo "deis-store-admin container is required for graceful shutdown"
   207          exit 2
   208        fi
   209        set -e -x -o pipefail
   210        # determine osd id
   211        CURRENT_STATUS=$(/usr/bin/docker exec deis-store-admin ceph health | awk '{print $1}')
   212        OSD_HOSTS=($(/usr/bin/etcdctl ls /deis/store/hosts/| awk -F'/' '{print $5}'))
   213        for HOST in "${OSD_HOSTS[@]}"
   214        do
   215          PUBLIC_IP=$(fleetctl list-machines -fields="machine,ip" -full -no-legend| grep `cat /etc/machine-id` | awk '{print $2}')
   216          if [ "$HOST" = "$PUBLIC_IP" ] ; then
   217            OSD_ID=$(/usr/bin/etcdctl get /deis/store/osds/$PUBLIC_IP)
   218            break
   219          fi
   220        done
   221        # if we own an osd and its healthy, try to gracefully remove it
   222        if [ ! -z "$OSD_ID" ] && [[ "$CURRENT_STATUS" == *"HEALTH_OK"* ]] && [ ${#OSD_HOSTS[@]} -gt "3" ]; then
   223          /usr/bin/docker exec deis-store-admin ceph osd out $OSD_ID
   224          sleep 30
   225          TIMEWAITED=0
   226          until [[ $(/usr/bin/docker exec deis-store-admin ceph health) == *"HEALTH_OK"* ]]
   227          do
   228            if [ $TIMEWAITED -gt "1200" ]
   229            then
   230              echo "ceph graceful removal timeout exceeded"
   231              break
   232            fi
   233            echo "waiting" && sleep 5
   234            TIMEWAITED=$((TIMEWAITED+5))
   235          done
   236          /usr/bin/docker stop deis-store-daemon
   237          /usr/bin/docker exec deis-store-admin ceph osd crush remove osd.$OSD_ID
   238          /usr/bin/docker exec deis-store-admin ceph auth del osd.$OSD_ID
   239          /usr/bin/docker exec deis-store-admin ceph osd rm $OSD_ID
   240          /usr/bin/etcdctl rm /deis/store/osds/$PUBLIC_IP
   241          etcdctl rm /deis/store/hosts/$PUBLIC_IP && sleep 10
   242          # remove ceph mon
   243          /usr/bin/docker stop deis-store-monitor || true
   244          /usr/bin/docker exec deis-store-admin ceph mon remove `hostname -f` # fixme
   245          /usr/bin/docker stop deis-store-metadata || true
   246        fi
   247        NODE=$(curl -L http://127.0.0.1:7001/v2/admin/machines/`cat /etc/machine-id`)
   248        # remove from etcd cluster
   249        if [ $NODE != 'null' ]; then
   250          /usr/bin/curl -L -XDELETE http://127.0.0.1:7001/v2/admin/machines/`cat /etc/machine-id`
   251        fi
   252  manage_etc_hosts: localhost