Skip to content

Instantly share code, notes, and snippets.

@vincentpaca
Last active August 29, 2015 14:05
Show Gist options
  • Save vincentpaca/aa85973ec9c95c61eda1 to your computer and use it in GitHub Desktop.
Save vincentpaca/aa85973ec9c95c61eda1 to your computer and use it in GitHub Desktop.
Deis and Google Cloud Compute Engine integration

fleetctl v0.7.1 fleet v0.7.1 deis v0.11.0

Setting Up Google Cloud utilities

  1. Install the gcloud utility by running curl https://sdk.cloud.google.com | bash
  2. Follow the steps.
    • If using zsh, edit your .zshrc file near the bottom and find the lines that were added by the] gcloud util install. Replace path.bash.inc with path.zsh.inc, do the same with completion.

      # The next line updates PATH for the Google Cloud SDK.
      source '~/google-cloud-sdk/path.zsh.inc'
      
      # The next line enables bash completion for gcloud.
      source '~/google-cloud-sdk/completion.zsh.inc'
      

gcloud Auth

  1. run gcloud auth login to authorize your account. Follow the wizard.
  2. Set the default project. In our case it's fourth-blend-666 (don't ask.) so the command would be gcloud config set project fourth-blend-666

Deis Setup

  1. clone deis git clone https://github.com/deis/deis.git
  2. cd inside deis/contrib/gce/ and run ./create-gce-user-data $(curl -s https://discovery.etcd.io/new) This will create gce-user-data inside the directory. I'm pretty sure we only need one gce-user-data and just have it shared for everyone but I'm not too sure

Cluster Setup

Clusters are group of hosts that Deis uses to run jobs and distribute applications. In our instance, our clusters are located inside Google Cloud Engine.

Create Disks

gcloud compute disks create "$env-disk$num" \
--zone asia-east1-b \
--size 100GB

or create disks via the Google Compute dashboard

Documentation

Launch Instances

We then launch instances using the latest CoreOS version. We can check for the latest CoreOS version using gcloud compute images list.

For one instance:

gcloud compute instances create "$env-instance$num" \
--image https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images/coreos-alpha-410-0-0-v20140818 \
--boot-disk-device-name "$env-boot$num" \
--boot-disk-size 10GB \
--disk name="$env-disk$num" \
--machine-type n1-standard-2 \
--metadata-from-file user-data=gce-user-data sshKey=~/.ssh/deis.pub \
--zone asia-east1-b \
--tags staging

Load Balancing

Create a new health check

gcloud compute http-health-checks create basic-check --request-path /health-check

Add new target pools

gcloud compute target-pools create staging-asia --health-check basic-check --region asia-east1

Assign instances to target pools

gcloud compute target-pools add-instances staging-asia --instances staging-instance1 staging-instance2 --zone asia-east1-b

Add a forwarding rule

gcloud compute forwarding-rules create staging-asia --target-pool staging-asia staging-us  --region asia-east1

Set firewall

gcloud compute firewall-rules create staging-firewall --target-tags staging --allow tcp:80 tcp:2222

Deleting and adding new machines

Deleting

When deleting an existing machine, that is already part of the Deis cluster, the cluster apparently fails.

The solution is to run DEIS_NUM_INSTANCES=3 DEIS_NUM_ROUTERS=3 make run again to reboot the services.

  • How often do we delete servers though?
  • If this is critical, then we should find a way how to delete machines in a cluster silently.

Adding new servers

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