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 +4 -4
- data/README.md +3 -4
- data/lib/kubernetes_helper/core.rb +4 -16
- data/lib/kubernetes_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 071cbd7243cf091dddbb90ae098afb3af88e8469c0b5db41a22f631907f1e529
|
4
|
+
data.tar.gz: c3d0a6f4bf022441862921cfca4fd3d8be219309a23312c15f693c15ce88f1b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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).
|
74
|
-
|
75
|
-
|
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
|
-
|
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
|