Friday, October 2, 2015

moving a project from a single dedicated host to a CoreOS installation

After all that complaining I'm still going to try to move a project of mine from Rackspace to Digital Ocean and from Ubuntu to CoreOS.

Right now I have a single etcd server and a single worker. The worker will run three containers; database data volume container, postgres database container, wepapp container (python 2.7).

Get a discovery tokey

curl https://discovery.etcd.io/new?size=1

Create the etcd server:

#cloud-config

coreos:
  etcd2:
    # generate a new token for each unique cluster from https://discovery.etcd.io/new?size=3
    # specify the initial size of your cluster with ?size=X
    discovery: https://discovery.etcd.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    # multi-region and multi-cloud deployments need to use $public_ipv4
    advertise-client-urls: http://$private_ipv4:2379,http://$private_ipv4:4001
    initial-advertise-peer-urls: http://$private_ipv4:2380
    # listen on both the official ports and the legacy ports
    # legacy ports can be omitted if your application doesn't depend on them
    listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
    listen-peer-urls: http://$private_ipv4:2380
  fleet:
    metadata: "role=services"
  units:
    - name: etcd2.service
      command: start
    - name: fleet.service
      command: start
  update:
    # https://coreos.com/docs/cluster-management/setup/update-strategies/
    reboot-strategy: etcd-lock

Create the worker:

#cloud-config

coreos:
  etcd2:
    # use the same discovery token for the central service machines
    # make sure you have used the discovery token to bootstrap the 
    # central service successfully
    # this etcd will fallback to proxy automatically
    discovery: https://discovery.etcd.io/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    # listen on both the official ports and the legacy ports
    # legacy ports can be omitted if your application doesn't depend on them
    listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
  fleet:
    metadata: "role=worker"
    etcd_servers: "http://localhost:2379"
  locksmith:
    endpoint: "http://localhost:2379"
  units:
    - name: etcd2.service
      command: start
    - name: fleet.service
      command: start
  update:
    # https://coreos.com/docs/cluster-management/setup/update-strategies/
    reboot-strategy: etcd-lock

Create the data volume

docker run --name local-postgres9.4 -e POSTGRES_PASSWORD=password -d --volumes-from postgres9.4-data postgres:9.4

Create the database container

docker run -it --link local-postgres9.4:postgres --rm postgres:9.4 sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'

Create the psql container

docker run -it --link local-postgres9.4:postgres --rm postgres:9.4 sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'

What's next?

  • backup and restore the data from the original server
  • create a webapp container and connect to the db
  • create a vulcand container
  • create fleetctl service files and run
 

No comments:

Post a Comment

dead pixels

I have never had a dead pixel so when I read: Small numbers (1-3) of stuck or dead pixels are a characteristic of LCD screens. These are n...