Skip to content

Instantly share code, notes, and snippets.

@ptsurbeleu
Last active September 1, 2017 17:33
Show Gist options
  • Save ptsurbeleu/c14466b91636eec7d42d74775fd7e459 to your computer and use it in GitHub Desktop.
Save ptsurbeleu/c14466b91636eec7d42d74775fd7e459 to your computer and use it in GitHub Desktop.
Hand-crafted cloud-config.yml to co-locate Kontena Master & The Only Initial Node on the same Packet server
#cloud-config
write_files:
- path: /etc/kontena-server.env
permissions: 0600
owner: root
content: |
KONTENA_VERSION=latest
KONTENA_VAULT_KEY=ghV5TK5yl4zsfJlW4sWuhdPMc1ngLFAOzDYJwTSnjQpK096VWwDcTD5BKrV0ZyNZ
KONTENA_VAULT_IV=usPWA6tbnzdt0sjZI0eYFVaqZgk4pgQqOlPxrpGkOJcv9yHTRhpMW5N3ugKp7wHe
KONTENA_INITIAL_ADMIN_CODE=CoreOS999
SSL_CERT="/etc/kontena-server.pem"
- path: /opt/bin/kontena-haproxy.sh
permissions: 0755
owner: root
content: |
#!/bin/sh
if [ -n "$SSL_CERT" ]; then
SSL_CERT=$(awk 1 ORS='\\n' $SSL_CERT)
else
SSL_CERT="**None**"
fi
/usr/bin/docker run --name=kontena-server-haproxy \
--link kontena-server-api:kontena-server-api \
-e SSL_CERT="$SSL_CERT" -e BACKEND_PORT=9292 \
-p 8080:80 -p 443:443 kontena/haproxy:latest
- path: /etc/kontena-agent.env
permissions: 0600
owner: root
content: |
KONTENA_URI="http://$public_ipv4:8080"
KONTENA_TOKEN="YeNSe69as33PVhfFT1ywv5IxjRpO5WJ6TQj3mSD8BHV/Xx/zeqFspeMKHPOdakifdN2DjIkMf0J2PDftfCrRDw=="
KONTENA_PEER_INTERFACE=eth1
KONTENA_VERSION=latest
KONTENA_PRIVATE_IP=$private_ipv4
- path: /etc/systemd/system/docker.service.d/50-kontena.conf
content: |
[Service]
Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/16" --bip="172.17.43.1/16"'
- path: /etc/sysctl.d/99-inotify.conf
owner: root
permissions: 0644
content: |
fs.inotify.max_user_instances = 8192
- path: /etc/resolv.conf
permissions: 0644
owner: root
content: |
nameserver 172.17.43.1
nameserver 8.8.8.8
nameserver 8.8.4.4
coreos:
units:
- name: kontena-server-mongo.service
command: start
enable: true
content: |
[Unit]
Description=kontena-server-mongo
After=network-online.target
After=docker.service
Description=Kontena Server MongoDB
Documentation=http://www.mongodb.org/
Requires=network-online.target
Requires=docker.service
[Service]
Restart=always
RestartSec=5
ExecStartPre=/usr/bin/docker pull mongo:3.0
ExecStartPre=-/usr/bin/docker create --name=kontena-server-mongo-data mongo:3.0
ExecStartPre=-/usr/bin/docker stop kontena-server-mongo
ExecStartPre=-/usr/bin/docker rm kontena-server-mongo
ExecStart=/usr/bin/docker run --name=kontena-server-mongo \
--volumes-from=kontena-server-mongo-data \
mongo:3.0 mongod --smallfiles
ExecStop=/usr/bin/docker stop kontena-server-mongo
- name: kontena-server-api.service
command: start
enable: true
content: |
[Unit]
Description=kontena-server-api
After=network-online.target
After=docker.service
Description=Kontena Agent
Documentation=http://www.kontena.io/
Requires=network-online.target
Requires=docker.service
[Service]
Restart=always
RestartSec=5
EnvironmentFile=/etc/kontena-server.env
ExecStartPre=-/usr/bin/docker stop kontena-server-api
ExecStartPre=-/usr/bin/docker rm kontena-server-api
ExecStartPre=/usr/bin/docker pull kontena/server:${KONTENA_VERSION}
ExecStart=/usr/bin/docker run --name kontena-server-api \
--link kontena-server-mongo:mongodb \
-e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
-e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
-e INITIAL_ADMIN_CODE=${KONTENA_INITIAL_ADMIN_CODE} \
kontena/server:${KONTENA_VERSION}
ExecStop=/usr/bin/docker stop kontena-server-api
- name: kontena-server-haproxy.service
command: start
enable: true
content: |
[Unit]
Description=kontena-server-haproxy
After=network-online.target
After=docker.service
Description=Kontena Server HAProxy
Documentation=http://www.kontena.io/
Requires=network-online.target
Requires=docker.service
[Service]
Restart=always
RestartSec=5
EnvironmentFile=/etc/kontena-server.env
ExecStartPre=-/usr/bin/docker stop kontena-server-haproxy
ExecStartPre=-/usr/bin/docker rm kontena-server-haproxy
ExecStartPre=/usr/bin/docker pull kontena/haproxy:latest
ExecStart=/opt/bin/kontena-haproxy.sh
ExecStop=/usr/bin/docker stop kontena-server-haproxy
- name: etcd2.service
command: start
enable: true
content: |
Description=etcd 2.0
After=docker.service
[Service]
Restart=always
RestartSec=5
ExecStart=/usr/bin/docker logs --tail=10 -f kontena-etcd
- name: 50-docker.network
mask: true
- name: 50-docker-veth.network
mask: true
- name: zz-default.network
mask: true
- name: kontena-agent.service
command: start
enable: true
content: |
[Unit]
Description=kontena-agent
After=network-online.target
After=docker.service
Description=Kontena Agent
Documentation=http://www.kontena.io/
Requires=network-online.target
Requires=docker.service
[Service]
Restart=always
RestartSec=5
EnvironmentFile=/etc/kontena-agent.env
ExecStartPre=-/usr/bin/docker stop kontena-agent
ExecStartPre=-/usr/bin/docker rm kontena-agent
ExecStartPre=/usr/bin/docker pull kontena/agent:${KONTENA_VERSION}
ExecStart=/usr/bin/docker run --name kontena-agent \
-e KONTENA_URI=${KONTENA_URI} \
-e KONTENA_TOKEN=${KONTENA_TOKEN} \
-e KONTENA_PEER_INTERFACE=${KONTENA_PEER_INTERFACE} \
-e KONTENA_PRIVATE_IP=${KONTENA_PRIVATE_IP} \
-v=/var/run/docker.sock:/var/run/docker.sock \
-v=/etc/kontena-agent.env:/etc/kontena.env \
--net=host \
kontena/agent:${KONTENA_VERSION}
@ptsurbeleu
Copy link
Author

ptsurbeleu commented Aug 24, 2017

New values for settings keys, such as KONTENA_VAULT_KEY and KONTENA_VAULT_IV can be generated using cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1 command.

You also might want to change KONTENA_INITIAL_ADMIN_CODE with something else that is closer to your heart.

You also might want to change KONTENA_TOKEN with some other randomly generated value.

Also note, that Kontena Master in this configuration is available on port 8080 (http) while Kontena LB can be scheduled on port 80 (http) just as you would like it to be in a standard configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment