Skip to content

Instantly share code, notes, and snippets.

@zedtux
Created July 29, 2019 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zedtux/7030eda4a27ee0d2e02f0f054de8683c to your computer and use it in GitHub Desktop.
Save zedtux/7030eda4a27ee0d2e02f0f054de8683c to your computer and use it in GitHub Desktop.
An extracted part of a Chef recipe to deploy Kubernetes with Kubeadm logging in real-time the command output
require 'pty'
# Initialize master
ruby_block 'kubeadm init' do
block do
command = <<-CMD
kubeadm init \
--token=#{node['kubeadm']['token']} \
--pod-network-cidr=#{node['kubeadm']['pod_cidr']} \
--service-cidr=#{node['kubeadm']['service_cidr']} \
--service-dns-domain=#{node['kubeadm']['dns_domain']} \
--apiserver-advertise-address=#{node['kubeadm']['api_ip_address']}
CMD
PTY.spawn(command) do |stdout, _, _|
begin
loop { puts stdout.gets.gsub(/\r\n/, '').gsub(/\t/, ' ') }
rescue Errno::EIO
end
end
end
action :run
not_if "grep 'https://#{master_ip_address}' /etc/kubernetes/kubelet.conf"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment