krane 1.1.2 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78d05d646de5dda6c38cd1fec3e5abca3964b656e7bd432ebb4f9e537dd3a88c
4
- data.tar.gz: 41a4ed27fc0a646c4471f4c6505ec24eb8ff605565f86eef1ea78ff75b614f7d
3
+ metadata.gz: d5cbad8d48ae06d3286c19cd193ef7208c04c74ee72b3519a82a25605d9c4e86
4
+ data.tar.gz: 2eded80d29111517ca964fe81033d6c3e3667b8704e9c37de3e293fe06fab987
5
5
  SHA512:
6
- metadata.gz: c8f7269fb7fb49b758bf6ac8127adf93bdcc59417ca6a3789b879e28cde2628e1bfacef8bda9f0b3534acc03792d359e5fbfad70260dab173179db362c007255
7
- data.tar.gz: cda59df1d38965783cf146c847db571b697ab23737655744f4123fa7b169f72aa0aaf9305b82f145b68792e1a58cf5b2571427db9cef340864c660b21ae82c61
6
+ metadata.gz: bf04a253ca03e3b3741e7c57dfd3967f54ccfc22b1094da4e9ca854e8211ce0f2fff4c1bc8ed56fef3c4fb7aefe63dd7a53c601e374ebdeaaf6274749722c7ec
7
+ data.tar.gz: db700598c8ec1e634c3c0db7802a6822668651355a2c3c509c1a4ff6dd54947b1999e36ee60404c62b397ffd58287eca93f272497ecfb7114082cdb029410595
@@ -1,5 +1,3 @@
1
- # Recommended rubocop version: ~> 0.78.0
2
-
3
1
  AllCops:
4
2
  Exclude:
5
3
  - 'db/schema.rb'
@@ -78,13 +76,6 @@ Style/BlockDelimiters:
78
76
  - proc
79
77
  - it
80
78
 
81
- Style/BracesAroundHashParameters:
82
- EnforcedStyle: no_braces
83
- SupportedStyles:
84
- - braces
85
- - no_braces
86
- - context_dependent
87
-
88
79
  Layout/CaseIndentation:
89
80
  EnforcedStyle: end
90
81
  SupportedStyles:
@@ -273,7 +264,7 @@ Style/MethodCallWithArgsParentheses:
273
264
  - raise
274
265
  - puts
275
266
  Exclude:
276
- - Gemfile
267
+ - '**/Gemfile'
277
268
 
278
269
  Style/MethodDefParentheses:
279
270
  EnforcedStyle: require_parentheses
@@ -586,6 +577,7 @@ Layout/BlockEndNewline:
586
577
 
587
578
  Style/CaseEquality:
588
579
  Enabled: true
580
+ AllowOnConstant: true
589
581
 
590
582
  Style/CharacterLiteral:
591
583
  Enabled: true
@@ -668,6 +660,9 @@ Style/IfWithSemicolon:
668
660
  Style/IdenticalConditionalBranches:
669
661
  Enabled: true
670
662
 
663
+ Layout/IndentationStyle:
664
+ Enabled: true
665
+
671
666
  Style/InfiniteLoop:
672
667
  Enabled: true
673
668
 
@@ -680,7 +675,7 @@ Style/LineEndConcatenation:
680
675
  Style/MethodCallWithoutArgsParentheses:
681
676
  Enabled: true
682
677
 
683
- Style/MethodMissingSuper:
678
+ Lint/MissingSuper:
684
679
  Enabled: true
685
680
 
686
681
  Style/MissingRespondToMissing:
@@ -812,9 +807,6 @@ Layout/SpaceInsideRangeLiteral:
812
807
  Style/SymbolLiteral:
813
808
  Enabled: true
814
809
 
815
- Layout/Tab:
816
- Enabled: true
817
-
818
810
  Layout/TrailingWhitespace:
819
811
  Enabled: true
820
812
 
@@ -843,7 +835,7 @@ Style/ZeroLengthPredicate:
843
835
  Enabled: true
844
836
 
845
837
  Layout/HeredocIndentation:
846
- EnforcedStyle: squiggly
838
+ Enabled: true
847
839
 
848
840
  Lint/AmbiguousOperator:
849
841
  Enabled: true
@@ -881,9 +873,6 @@ Lint/EmptyEnsure:
881
873
  Lint/EmptyInterpolation:
882
874
  Enabled: true
883
875
 
884
- Lint/EndInMethod:
885
- Enabled: true
886
-
887
876
  Lint/EnsureReturn:
888
877
  Enabled: true
889
878
 
@@ -976,7 +965,7 @@ Lint/UselessAccessModifier:
976
965
  Lint/UselessAssignment:
977
966
  Enabled: true
978
967
 
979
- Lint/UselessComparison:
968
+ Lint/BinaryOperatorWithIdenticalOperands:
980
969
  Enabled: true
981
970
 
982
971
  Lint/UselessElseWithoutRescue:
@@ -1027,3 +1016,6 @@ Style/ModuleFunction:
1027
1016
 
1028
1017
  Lint/OrderedMagicComments:
1029
1018
  Enabled: true
1019
+
1020
+ Lint/DeprecatedOpenSSLConstant:
1021
+ Enabled: true
@@ -1,21 +1,36 @@
1
1
  containers:
2
2
  default:
3
- docker: circleci/ruby:2.4.6-node-browsers
3
+ docker: circleci/ruby:2.5.7
4
4
 
5
5
  steps:
6
6
  - label: Lint
7
7
  timeout: 5m
8
8
  run:
9
+ - bundle: ~
9
10
  - bundle exec rubocop
10
- dependencies:
11
- - bundler
12
- - label: 'Run Test Suite (:kubernetes: 1.16-latest)'
11
+ - label: 'Run Test Suite (:kubernetes: 1.18-latest :ruby: 2.7)'
13
12
  command: bin/ci
14
13
  agents:
15
14
  queue: k8s-ci
16
15
  env:
17
16
  LOGGING_LEVEL: "4"
18
- KUBERNETES_VERSION: v1.16-latest
17
+ KUBERNETES_VERSION: v1.18-latest
18
+ RUBY_VERSION: "2.7"
19
+ - label: 'Run Test Suite (:kubernetes: 1.17-latest)'
20
+ command: bin/ci
21
+ agents:
22
+ queue: k8s-ci
23
+ env:
24
+ LOGGING_LEVEL: "4"
25
+ KUBERNETES_VERSION: v1.17-latest
26
+ - label: 'Run Test Suite (:kubernetes: 1.16.12)'
27
+ command: bin/ci
28
+ agents:
29
+ queue: k8s-ci
30
+ env:
31
+ LOGGING_LEVEL: "4"
32
+ # Flip this back to v1.16-latest when 1.16.14 comes out (see #733)
33
+ KUBERNETES_VERSION: v1.16.12
19
34
  - label: 'Run Test Suite (:kubernetes: 1.15-latest)'
20
35
  command: bin/ci
21
36
  agents:
@@ -51,4 +66,3 @@ steps:
51
66
  env:
52
67
  LOGGING_LEVEL: "4"
53
68
  KUBERNETES_VERSION: v1.11-latest
54
-
@@ -119,7 +119,7 @@ Old flag | New flag | Comments
119
119
  --skip-wait | --verify-result=true |
120
120
  --allow-protected-ns | --protected-namespaces=default,kube-system,kube-public | Added the ability to specify which namespaces are protected
121
121
  --no-prune | --prune=true |
122
- --template-dir | -f, --filename | Makes all krane commands accept this argument, which is now required for the deploy task
122
+ --template-dir | -f, --filenames | Makes all krane commands accept this argument, which is now required for the deploy task
123
123
  --verbose-log-prefix | --verbose-log-prefix |
124
124
  --max-watch-seconds=seconds | --global-timeout=300s | Changed flag name and default value to be a duration (expressed using strings like "300s" or "1h")
125
125
  --selector | --selector |
@@ -1,6 +1,47 @@
1
1
  ## next
2
2
 
3
- ...
3
+ ## 2.1.1
4
+
5
+ *Bug Fixes*
6
+ - Fix the way environment variables are passed into the EJSON decryption invocation [#759](https://github.com/Shopify/krane/pull/759)
7
+
8
+ ## 2.1.0
9
+
10
+ *Features*
11
+ - _(experimental)_ Override deploy method via annotation. This feature is considered alpha and should not be considered stable [#753](https://github.com/Shopify/krane/pull/753)
12
+
13
+ *Enhancements*
14
+ - Increased the number of attempts on kubectl commands during Initializing deploy phase [#749](https://github.com/Shopify/krane/pull/749)
15
+ - Increased attempts on kubectl apply command during deploy [#751](https://github.com/Shopify/krane/pull/751)
16
+ - Whitelist context deadline error during kubctl dry run [#754](https://github.com/Shopify/krane/pull/754)
17
+ - Allow specifying a kubeconfig per task in the internal API [#746](https://github.com/Shopify/krane/pull/746)
18
+
19
+ ## 2.0.0
20
+
21
+ *Breaking Changes*
22
+ - Remove kubernetes deploy annotation prefix [#738](https://github.com/Shopify/krane/pull/738)
23
+
24
+ *Bug Fixes*
25
+ - Always set a deployment_id, even if the current_sha isn't set [#730](https://github.com/Shopify/krane/pull/730)
26
+ - YAML string scalars with scientific/e-notation numeric format not properly quoted. [#740](https://github.com/Shopify/krane/pull/740)
27
+
28
+ ## 1.1.4
29
+
30
+ *Bug Fixes*
31
+ - Properly look up constant on Krane namespace. [#720](https://github.com/Shopify/krane/pull/720)
32
+
33
+ *Enhancements*
34
+ - Allow to configure `image_tag` when using task runner. [#719](https://github.com/Shopify/krane/pull/719)
35
+
36
+ ## 1.1.3
37
+
38
+ *Bug Fixes*
39
+ - Retry dry-run validation when no error is returned. [#705](https://github.com/Shopify/krane/pull/705)
40
+ - Stop deploys if ClusterResourceDiscovery's kubectl calls fail. [#701](https://github.com/Shopify/krane/pull/701)
41
+
42
+ *Other*
43
+ - Dropped support for Ruby 2.4 since it will be EoL shortly. [#693](https://github.com/Shopify/krane/pull/693).
44
+ - Ruby 2.7 support: fix deprecation warnings, add testing. [#710](https://github.com/Shopify/krane/pull/705)
4
45
 
5
46
  ## 1.1.2
6
47
  *Enhancements*
@@ -43,6 +84,12 @@
43
84
  We've renamed the gem and cli to Krane.
44
85
  See our [migration guide](https://github.com/Shopify/krane/blob/master/1.0-Upgrade.md) to help navigate the breaking changes.
45
86
 
87
+ ## 1.0.0.pre.2
88
+
89
+ *Enhancements*
90
+ - Relax thor version requirement. ([#731](https://github.com/Shopify/krane/pull/731))
91
+ - Relax googleauth restriction. ([#731](https://github.com/Shopify/krane/pull/731))
92
+
46
93
  ## 1.0.0.pre.1
47
94
 
48
95
  *Important!*
@@ -151,7 +151,7 @@ To see the full-color output of a specific integration test, you can use `PRINT_
151
151
  1. Make sure CHANGELOG.md includes all user-facing changes since the last release. Things like test changes or refactors do not need to be included.
152
152
  1. Update the version number in `version.rb`.
153
153
  1. Commit your changes with message "Version x.y.z" and open a PR.
154
- 1. After merging your PR, deploy via [Shipit](https://shipit.shopify.io/shopify/kubernetes-deploy/rubygems). Shipit will automatically tag the release and upload the gem to [rubygems.org](https://rubygems.org/gems/krane).
154
+ 1. After merging your PR, deploy via [Shipit](https://shipit.shopify.io/shopify/krane/rubygems). Shipit will automatically tag the release and upload the gem to [rubygems.org](https://rubygems.org/gems/krane).
155
155
 
156
156
  ## CI (External contributors)
157
157
 
data/README.md CHANGED
@@ -73,7 +73,7 @@ If you need the ability to render dynamic values in templates before deploying,
73
73
 
74
74
  ## Prerequisites
75
75
 
76
- * Ruby 2.4+
76
+ * Ruby 2.5+
77
77
  * Your cluster must be running Kubernetes v1.11.0 or higher<sup>1</sup>
78
78
 
79
79
  <sup>1</sup> We run integration tests against these Kubernetes versions. You can find our
@@ -103,7 +103,7 @@ official compatibility chart below.
103
103
 
104
104
  *Environment variables:*
105
105
 
106
- - `$KUBECONFIG`: points to one or multiple valid kubeconfig files that include the context you want to deploy to. File names are separated by colon for Linux and Mac, and semi-colon for Windows. If ommitted, will use the Kubernetes default of `~/.kube/config`.
106
+ - `$KUBECONFIG`: points to one or multiple valid kubeconfig files that include the context you want to deploy to. File names are separated by colon for Linux and Mac, and semi-colon for Windows. If omitted, Krane will use the Kubernetes default of `~/.kube/config`.
107
107
  - `$GOOGLE_APPLICATION_CREDENTIALS`: points to the credentials for an authenticated service account (required if your kubeconfig `user`'s auth provider is GCP)
108
108
 
109
109
 
@@ -159,6 +159,11 @@ before the deployment is considered successful.
159
159
  - _Default_: `true`
160
160
  - `true`: The custom resource will be deployed in the pre-deploy phase.
161
161
  - All other values: The custom resource will be deployed in the main deployment phase.
162
+ - `krane.shopify.io/deploy-method-override`: Cause a resource to be deployed by the specified `kubectl` command, instead of the default `apply`.
163
+ - _Compatibility_: Cannot be used for `PodDisruptionBudget`, since it always uses `create/replace-force`
164
+ - _Accepted values_: `create`, `replace`, and `replace-force`
165
+ - _Warning_: Resources whose deploy method is overridden are no longer subject to pruning on deploy.
166
+ - This feature is _experimental_ and may be removed at any time.
162
167
 
163
168
 
164
169
  ### Running tasks at the beginning of a deploy
@@ -544,9 +549,7 @@ krane render -f ./path/to/template/dir/template.yaml.erb > template.yaml
544
549
  - `--bindings=BINDINGS`: Makes additional variables available to your ERB templates. For example, `krane render --bindings=color=blue size=large -f some-template.yaml.erb` will expose `color` and `size` to `some-template.yaml.erb`.
545
550
  - `--current-sha`: Expose SHA `current_sha` in ERB bindings
546
551
 
547
- You can add additional variables using the `--bindings=BINDINGS` option which can be formated as a string, JSON string or path to a JSON or YAML file. Complex JSON or YAML data will be converted to a Hash for use in templates. To load a file the argument should include the relative
548
- file path prefixed with an `@` sign. An argument error will be raised if the string argument cannot be parsed, the referenced file does not include a
549
- valid extension (`.json`, `.yaml` or `.yml`) or the referenced file does not exist.
552
+ You can add additional variables using the `--bindings=BINDINGS` option which can be formatted as a string, JSON string or path to a JSON or YAML file. Complex JSON or YAML data will be converted to a Hash for use in templates. To load a file, the argument should include the relative file path prefixed with an `@` sign. An argument error will be raised if the string argument cannot be parsed, the referenced file does not include a valid extension (`.json`, `.yaml` or `.yml`) or the referenced file does not exist.
550
553
 
551
554
  #### Bindings examples
552
555
 
data/bin/ci CHANGED
@@ -17,5 +17,5 @@ docker run --rm \
17
17
  -e VERBOSE=1 \
18
18
  -e PARALLELISM=$PARALLELISM \
19
19
  -w /usr/src/app \
20
- ruby:2.4 \
20
+ ruby:"${RUBY_VERSION:-2.5}" \
21
21
  bin/test
data/dev.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  ---
2
2
  name: krane
3
3
  up:
4
- - ruby: 2.4.6 # Matches gemspec
4
+ - ruby: 2.5.7 # Matches gemspec
5
5
  - bundler
6
6
  - homebrew:
7
- - Caskroom/cask/minikube
7
+ - homebrew/cask/minikube
8
+ - hyperkit
8
9
  - custom:
9
10
  name: Install the minikube fork of driver-hyperkit
10
11
  met?: command -v docker-machine-driver-hyperkit
@@ -23,7 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = %w(lib)
25
25
 
26
- spec.required_ruby_version = '>= 2.4.0'
26
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
27
+
28
+ spec.required_ruby_version = '>= 2.5.0'
27
29
  spec.add_dependency("activesupport", ">= 5.0")
28
30
  spec.add_dependency("kubeclient", "~> 4.3")
29
31
  spec.add_dependency("googleauth", "~> 0.8")
@@ -54,6 +56,6 @@ Gem::Specification.new do |spec|
54
56
  spec.add_development_dependency("byebug")
55
57
  spec.add_development_dependency("ruby-prof")
56
58
  spec.add_development_dependency("ruby-prof-flamegraph")
57
- spec.add_development_dependency("rubocop", "~> 0.78.0")
59
+ spec.add_development_dependency("rubocop", "~> 0.89.1")
58
60
  spec.add_development_dependency("codecov")
59
61
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Krane
4
+ module Annotation
5
+ class << self
6
+ def for(suffix)
7
+ "krane.shopify.io/#{suffix}"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -37,7 +37,7 @@ module Krane
37
37
  def fetch_resources(namespaced: false)
38
38
  command = %w(api-resources)
39
39
  command << "--namespaced=#{namespaced}"
40
- raw, _, st = kubectl.run(*command, output: "wide", attempts: 5,
40
+ raw, err, st = kubectl.run(*command, output: "wide", attempts: 5,
41
41
  use_namespace: false)
42
42
  if st.success?
43
43
  rows = raw.split("\n")
@@ -59,7 +59,7 @@ module Krane
59
59
  resource
60
60
  end
61
61
  else
62
- []
62
+ raise FatalKubeAPIError, "Error retrieving api-resources: #{err}"
63
63
  end
64
64
  end
65
65
 
@@ -68,7 +68,7 @@ module Krane
68
68
  # kubectl api-versions returns a list of group/version strings e.g. autoscaling/v2beta2
69
69
  # A kind may not exist in all versions of the group.
70
70
  def fetch_api_versions
71
- raw, _, st = kubectl.run("api-versions", attempts: 5, use_namespace: false)
71
+ raw, err, st = kubectl.run("api-versions", attempts: 5, use_namespace: false)
72
72
  # The "core" group is represented by an empty string
73
73
  versions = { "" => %w(v1) }
74
74
  if st.success?
@@ -78,6 +78,8 @@ module Krane
78
78
  versions[group] ||= []
79
79
  versions[group] << version
80
80
  end
81
+ else
82
+ raise FatalKubeAPIError, "Error retrieving api-versions: #{err}"
81
83
  end
82
84
  versions
83
85
  end
@@ -86,7 +88,8 @@ module Krane
86
88
  # Override list for kinds that don't appear in the lastest version of a group
87
89
  version_override = { "CronJob" => "v1beta1", "VolumeAttachment" => "v1beta1",
88
90
  "CSIDriver" => "v1beta1", "Ingress" => "v1beta1",
89
- "CSINode" => "v1beta1", "Job" => "v1" }
91
+ "CSINode" => "v1beta1", "Job" => "v1",
92
+ "IngressClass" => "v1beta1" }
90
93
 
91
94
  pattern = /v(?<major>\d+)(?<pre>alpha|beta)?(?<minor>\d+)?/
92
95
  latest = versions.sort_by do |version|
@@ -98,12 +101,12 @@ module Krane
98
101
  end
99
102
 
100
103
  def fetch_crds
101
- raw_json, _, st = kubectl.run("get", "CustomResourceDefinition", output: "json", attempts: 5,
104
+ raw_json, err, st = kubectl.run("get", "CustomResourceDefinition", output: "json", attempts: 5,
102
105
  use_namespace: false)
103
106
  if st.success?
104
107
  JSON.parse(raw_json)["items"]
105
108
  else
106
- []
109
+ raise FatalKubeAPIError, "Error retrieving CustomResourceDefinition: #{err}"
107
110
  end
108
111
  end
109
112
 
@@ -15,12 +15,6 @@ module Krane
15
15
  logger.summary.add_paragraph(debug_msg)
16
16
  end
17
17
 
18
- def record_warnings(logger:, warning:, filename:)
19
- warn_msg = "Template warning: #{filename}\n"
20
- warn_msg += "> Warning message:\n#{Krane::FormattedLogger.indent_four(warning)}"
21
- logger.summary.add_paragraph(ColorizedString.new(warn_msg).yellow)
22
- end
23
-
24
18
  def add_para_from_list(logger:, action:, enum:)
25
19
  logger.summary.add_action(action)
26
20
  logger.summary.add_paragraph(enum.map { |e| "- #{e}" }.join("\n"))
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ module Krane
3
+ class ContainerOverrides
4
+ attr_reader :command, :arguments, :env_vars, :image_tag
5
+
6
+ def initialize(command: nil, arguments: nil, env_vars: [], image_tag: nil)
7
+ @command = command
8
+ @arguments = arguments
9
+ @env_vars = env_vars
10
+ @image_tag = image_tag
11
+ end
12
+
13
+ def apply!(container)
14
+ container.command = command if command
15
+ container.args = arguments if arguments
16
+
17
+ if image_tag
18
+ image = container.image
19
+ base_image, _old_tag = image.split(':')
20
+ new_image = "#{base_image}:#{image_tag}"
21
+
22
+ container.image = new_image
23
+ end
24
+
25
+ env_args = env_vars.map do |env|
26
+ key, value = env.split('=', 2)
27
+ { name: key, value: value }
28
+ end
29
+ container.env ||= []
30
+ container.env = container.env.map(&:to_h) + env_args
31
+ end
32
+ end
33
+ end
@@ -4,6 +4,7 @@ require 'shellwords'
4
4
  require 'tempfile'
5
5
  require 'fileutils'
6
6
 
7
+ require 'krane/annotation'
7
8
  require 'krane/common'
8
9
  require 'krane/concurrency'
9
10
  require 'krane/resource_cache'
@@ -56,6 +57,7 @@ module Krane
56
57
  )
57
58
 
58
59
  def predeploy_sequence
60
+ default_group = { group: nil }
59
61
  before_crs = %w(
60
62
  ResourceQuota
61
63
  NetworkPolicy
@@ -65,12 +67,14 @@ module Krane
65
67
  Role
66
68
  RoleBinding
67
69
  Secret
68
- )
70
+ ).map { |r| [r, default_group] }
71
+
69
72
  after_crs = %w(
70
73
  Pod
71
- )
74
+ ).map { |r| [r, default_group] }
72
75
 
73
- before_crs + cluster_resource_discoverer.crds.select(&:predeployed?).map(&:kind) + after_crs
76
+ crs = cluster_resource_discoverer.crds.select(&:predeployed?).map { |cr| [cr.kind, { group: cr.group }] }
77
+ Hash[before_crs + crs + after_crs]
74
78
  end
75
79
 
76
80
  def prune_whitelist
@@ -81,6 +85,10 @@ module Krane
81
85
  kubectl.server_version
82
86
  end
83
87
 
88
+ attr_reader :task_config
89
+
90
+ delegate :kubeclient_builder, to: :task_config
91
+
84
92
  # Initializes the deploy task
85
93
  #
86
94
  # @param namespace [String] Kubernetes namespace (*required*)
@@ -97,10 +105,10 @@ module Krane
97
105
  # @param render_erb [Boolean] Enable ERB rendering
98
106
  def initialize(namespace:, context:, current_sha: nil, logger: nil, kubectl_instance: nil, bindings: {},
99
107
  global_timeout: nil, selector: nil, filenames: [], protected_namespaces: nil,
100
- render_erb: false)
108
+ render_erb: false, kubeconfig: nil)
101
109
  @logger = logger || Krane::FormattedLogger.build(namespace, context)
102
110
  @template_sets = TemplateSets.from_dirs_and_files(paths: filenames, logger: @logger, render_erb: render_erb)
103
- @task_config = Krane::TaskConfig.new(context, namespace, @logger)
111
+ @task_config = Krane::TaskConfig.new(context, namespace, @logger, kubeconfig)
104
112
  @bindings = bindings
105
113
  @namespace = namespace
106
114
  @namespace_tags = []
@@ -116,8 +124,8 @@ module Krane
116
124
  # Runs the task, returning a boolean representing success or failure
117
125
  #
118
126
  # @return [Boolean]
119
- def run(*args)
120
- run!(*args)
127
+ def run(**args)
128
+ run!(**args)
121
129
  true
122
130
  rescue FatalDeploymentError
123
131
  false
@@ -186,10 +194,6 @@ module Krane
186
194
  selector: @selector, statsd_tags: statsd_tags, current_sha: @current_sha)
187
195
  end
188
196
 
189
- def kubeclient_builder
190
- @kubeclient_builder ||= KubeclientBuilder.new
191
- end
192
-
193
197
  def cluster_resource_discoverer
194
198
  @cluster_resource_discoverer ||= ClusterResourceDiscovery.new(
195
199
  task_config: @task_config,
@@ -210,7 +214,10 @@ module Krane
210
214
  end
211
215
 
212
216
  def deploy_has_priority_resources?(resources)
213
- resources.any? { |r| predeploy_sequence.include?(r.type) }
217
+ resources.any? do |r|
218
+ next unless (pr = predeploy_sequence[r.type])
219
+ !pr[:group] || pr[:group] == r.group
220
+ end
214
221
  end
215
222
 
216
223
  def check_initial_status(resources)
@@ -242,6 +249,8 @@ module Krane
242
249
  @logger.info(" - #{secret.id} (from ejson)")
243
250
  end
244
251
 
252
+ StatsD.client.gauge('discover_resources.count', resources.size, tags: statsd_tags)
253
+
245
254
  resources.sort
246
255
  rescue InvalidTemplateError => e
247
256
  record_invalid_template(logger: @logger, err: e.message, filename: e.filename,
@@ -274,11 +283,6 @@ module Krane
274
283
  r.validate_definition(kubectl, selector: @selector)
275
284
  end
276
285
 
277
- resources.select(&:has_warnings?).each do |resource|
278
- record_warnings(logger: @logger, warning: resource.validation_warning_msg,
279
- filename: File.basename(resource.file_path))
280
- end
281
-
282
286
  failed_resources = resources.select(&:validation_failed?)
283
287
  if failed_resources.present?
284
288