diff --git a/cookbooks/nomad/attributes.rb b/cookbooks/nomad/attributes.rb index d0fb934..e366ebf 100644 --- a/cookbooks/nomad/attributes.rb +++ b/cookbooks/nomad/attributes.rb @@ -5,6 +5,7 @@ node.reverse_merge!({ 'nomad' => { 'manager' => false, 'client' => false, - 'lokiendpoint' => 'loki.service.consul:3100' + 'lokiendpoint' => 'loki.service.consul:3100', + 'synology' => '192.168.10.200' } }) diff --git a/cookbooks/nomad/csi.rb b/cookbooks/nomad/csi.rb new file mode 100644 index 0000000..222199c --- /dev/null +++ b/cookbooks/nomad/csi.rb @@ -0,0 +1,61 @@ +SYNOLOGY = node['nomad']['synology'] + +# 前提パッケージのインストール・セットアップ +%w( open-iscsi lsscsi sg3-utils multipath-tools scsitools ).each do |p| + package p +end + +execute "iscsiadm -m discoverydb -t st -p #{SYNOLOGY} --discover" do + user 'root' +end + +remote_file "/etc/multipath.conf" do + user 'root' + group 'root' + mode '0644' + + notifies :restart, 'service[multipath-tools]' +end + +%w( multipath-tools open-iscsi).each do |s| + service s do + action [:enable, :restart] + end +end + +# CNIプラグインのデプロイ・セットアップ +directory '/opt/cni/bin' do + owner 'root' + group 'root' + + mode '0755' +end + +%w( bandwidth bridge dhcp firewall host-device host-local ipvlan loopback macvlan portmap ptp sbr static tuning vlan vrf ).each do |f| + remote_file "/opt/cni/bin/#{f}" do + owner 'root' + group 'root' + + mode '0775' + end +end + +directory '/etc/cni' do + owner 'root' + group 'root' + mode '0755' +end + +remote_file '/etc/cni/nomad.conflist' do + owner 'root' + group 'root' + mode '0644' +end + +remote_file '/etc/nomad.d/csi.hcl' do + owner 'nomad' + group 'nomad' + mode '0664' + + notifies :restart, 'service[nomad]' +end diff --git a/cookbooks/nomad/default.rb b/cookbooks/nomad/default.rb index 64ce176..df2a768 100644 --- a/cookbooks/nomad/default.rb +++ b/cookbooks/nomad/default.rb @@ -4,6 +4,7 @@ include_recipe './install.rb' if node['nomad']['manager'] || node['nomad']['client'] include_recipe './setup.rb' + include_recipe './csi.rb' include_recipe './shared_dir.rb' end diff --git a/cookbooks/nomad/files/etc/cni/nomad.conflist b/cookbooks/nomad/files/etc/cni/nomad.conflist new file mode 100644 index 0000000..6c3a414 --- /dev/null +++ b/cookbooks/nomad/files/etc/cni/nomad.conflist @@ -0,0 +1,23 @@ +{ + "cniVersion": "0.3.1", + "name": "nomad", + "plugins": [ + { + "type": "ptp", + "ipMasq": true, + "ipam": { + "type": "host-local", + "subnet": "172.16.30.0/24", + "routes": [ + { + "dst": "0.0.0.0/0" + } + ] + } + }, + { + "type": "portmap", + "capabilities": { "portMappings": true } + } + ] +} diff --git a/cookbooks/nomad/files/etc/multipath.conf b/cookbooks/nomad/files/etc/multipath.conf new file mode 100644 index 0000000..6a06f08 --- /dev/null +++ b/cookbooks/nomad/files/etc/multipath.conf @@ -0,0 +1,8 @@ +defaults { + user_friendly_names yes + find_multipaths yes +} + +blacklist { + devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st|sda)[0-9]*" +} diff --git a/cookbooks/nomad/files/etc/nomad.d/csi.hcl b/cookbooks/nomad/files/etc/nomad.d/csi.hcl new file mode 100644 index 0000000..c5c0503 --- /dev/null +++ b/cookbooks/nomad/files/etc/nomad.d/csi.hcl @@ -0,0 +1,14 @@ +client { + cni_path = "/opt/cni/bin" + cni_config_dir = "/etc/cni/" +} + +plugin "docker" { + config { + volumes { + enabled = true + } + + allow_privileged = true + } +} diff --git a/cookbooks/nomad/files/opt/cni/bin/bandwidth b/cookbooks/nomad/files/opt/cni/bin/bandwidth new file mode 100644 index 0000000..cc834cf Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/bandwidth differ diff --git a/cookbooks/nomad/files/opt/cni/bin/bridge b/cookbooks/nomad/files/opt/cni/bin/bridge new file mode 100644 index 0000000..6c371ce Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/bridge differ diff --git a/cookbooks/nomad/files/opt/cni/bin/dhcp b/cookbooks/nomad/files/opt/cni/bin/dhcp new file mode 100644 index 0000000..f62339a Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/dhcp differ diff --git a/cookbooks/nomad/files/opt/cni/bin/firewall b/cookbooks/nomad/files/opt/cni/bin/firewall new file mode 100644 index 0000000..27e5ecf Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/firewall differ diff --git a/cookbooks/nomad/files/opt/cni/bin/host-device b/cookbooks/nomad/files/opt/cni/bin/host-device new file mode 100644 index 0000000..082489a Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/host-device differ diff --git a/cookbooks/nomad/files/opt/cni/bin/host-local b/cookbooks/nomad/files/opt/cni/bin/host-local new file mode 100644 index 0000000..7c75ff5 Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/host-local differ diff --git a/cookbooks/nomad/files/opt/cni/bin/ipvlan b/cookbooks/nomad/files/opt/cni/bin/ipvlan new file mode 100644 index 0000000..a2e8186 Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/ipvlan differ diff --git a/cookbooks/nomad/files/opt/cni/bin/loopback b/cookbooks/nomad/files/opt/cni/bin/loopback new file mode 100644 index 0000000..56a107d Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/loopback differ diff --git a/cookbooks/nomad/files/opt/cni/bin/macvlan b/cookbooks/nomad/files/opt/cni/bin/macvlan new file mode 100644 index 0000000..36608de Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/macvlan differ diff --git a/cookbooks/nomad/files/opt/cni/bin/portmap b/cookbooks/nomad/files/opt/cni/bin/portmap new file mode 100644 index 0000000..ca96b93 Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/portmap differ diff --git a/cookbooks/nomad/files/opt/cni/bin/ptp b/cookbooks/nomad/files/opt/cni/bin/ptp new file mode 100644 index 0000000..14c2023 Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/ptp differ diff --git a/cookbooks/nomad/files/opt/cni/bin/sbr b/cookbooks/nomad/files/opt/cni/bin/sbr new file mode 100644 index 0000000..ff97bbc Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/sbr differ diff --git a/cookbooks/nomad/files/opt/cni/bin/static b/cookbooks/nomad/files/opt/cni/bin/static new file mode 100644 index 0000000..e28d72b Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/static differ diff --git a/cookbooks/nomad/files/opt/cni/bin/tuning b/cookbooks/nomad/files/opt/cni/bin/tuning new file mode 100644 index 0000000..1e0aed5 Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/tuning differ diff --git a/cookbooks/nomad/files/opt/cni/bin/vlan b/cookbooks/nomad/files/opt/cni/bin/vlan new file mode 100644 index 0000000..339243e Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/vlan differ diff --git a/cookbooks/nomad/files/opt/cni/bin/vrf b/cookbooks/nomad/files/opt/cni/bin/vrf new file mode 100644 index 0000000..a6f5709 Binary files /dev/null and b/cookbooks/nomad/files/opt/cni/bin/vrf differ