Skip to content

Instantly share code, notes, and snippets.

@runeleaf
Created April 22, 2016 07:12
Show Gist options
  • Save runeleaf/b18e2463d005f6b89f45a7f29f97e320 to your computer and use it in GitHub Desktop.
Save runeleaf/b18e2463d005f6b89f45a7f29f97e320 to your computer and use it in GitHub Desktop.
権限>サービスアカウント>Compute Engine default service account>鍵を作成>jsonダウンロード>.ssh/google-compute-engine-xxxxxx.json
compute engine>メタデータ>SSHキー>公開鍵を追加
NW
ネットワーキング>ネットワーク>TODO
FW
ネットワーキング>ファイアーウォールルール>+ファイアーウォールを作成>80を許可
LB
ネットワーキング>負荷分散>TODO
DNS
ネットワーキング>CloudDNS>TODO
VPN
ネットワーキング>VPN
curl https://sdk.cloud.google.com | bash
gcloud auth login
(ブラウザ)
gcloud config set project my-project
gcloud compute instances list
vagrant-google(https://github.com/mitchellh/vagrant-google)
vagrant plugin install vagrant-google
vagrant box add gce https://github.com/mitchellh/vagrant-google/raw/master/google.box
vagrant init
vi Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "gce"
config.vm.provider :google do |google, override|
google.google_project_id = 'hoge-app'
google.google_client_email = 'xxxxxxxxxxxx'
google.google_json_key_location = '/path/to/.ssh/google-compute-engine-xxxxxx.json'
google.zone = 'asia-east1-a'
google.zone_config 'asia-east1-a' do |zone1a|
zone1a.name = 'gce-vagrant-001'
#zone1a.machine_type = 'n1-standard-1'
zone1a.machine_type = 'g1-small'
zone1a.zone = 'asia-east1-a'
zone1a.image = 'ubuntu-1404-trusty-v20160406'
#zone1a.disk_size = 10
zone1a.disk_type = 'pd-ssd'
#zone1a.disk_name = ''
#zone1a.instance_group = ''
end
override.ssh.username = 'vagrant'
override.ssh.private_key_path = '/path/to/.ssh/google_compute_engine'
end
#config.vm.provision :shell, path: 'init.sh'
# @todo :shell, 'ansible-playbook'
# rbenv ruby-build
config.vm.provision :shell, inline: <<-SHELL
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-get -y install vim vim-common git g++ make zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt-dev nginx zsh byobu language-pack-ja
sudo update-locale LANG=ja_JP.UTF-8
SHELL
end
git init
vi .gitignore
/*
!config
!.gitignore
!Vagrantfile
.DS_store
*~
vagrant up --provider=google
...
vagrant ssh
sudo su -
password vagrant
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# CoreOS+dockerでもよい
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment