I decided to use "fog" - the Ruby API for the Rackspace Cloud - to build something to let me, in one step, run commands on all of the servers. It turned out to be pretty straightforward.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
############################################# | |
# Ruby / Fog Cloud Server Command Runner | |
# | |
# Author: Paul Reiber reiber@gmail.com | |
# | |
# Usage: run commandline-to-run-on-all-servers | |
# | |
# Assumptions: | |
# * You are using the Rackspace Cloud | |
# * Your cloud servers are in the dfw datacenter (if not, fix the rackspace_region) | |
# * All servers on the cloud account have key-based root ssh access. | |
# ...if they don't have ssh key-based access here are the steps: | |
# http://www.rackspace.com/knowledge_center/article/secure-shell-ssh | |
# | |
# The 'oj' gem requirement is only there to eliminate the irritating warning about the default JSON parser | |
# | |
require 'rubygems' | |
require 'fog' | |
require 'pp' | |
require 'oj' | |
# populate the following with your correct username, api_key, and region details | |
service = Fog::Compute.new({ :provider => 'Rackspace', :version => :v2, | |
:rackspace_region => :dfw, :rackspace_username => 'YOUR-CLOUD-USERNAME', :rackspace_api_key => 'YOUR-CLOUD-API-KEY' }) | |
# running a command on all servers and reporting the results is as simple as the following: | |
service.servers.each {|n| puts n.name; pp n.ssh [ARGV] } | |
# thats all it takes! |
You might have a different model - an array of web servers, another array of db servers, and another array of compute servers, for example. If so, you can easily extend the code to work with your different groups of servers by querying for whatever differentiates them.
Thank you for sharing this Information.
ReplyDeleteI also found Various useful links related to Devops, Docker & Kubernetes
Kubernetes Kubectl Commands CheatSheet
Introduction to Kubernetes Networking
Basic Concept of Kubernetes
Kubernetes Interview Question and Answers
Kubernetes Sheetsheat
Docker Basic Tutorial
Linux Sar Command Tutorial
Linux Interview Questions and Answers
Docker Interview Question and Answers
OpenStack Interview Questions and Answers