kubernetes_helper 1.13.0 → 1.13.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: d7530d88e0f3442c2db0a7fa75d66fd03cac567ea179063ad57d14dcb87e98db
4
- data.tar.gz: 21acb0413b2b62935e442a5ac4b03650ff8fc5e6eba8d7bb6daba0c94ecd937d
3
+ metadata.gz: 071cbd7243cf091dddbb90ae098afb3af88e8469c0b5db41a22f631907f1e529
4
+ data.tar.gz: c3d0a6f4bf022441862921cfca4fd3d8be219309a23312c15f693c15ce88f1b7
5
5
  SHA512:
6
- metadata.gz: eb2a26a7704e7500a37f06a5d6f56b5dd6979b68283324213e612ace1a9d45204714c761e0737cfd64d9e41700bdcfd6e143d1bcc4c6f957e4f7c29c479410d0
7
- data.tar.gz: 59443675ec5cc8705383458ec25de2e3a0fd3488fcb5dbf575cf9375f4b63983d6d01089d8641e5f14be47c99cb5107bb307977858a9dcb29a69aa46789713c6
6
+ metadata.gz: cc4adcdfc85d9b12cbfaf7d4b523a9585a12e9f6da55c140429e818aa05ab70380c1c45fd6209fb5a25c7ff59b28e73e45178a051031a4268321382a9f6afc03
7
+ data.tar.gz: 639e58559bb0768a78fd21e5d568db6c40747d225975679d6cd6873da52d388bd086bb53d0212b8828dd76ed4e562a600277004a41a3a121126db1b79d51a5d7
data/README.md CHANGED
@@ -70,10 +70,9 @@ Below settings are used when configuring the application in the k8s environment
70
70
  - `deployment.replicas_range` (Array<min, max, cpu_percentage>, Optional): Defines the minimum and the maximum number of pods that could automatically be created when `CPUUtilizationPercentage` is above than defined. Sample: `[1, 3, 50]`
71
71
  - `deployment.cloud_secret_name` (String, Optional): K8s credentials name where cloud secrets will be saved (includes permission like DB). Sample: `my-app-cloud-secret`
72
72
  - `deployment.cloud_sql_instance` (String, Optional): Cloud sql instance name. Sample: `my-project:europe-west1:my-instance-name=tcp:5432` (5432 => postgres, 3306 => mysql)
73
- - `deployment.env_vars` (Hash, optional): List of static env variables (Note: Not recommended for sensitive values). Sample: `{ 'RAILS_ENV' => 'production' }`
74
- - `deployment.external_secrets` (Hash, optional): List of env vars imported from external secret config.
75
- Basic example: `external_secrets: { paper_trail_port: 'common_secrets' }` will import `paper_trail_port` value from `common_secrets` yml as `PAPER_TRAIL_PORT`
76
- Advanced example: `external_secrets: { papertrail_port: { name: 'common_secrets', key: 'paper_trail_port' } }` will import `paper_trail_port` value from `common_secrets` yml as `PAPERTRAIL_PORT`
73
+ - `deployment.env_vars` (Hash, optional): List of static or external env variables (Note: Not recommended for sensitive values).
74
+ Sample: `{ 'RAILS_ENV' => 'production' }`
75
+ Example for external secrets: `{ PAPERTRAIL_PORT: { name: 'common_secrets', key: 'paper_trail_port' }` will import `paper_trail_port` value from `common_secrets` yml as `PAPERTRAIL_PORT`
77
76
 
78
77
  - `deployment.command` (String, Optional): Bash command to be used for web containers. Sample: `rails s -b 0.0.0.0`
79
78
  - `deployment.liveness_path` (String, Optional): Relative path to be used for readiness and liveness checker of the web app. Sample: `/check_liveness`
@@ -67,26 +67,12 @@ module KubernetesHelper
67
67
  def import_secrets(path, secrets_name)
68
68
  path = KubernetesHelper.settings_path(path)
69
69
  data = YAML.load(File.read(path)) # rubocop:disable Security/YAMLLoad
70
- secrets = data['data'].keys.map do |secret|
70
+ data['data'].keys.map do |secret|
71
71
  {
72
72
  'name' => secret.upcase,
73
73
  'valueFrom' => { 'secretKeyRef' => { 'name' => secrets_name, 'key' => secret } }
74
74
  }
75
75
  end
76
- secrets + external_secrets
77
- end
78
-
79
- def external_secrets
80
- data = config_values.dig(:deployment, :external_secrets) || {}
81
- data.map do |key, source|
82
- source = source.is_a?(Hash) ? source : { name: source.to_s, key: key }
83
- {
84
- 'name' => key.upcase.to_s,
85
- 'valueFrom' => {
86
- 'secretKeyRef' => { 'name' => source[:name], 'key' => source[:key].to_s }
87
- }
88
- }
89
- end
90
76
  end
91
77
 
92
78
  def render_template(template_name, locals = {})
@@ -97,9 +83,11 @@ module KubernetesHelper
97
83
 
98
84
  def static_env_vars
99
85
  (config_values.dig(:deployment, :env_vars) || {}).map do |key, value|
86
+ external = value.is_a?(Hash)
87
+ value = { 'secretKeyRef' => { 'name' => value[:name], 'key' => value[:key].to_s } } if external
100
88
  {
101
89
  'name' => key.to_s,
102
- 'value' => value
90
+ (external ? 'valueFrom' : 'value') => value
103
91
  }
104
92
  end
105
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesHelper
4
- VERSION = '1.13.0'
4
+ VERSION = '1.13.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - owen2345