coreos
Workshop
Created by
Andreas Grohmann
/
andreas.grohmann@gmx.de
/
twitter.com/grohmeo
# coreos * [motivation](#/2) * [overview](#/3) * [getting started](#/4)
## motivation * where should i host my containers?
### facts * lightweight os * no package manager * everything runs in containers * automatically updated without administration
### benefits * lightweight os * designed for clustered deployments * automation * security * scalability
getting started
create a droplet in DigitalOcean
www.digitalocean.com
### install docker-compose ``` $ sudo su - $ mkdir /opt/ $ mkdir /opt/bin $ curl -L \ https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` \ > /opt/bin/docker-compose $ chmod +x /opt/bin/docker-compose $ exit ``` * [check for latest version](https://github.com/docker/compose/releases)
### create swapon service (512 MB RAM) ``` $ sudo vi /etc/systemd/system/swap.service ``` press i for insert mode, insert following ``` [Unit] Description=Turn on swap [Service] Type=oneshot Environment="SWAP_PATH=/var/vm" "SWAP_FILE=swapfile1" ExecStartPre=-/usr/bin/rm -rf ${SWAP_PATH} ExecStartPre=/usr/bin/mkdir -p ${SWAP_PATH} ExecStartPre=/usr/bin/touch ${SWAP_PATH}/${SWAP_FILE} ExecStartPre=/bin/bash -c "fallocate -l 1024m ${SWAP_PATH}/${SWAP_FILE}" ExecStartPre=/usr/bin/chmod 600 ${SWAP_PATH}/${SWAP_FILE} ExecStartPre=/usr/sbin/mkswap ${SWAP_PATH}/${SWAP_FILE} ExecStartPre=/usr/sbin/sysctl vm.swappiness=10 ExecStart=/sbin/swapon ${SWAP_PATH}/${SWAP_FILE} ExecStop=/sbin/swapoff ${SWAP_PATH}/${SWAP_FILE} ExecStopPost=-/usr/bin/rm -rf ${SWAP_PATH} RemainAfterExit=true [Install] WantedBy=multi-user.target ``` press "Esc" and enter ":wq"
enable service ``` $ sudo systemctl enable --now /etc/systemd/system/swap.service ``` reboot ``` $ sudo reboot ``` check after reboot ``` $ free ```
### generate a service generate service file ``` $ sudo vi /etc/systemd/system/YOUR-SERVICE-NAME.service ``` press i for insert mode, insert following ``` [Unit] Description=InterestService After=docker.service Requires=docker.service [Service] # environment vars secrets TimeoutStartSec=0 ExecStart=/opt/bin/docker-compose --file /srv/YOUR-PATH/docker-compose.yml up -d [Install] WantedBy=multi-user.target ``` press "Esc" and enter ":wq"
enable service ``` $ sudo systemctl enable --now /etc/systemd/system/YOUR-SERVICE-NAME.service ``` start service ``` $ sudo systemctl start YOUR-SERVICE-NAME ``` check status of service ``` $ systemctl status YOUR-SERVICE-NAME.service ``` after changing service ``` $ sudo systemctl daemon-reload ```
## start hacking in coreos
Questions?