kubernetes_helper 1.12.6 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/lib/kubernetes_helper/core.rb +15 -1
- data/lib/kubernetes_helper/version.rb +1 -1
- data/lib/kubernetes_helper.rb +7 -2
- data/lib/templates/deployment.yml +2 -2
- data/lib/templates/settings.rb +6 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7530d88e0f3442c2db0a7fa75d66fd03cac567ea179063ad57d14dcb87e98db
|
4
|
+
data.tar.gz: 21acb0413b2b62935e442a5ac4b03650ff8fc5e6eba8d7bb6daba0c94ecd937d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb2a26a7704e7500a37f06a5d6f56b5dd6979b68283324213e612ace1a9d45204714c761e0737cfd64d9e41700bdcfd6e143d1bcc4c6f957e4f7c29c479410d0
|
7
|
+
data.tar.gz: 59443675ec5cc8705383458ec25de2e3a0fd3488fcb5dbf575cf9375f4b63983d6d01089d8641e5f14be47c99cb5107bb307977858a9dcb29a69aa46789713c6
|
data/README.md
CHANGED
@@ -71,12 +71,17 @@ Below settings are used when configuring the application in the k8s environment
|
|
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
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`
|
77
|
+
|
74
78
|
- `deployment.command` (String, Optional): Bash command to be used for web containers. Sample: `rails s -b 0.0.0.0`
|
75
79
|
- `deployment.liveness_path` (String, Optional): Relative path to be used for readiness and liveness checker of the web app. Sample: `/check_liveness`
|
76
80
|
- `deployment.custom_volumes` (Hash<name: path>, Optional): Custom volumes to be mounted.
|
77
81
|
Sample volume: `{ my_volume: { kind: 'hostPath', mount_path: '/', settings: { path: '..', type: 'Directory' } } }`
|
78
82
|
Sample secret: `{ pubsub_secret: { kind: 'secret', mount_path: '/secrets/pubsub', settings: { secretName: 'my_secret_name' } } }`
|
79
83
|
- `deployment.log_container` (Boolean, default true): Permits to auto include logs container to print all logs from logs/*.log to stdout (required for papertrail using fluentd)
|
84
|
+
- `deployment.log_folder` (String, default `/app/log`): Logs to be printed from
|
80
85
|
- `deployment.app_port` (Integer, default 3000): Application port number
|
81
86
|
|
82
87
|
- `deployment.job_name` (String, optional): Job deployment name (Note: Underscores are not accepted). Sample: `my-app-job`. Note: This deployment is created only if this value is present
|
@@ -88,8 +93,8 @@ Below settings are used when configuring the application in the k8s environment
|
|
88
93
|
- `secrets.name` (String): K8s secrets name where env vars will be saved and fetched from. Sample: `my-app-secrets`
|
89
94
|
|
90
95
|
- `service.name`: K8s service name. Sample: `my-app-service`
|
91
|
-
- `service.port_name
|
92
|
-
- `service.backend_port_name` (String): Web backend port name to be connected between k8s service and web deployments. Sample: `b-port`. Note: max 15 characters
|
96
|
+
- `service.port_name` (String, default `http-port`): Http port name to connect between k8s ingress and service. Sample: `http-port`. Note: max 15 characters
|
97
|
+
- `service.backend_port_name` (String, default `b-port`): Web backend port name to be connected between k8s service and web deployments. Sample: `b-port`. Note: max 15 characters
|
93
98
|
|
94
99
|
- `ingress.name`: Name of k8s ingress for the app: Sample: `my-app-ingress`
|
95
100
|
- `ingress.ip_name` (Optional): Static ip address is not created nor assigned if empty value. Sample: `my-app-static-ip`
|
@@ -67,12 +67,26 @@ 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
|
-
data['data'].keys.map do |secret|
|
70
|
+
secrets = 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
|
76
90
|
end
|
77
91
|
|
78
92
|
def render_template(template_name, locals = {})
|
data/lib/kubernetes_helper.rb
CHANGED
@@ -23,9 +23,14 @@ module KubernetesHelper
|
|
23
23
|
name: 'gcloud'
|
24
24
|
},
|
25
25
|
deployment: {
|
26
|
-
log_container: true
|
26
|
+
log_container: true,
|
27
|
+
log_folder: '/app/log',
|
28
|
+
external_secrets: {}
|
29
|
+
},
|
30
|
+
service: {
|
31
|
+
port_name: 'http-port',
|
32
|
+
backend_port_name: 'b-port'
|
27
33
|
},
|
28
|
-
service: {},
|
29
34
|
secrets: {},
|
30
35
|
continuous_deployment: {},
|
31
36
|
ingress: {}
|
@@ -48,7 +48,7 @@ documents:
|
|
48
48
|
<% if deployment.log_container %>
|
49
49
|
- &log_volume
|
50
50
|
name: applog
|
51
|
-
mountPath:
|
51
|
+
mountPath: <%= deployment.log_folder %>
|
52
52
|
<% end %>
|
53
53
|
|
54
54
|
<% if deployment.cloud_secret_name %>
|
@@ -80,7 +80,7 @@ documents:
|
|
80
80
|
- &logs_container # print to stdout all log files
|
81
81
|
name: print-logs
|
82
82
|
image: busybox
|
83
|
-
command: [/bin/sh, -c, 'until find
|
83
|
+
command: [/bin/sh, -c, 'until find <%= deployment.log_folder %>/*.log; do sleep 1; done; tail -n+1 -f <%= deployment.log_folder %>/*.log']
|
84
84
|
env: []
|
85
85
|
volumeMounts:
|
86
86
|
- *log_volume
|
data/lib/templates/settings.rb
CHANGED
@@ -17,6 +17,12 @@ settings = {
|
|
17
17
|
# job_services: ['sidekiq', 'cron'] # list of linux services needed.
|
18
18
|
# custom_volumes: { my_volume: { kind: 'hostPath', mount_path: '/', settings: { path: '..', type: 'Directory' } } }
|
19
19
|
},
|
20
|
+
secrets: {
|
21
|
+
name: "#{app_name}-secrets"
|
22
|
+
},
|
23
|
+
service: {
|
24
|
+
name: app_name,
|
25
|
+
},
|
20
26
|
ingress: {
|
21
27
|
name: "#{app_name}-ingress",
|
22
28
|
ip_name: "#{app_name}-static-ip", # nil if static ip is not necessary
|
@@ -32,14 +38,6 @@ settings = {
|
|
32
38
|
docker_build_cmd: 'build -f Dockerfile', # using target: 'build --target production -f Dockerfile '
|
33
39
|
update_deployment: false # permits to reload secrets and re-generate/update deployment yaml
|
34
40
|
},
|
35
|
-
secrets: {
|
36
|
-
name: "#{app_name}-secrets"
|
37
|
-
},
|
38
|
-
service: {
|
39
|
-
name: app_name,
|
40
|
-
port_name: 'http-port', # max 15 characters
|
41
|
-
backend_port_name: 'b-port' # max 15 characters
|
42
|
-
}
|
43
41
|
}
|
44
42
|
|
45
43
|
KubernetesHelper.settings(settings)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubernetes_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- owen2345
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erb
|