-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.rb
44 lines (39 loc) · 1.19 KB
/
dashboard.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
# Cookbook:: .
# Recipe:: dashboard
#
# Copyright:: 2017, The Authors, All Rights Reserved.
# Download dashboard
install_path = "/etc/kubernetes/manifests/dashboard-#{node['kubeadm']['dashboard_commit_hash7']}"
download_url = "https://github.com/kubernetes/dashboard/raw/#{node['kubeadm']['dashboard_commit_hash7']}"
bash 'download dashboard' do
code <<-EOF
mkdir -p #{install_path}
cd #{install_path}
wget #{download_url}/src/deploy/recommended/kubernetes-dashboard.yaml
EOF
not_if { ::File.exist?("#{install_path}/kubernetes-dashboard.yaml") }
end
# install dashboard addon
execute 'install dashboard' do
cwd install_path
command 'kubectl create -f .'
action :run
retries 20
retry_delay 10
not_if 'kubectl get pods -n kube-system | grep kubernetes-dashboard'
end
# create template for dashboard admin role
template "#{install_path}/dashboard-admin.yaml" do
source 'dashboard-admin.yaml.erb'
owner 'root'
group 'root'
mode '0644'
notifies :run, 'execute[create dashboard admin role]', :immediately
end
# create dashboard admin role
execute 'create dashboard admin role' do
cwd install_path
command 'kubectl create -f ./dashboard-admin.yaml'
action :nothing
end