kube_auto_analyzer 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62e3662e8af79fd34786e09365d3dc9247facc66
4
- data.tar.gz: 6f8b1ab40edfba133847ebc220863c00f5d5f6c6
3
+ metadata.gz: 8fd1aff1f5704afeae2c8834fc74af48bdec557b
4
+ data.tar.gz: f9db491c94623efc96d3250db2023c1da9af59b0
5
5
  SHA512:
6
- metadata.gz: 47fdb79b36cdf3cad35b13f9225426e3c926040a60dbf806ca1b2d7b388ce0a88d6037e172571b58ad2db9d45cf46b005e4e7c242e24629160bb9dd6484e290e
7
- data.tar.gz: 28f825709c18510c33d0e524e877b6de640489d63c0668df9c05256ff64a0a635820ee157e6e8585afec48d1d7f19973f712607a7e060b45a9042f37fbb7e37e
6
+ metadata.gz: 8b4513de20ce3a52618dec8c5bad3b86d9c9d80b7b3281101655dc2f5bf4a0e577dd1186be9cc0cb2c927515ed9c1b0cc55574b091fb2ee5a9acfcf868d300a4
7
+ data.tar.gz: ef690999d310ef569f7bb06b03b486133724393e7e82020ff77e69d374b0ba806d234f539f6b15762b9bb332c7129ecbdc23706c2ab879cb44aad0ec53064acc
data/bin/kubeautoanalyzer CHANGED
@@ -9,6 +9,7 @@
9
9
  options.report_file = 'kube-parse-report'
10
10
  options.target_server = 'http://127.0.0.1:8080'
11
11
  options.html_report = false
12
+ options.json_report = false
12
13
  options.token = ''
13
14
  options.token_file = ''
14
15
  options.config_file = false
@@ -33,6 +34,14 @@
33
34
  options.token = token
34
35
  end
35
36
 
37
+ opts.on("-j", "--json", "Create a JSON report") do |json|
38
+ options.json_report = true
39
+ end
40
+
41
+ opts.on("--html", "Create an HTML report") do |html|
42
+ options.html_report = true
43
+ end
44
+
36
45
  opts.on("-f", "--token_file [TOKENFILE]", "Token file to use (provide full path)") do |token_file|
37
46
  options.token = token_file
38
47
  end
@@ -68,4 +77,10 @@
68
77
  exit
69
78
  end
70
79
 
80
+ unless (options.json_report || options.html_report)
81
+ puts "You need to ask for either an HTML report or a JSON one (or both)"
82
+ puts opts
83
+ exit
84
+ end
85
+
71
86
  KubeAutoAnalyzer.execute(options)
@@ -4,15 +4,12 @@ module KubeAutoAnalyzer
4
4
  require 'json'
5
5
  @log.debug ("entering File check")
6
6
  target = @options.target_server
7
- @results[target]['worker_files'] = Hash.new
7
+ @results[target]['node_files'] = Hash.new
8
+
8
9
 
9
- #Run on any nodes that aren't NoSchedule
10
- #Doesn't necessarily mean worker nodes, but a reasonable facsimile for now.
11
10
  nodes = Array.new
12
11
  @client.get_nodes.each do |node|
13
- unless node.spec.taints.to_s =~ /NoSchedule/
14
- nodes << node
15
- end
12
+ nodes << node
16
13
  end
17
14
  nodes.each do |nod|
18
15
  node_hostname = nod.metadata.labels['kubernetes.io/hostname']
@@ -25,6 +22,11 @@ module KubeAutoAnalyzer
25
22
  pod.spec.restartPolicy = "Never"
26
23
  pod.spec.containers = {}
27
24
  pod.spec.containers = [{name: "kubeautoanalyzerfiletest", image: "raesene/kaa-agent:latest"}]
25
+
26
+ #Try the Toleration for Master
27
+ pod.spec.tolerations = {}
28
+ pod.spec.tolerations = [{ key:"key", operator:"Equal", value:"value",effect:"NoSchedule"}]
29
+
28
30
  pod.spec.volumes = [{name: 'etck8s', hostPath: {path: '/etc'}}]
29
31
  pod.spec.containers[0].volumeMounts = [{mountPath: '/etc', name: 'etck8s'}]
30
32
  pod.spec.containers[0].args = ["/file-checker.rb","/etc/kubernetes"]
@@ -39,13 +41,13 @@ module KubeAutoAnalyzer
39
41
  end
40
42
  files = JSON.parse(@client.get_pod_log(container_name,"default"))
41
43
 
42
- @results[target]['worker_files'][node_hostname] = files
44
+ @results[target]['node_files'][node_hostname] = files
43
45
  ensure
44
46
  @client.delete_pod(container_name,"default")
45
47
  end
46
48
 
47
49
  end
48
- @log.debug("Finished Worker File Check")
50
+ @log.debug("Finished Node File Check")
49
51
  end
50
52
 
51
53
  end
@@ -9,9 +9,9 @@ module KubeAutoAnalyzer
9
9
 
10
10
  nodes = Array.new
11
11
  @client.get_nodes.each do |node|
12
- unless node.spec.taints.to_s =~ /NoSchedule/
12
+ # unless node.spec.taints.to_s =~ /NoSchedule/
13
13
  nodes << node
14
- end
14
+ # end
15
15
  end
16
16
 
17
17
  nodes.each do |nod|
@@ -25,6 +25,11 @@ module KubeAutoAnalyzer
25
25
  pod.spec.restartPolicy = "Never"
26
26
  pod.spec.containers = {}
27
27
  pod.spec.containers = [{name: "kaakubelettest", image: "raesene/kaa-agent:latest"}]
28
+
29
+ #Try the Toleration for Master
30
+ pod.spec.tolerations = {}
31
+ pod.spec.tolerations = [{ key:"key", operator:"Equal", value:"value",effect:"NoSchedule"}]
32
+
28
33
  pod.spec.containers[0].args = ["/process-checker.rb"]
29
34
  pod.spec.hostPID = true
30
35
  pod.spec.nodeselector = {}
@@ -1,54 +1,10 @@
1
1
  module KubeAutoAnalyzer
2
2
 
3
- def self.report
3
+ def self.json_report
4
+ require 'json'
4
5
  @log.debug("Starting Report")
5
- @report_file.puts "Kubernetes Analyzer"
6
- @report_file.puts "===================\n\n"
7
- @report_file.puts "**Server Reviewed** : #{@options.target_server}"
8
- @report_file.puts "\n\nAPI Server Results"
9
- @report_file.puts "----------------------\n\n"
10
- @results[@options.target_server]['api_server'].each do |test, result|
11
- @report_file.puts '* ' + test + ' - **' + result + '**'
12
- end
13
- @report_file.puts "\n\nScheduler Results"
14
- @report_file.puts "----------------------\n\n"
15
- @results[@options.target_server]['scheduler'].each do |test, result|
16
- @report_file.puts '* ' + test + ' - **' + result + '**'
17
- end
18
-
19
- @report_file.puts "\n\nController Manager Results"
20
- @report_file.puts "----------------------\n\n"
21
- @results[@options.target_server]['controller_manager'].each do |test, result|
22
- @report_file.puts '* ' + test + ' - **' + result + '**'
23
- end
24
-
25
- @report_file.puts "\n\netcd Results"
26
- @report_file.puts "----------------------\n\n"
27
- @results[@options.target_server]['etcd'].each do |test, result|
28
- @report_file.puts '* ' + test + ' - **' + result + '**'
29
- end
30
- if @options.agent_file_checks
31
- @report_file.puts "\n\nWorker Nodes File Permissions"
32
- @report_file.puts "----------------------\n\n"
33
- @log.debug("Class is #{@results[@options.target_server]['worker_files'].class}")
34
- @results[@options.target_server]['worker_files'].each do |node, results|
35
- @report_file.puts "\n\n#{node}\n"
36
- results.each do |file|
37
- @report_file.puts file.join(', ')
38
- end
39
- end
40
- end
6
+ @json_report_file.puts JSON.generate(@results)
41
7
 
42
- @report_file.puts "\n\nEvidence"
43
- @report_file.puts "---------------\n\n"
44
- @report_file.puts ' ' + @results[@options.target_server]['evidence']['API Server'].to_s
45
- @report_file.puts "---------------\n\n"
46
- @report_file.puts ' ' + @results[@options.target_server]['evidence']['Scheduler'].to_s
47
- @report_file.puts "---------------\n\n"
48
- @report_file.puts ' ' + @results[@options.target_server]['evidence']['Controller Manager'].to_s
49
- @report_file.puts "---------------\n\n"
50
- @report_file.puts ' ' + @results[@options.target_server]['evidence']['etcd'].to_s
51
- @report_file.close
52
8
  end
53
9
 
54
10
  def self.html_report
@@ -295,8 +251,8 @@ module KubeAutoAnalyzer
295
251
  #Close the Worker Node Div
296
252
  @html_report_file.puts '</div>'
297
253
  if @options.agent_checks
298
- @html_report_file.puts '<br><h2>File Permissions</h2>'
299
- @results[@options.target_server]['worker_files'].each do |node, results|
254
+ @html_report_file.puts '<br><h2>Node File Permissions</h2>'
255
+ @results[@options.target_server]['node_files'].each do |node, results|
300
256
  @html_report_file.puts "<br><b>#{node}</b><br>"
301
257
  @html_report_file.puts "<table><thead><tr><th>file</th><th>user</th><th>group</th><th>permissions</th></thead>"
302
258
  results.each do |file|
@@ -1,3 +1,3 @@
1
1
  module KubeAutoAnalyzer
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -10,9 +10,7 @@ module KubeAutoAnalyzer
10
10
 
11
11
  nodes = Array.new
12
12
  @client.get_nodes.each do |node|
13
- unless node.spec.taints.to_s =~ /NoSchedule/
14
- nodes << node
15
- end
13
+ nodes << node
16
14
  end
17
15
 
18
16
  nodes.each do |nod|
@@ -28,6 +26,11 @@ module KubeAutoAnalyzer
28
26
  pod.spec.containers = {}
29
27
  pod.spec.containers = [{name: "kubeautoanalyzerkubelettest", image: "raesene/kaa-agent:latest"}]
30
28
  pod.spec.containers[0].args = ["/amicontained.rb"]
29
+
30
+ #Try the Toleration for Master
31
+ pod.spec.tolerations = {}
32
+ pod.spec.tolerations = [{ key:"key", operator:"Equal", value:"value",effect:"NoSchedule"}]
33
+
31
34
  pod.spec.nodeselector = {}
32
35
  pod.spec.nodeselector['kubernetes.io/hostname'] = node_hostname
33
36
  begin
@@ -33,9 +33,13 @@ module KubeAutoAnalyzer
33
33
  @log.debug("Target API Server is " + @options.target_server)
34
34
 
35
35
  @report_file_name = @base_dir + '/' + @options.report_file
36
- #Remove the Text report for now as we're not using this option
37
- #@report_file = File.new(@report_file_name + '.txt','w+')
38
- @html_report_file = File.new(@report_file_name + '.html','w+')
36
+ if @options.json_report
37
+ @json_report_file = File.new(@report_file_name + '.json','w+')
38
+ end
39
+
40
+ if @options.html_report
41
+ @html_report_file = File.new(@report_file_name + '.html','w+')
42
+ end
39
43
  @log.debug("New Report File created #{@report_file_name}")
40
44
 
41
45
  @results = Hash.new
@@ -96,7 +100,12 @@ module KubeAutoAnalyzer
96
100
  check_kubelet_process
97
101
  check_amicontained
98
102
  end
99
- html_report
103
+ if @options.html_report
104
+ html_report
105
+ end
106
+ if @options.json_report
107
+ json_report
108
+ end
100
109
  end
101
110
 
102
111
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_auto_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rory McCune