summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2014-09-22 16:19:19 -0700
committerJhon Honce <jhonce@redhat.com>2014-09-24 09:26:57 -0700
commit3d57c7e4d02e8b769b8bb4b527a95fa819b77749 (patch)
treec8698eaf54304a1f9843909076bbc6c14bf3463b
parent5994dee9a8b3b1ee97f9e3b3529fd32ffb896187 (diff)
downloadopenshift-3d57c7e4d02e8b769b8bb4b527a95fa819b77749.tar.gz
openshift-3d57c7e4d02e8b769b8bb4b527a95fa819b77749.tar.bz2
openshift-3d57c7e4d02e8b769b8bb4b527a95fa819b77749.tar.xz
openshift-3d57c7e4d02e8b769b8bb4b527a95fa819b77749.zip
WIP Infra - Support for multiple GCE projects
* Add support in cloud.rb for reading configuration * Add support for docker-registry pod
-rw-r--r--README_GCE.txt3
-rwxr-xr-xcloud.rb45
-rw-r--r--roles/kubernetes_kubelet/files/registry-service.json10
-rw-r--r--roles/pods/files/pods/docker-registry.json30
4 files changed, 74 insertions, 14 deletions
diff --git a/README_GCE.txt b/README_GCE.txt
index b2f6aec21..3848778a1 100644
--- a/README_GCE.txt
+++ b/README_GCE.txt
@@ -5,6 +5,9 @@ Get a gce service key
---------------------
1. ping twiest and ask for a GCE service key
+Note: If your GCE project doesn't show a Service Account under <Project>/APIs & auth/Credentials, you will need to use "Create new
+Client ID" to create a Service Account.
+
Convert a GCE service key into a pem (for ansible)
--------------------------------------------------
diff --git a/cloud.rb b/cloud.rb
index cc23a7290..8f53b9460 100755
--- a/cloud.rb
+++ b/cloud.rb
@@ -5,6 +5,7 @@ require 'json'
require 'yaml'
require 'securerandom'
require 'fileutils'
+require 'parseconfig'
SCRIPT_DIR = File.expand_path(File.dirname(__FILE__))
@@ -111,22 +112,26 @@ module OpenShift
cmds = []
+ #cmds << 'set -x'
cmds << %Q[export ANSIBLE_FILTER_PLUGINS="#{Dir.pwd}/filter_plugins"]
# We need this for launching instances, otherwise conflicting keys and what not kill it
cmds << %q[export ANSIBLE_TRANSPORT="ssh"]
- cmds << %Q[export ANSIBLE_SSH_ARGS="-o ForwardAgent=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"]
+ cmds << %q[export ANSIBLE_SSH_ARGS="-o ForwardAgent=yes -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"]
# We need pipelining off so that we can do sudo to enable the root account
cmds << %Q[export ANSIBLE_SSH_PIPELINING='#{@pipelining.to_s}']
- ssh_key_arg = "--private-key=~/.ssh/mmcgrath_libra" if File.file?(ENV['HOME']+'/.ssh/mmcgrath_libra.pem')
+ ssh_key_arg = %q[--private-key=~/.ssh/mmcgrath_libra] if File.file?(ENV['HOME']+'/.ssh/mmcgrath_libra.pem')
cmds << %Q[time -p ansible-playbook -i #{@inventory} #{@verbosity} #{playbook} #{ssh_key_arg} --extra-vars '@#{tmpfile.path}']
cmd = cmds.join(' ; ')
- system(cmd)
+ unless system(cmd)
+ puts %Q[Following command failed with exit code: #{$?.exitstatus}\n#{cmd}]
+ puts %Q[extra_vars: #{@extra_vars.to_json}]
+ end
tmpfile.unlink
end
@@ -135,19 +140,31 @@ module OpenShift
@extra_vars.merge!(vars)
end
- def self.for_gce()
- ah = AnsibleHelper.new()
+ def self.for_gce
+ ah = AnsibleHelper.new
# GCE specific configs
- ah.extra_vars['gce_pem_file'] = "#{ENV['HOME']}/.ssh/os302gce_priv_key.pem"
- ah.extra_vars['gce_service_account_email'] = '198287808360-f457cs26hutqeosmlje1eosfeqo0krlg@developer.gserviceaccount.com'
- ah.extra_vars['gce_project_id'] = 'corded-cable-672'
+ gce_ini = "#{SCRIPT_DIR}/inventory/gce/gce.ini"
+ config = ParseConfig.new(gce_ini)
- ah.inventory = 'inventory/gce/gce.py'
+ if config['gce']['gce_project_id'].to_s.empty?
+ raise %Q['gce_project_id' not set in #{gce_ini}]
+ end
+ ah.extra_vars['gce_project_id'] = config['gce']['gce_project_id']
+
+ if config['gce']['gce_service_account_pem_file_path'].to_s.empty?
+ raise %Q['gce_service_account_pem_file_path' not set in #{gce_ini}]
+ end
+ ah.extra_vars['gce_pem_file'] = config['gce']['gce_service_account_pem_file_path']
+
+ if config['gce']['gce_service_account_email_address'].to_s.empty?
+ raise %Q['gce_service_account_email_address' not set in #{gce_ini}]
+ end
+ ah.extra_vars['gce_service_account_email'] = config['gce']['gce_service_account_email_address']
+ ah.inventory = 'inventory/gce/gce.py'
return ah
end
-
end
class GceCommand < Thor
@@ -181,10 +198,10 @@ module OpenShift
ah.extra_vars['oo_new_inst_tags'] << GceHelper.generate_env_host_type_tag(options[:env], options[:type])
puts
- puts "Creating instance(s) in GCE..."
+ puts 'Creating instance(s) in GCE...'
puts
- puts " .---- Disregard this (ansible bug 6407) ----."
- puts " V V"
+ puts %q[ .---- Spurious warning "It is unnecessary to use '{{' in loops" (ansible bug 6407) ----.]
+ puts %q[ V V]
ah.run_playbook("playbooks/gce/#{options[:type]}/launch.yml")
@@ -268,7 +285,7 @@ module OpenShift
else
cmd += " #{user}@"
end
-
+
if dest.nil?
download = File.join(Dir.pwd, 'download')
FileUtils.mkdir_p(download) unless File.exists?(download)
diff --git a/roles/kubernetes_kubelet/files/registry-service.json b/roles/kubernetes_kubelet/files/registry-service.json
new file mode 100644
index 000000000..96eaf261c
--- /dev/null
+++ b/roles/kubernetes_kubelet/files/registry-service.json
@@ -0,0 +1,10 @@
+{
+ "id": "dockerregistry",
+ "kind": "Service",
+ "apiVersion": "v1beta1",
+ "port": 8888,
+ "selector": {
+ "name": "docker-registry"
+ }
+}
+
diff --git a/roles/pods/files/pods/docker-registry.json b/roles/pods/files/pods/docker-registry.json
new file mode 100644
index 000000000..388a1015e
--- /dev/null
+++ b/roles/pods/files/pods/docker-registry.json
@@ -0,0 +1,30 @@
+{
+ "kind": "Pod",
+ "version": "v1beta1",
+ "desiredState": {
+ "manifest": {
+ "version": "v1beta1",
+ "containers": [{
+ "name": "docker-registry",
+ "image": "registry",
+ "volumeMounts": [{
+ "name": "data",
+ "mountPath": "/var/lib/docker-registry"
+ }],
+ "ports": [{
+ "containerPort": 5000,
+ "hostPort": 9999
+ }]
+ }],
+ "volumes": [{
+ "name": "data",
+ "source": {
+ "emptyDir": true
+ }
+ }]
+ }
+ },
+ "labels": {
+ "name": "docker-registry"
+ }
+}