kubernetes_helper 1.16.0 → 1.17.0

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
  SHA256:
3
- metadata.gz: bd1b1fbd529561166b5e90b3ece98cd5f9abb81d1d652dcd52d62179daddbd14
4
- data.tar.gz: a6bb05e8553de13d43d7b9bc9c46ea5aa1dc03e1adca3fc286cb7b7ed73609ff
3
+ metadata.gz: 304a3005e0ef0280b53a2d108a0880a5406354a135027fb57cefff5e0ed5c437
4
+ data.tar.gz: dfb38b6b47866ca50ba1c88d11dcad20101827f93a8f617dca95b3b3e225b31d
5
5
  SHA512:
6
- metadata.gz: 5fde4038a234dafaa435aa6aca47348a090bb79d53a3ba3357a3d632b1f85a849322b70851da89674412abe5d679a72feeb30ac0b86b2de83f4dd9bc3224fb8d
7
- data.tar.gz: 89ca63330472ad00a1b06004be34c43b7de2582a509247c75d605c5aa6743b64fd653d51fe3459eb1a9d24071faf18a1632663946d274c2ff7dd425a5dc7f220
6
+ metadata.gz: d02d6bfefa1404a9a906c964c0ebb2e3979835fbcf539aeb99179cf850e08d87d1aa1c75f878ffb051fa0769a5ea19cf4ff73707bffc8aa5031eed59ee1081fa
7
+ data.tar.gz: 3b40bf03b9498aed70c286170536764bd4ebe3ee8840b197584e831cbd4e5965e27671802dc30a4481de99093e18e9d9f8066728d4e95dbbed58c61032aa61b5
data/README.md CHANGED
@@ -22,7 +22,7 @@ Configuration and customization can be done for multiple environments and at any
22
22
  Note: The local template will be used instead of the default one.
23
23
 
24
24
  3. Install/setup the application on kubernetes
25
- Open [.kubernetes/README.md](lib/templates/README.md) to see the instructions (customize the file according to your project and keep it updated)
25
+ Open [.kubernetes/README.md](lib/templates/README.md) to see the instructions (customize the file according to your project and keep it updated in your repository)
26
26
 
27
27
 
28
28
  ## Settings API
@@ -49,11 +49,11 @@ Configuration and customization can be done for multiple environments and at any
49
49
  - `deployment.logs_resources` (Hash, optional): Configure depending on the app requirements. Default: `{ cpu: { max: '200m', min: '50m' }, mem: { max: '200Mi', min: '50Mi' } }`
50
50
 
51
51
  ### Application deployment.yml for jobs or services without internet interaction (Optional)
52
- - `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
53
- - `deployment.job_command` (String, optional): Bash command to be used for job container. Sample: `bundle exec sidekiq`
54
- - `deployment.job_sidekiq_alive_gem` (Boolean, default false): If true will add liveness checker settings using `sidekiq_alive_gem` (`sidekiq_alive` gem needs to be present in your Gemfile)
55
- - `deployment.job_services` (Array, Optional, only `job_sidekiq_alive_gem` or `job_services` is allowed): List of linux service names that are required for a healthy job container. Sample: `['sidekiq', 'cron']`
56
- - `deployment.job_resources` (Hash, optional): Configure depending on the job app requirements. Sample: `{ cpu: { max: '1', min: '500m' }, mem: { max: '1Gi', min: '500Mi' } }`
52
+ - `deployment.job_apps[].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
53
+ - `deployment.job_apps[].command` (String, optional): Bash command to be used for job container. Sample: `bundle exec sidekiq`
54
+ - `deployment.job_apps[].sidekiq_alive_gem` (Boolean, default false): If true will add liveness checker settings using `sidekiq_alive_gem` (`sidekiq_alive` gem needs to be present in your Gemfile)
55
+ - `deployment.job_apps[].services` (Array, Optional): List of linux service names that are required for a healthy job container. Sample: `['sidekiq', 'cron']`. Note: This will be ignored if `sidekiq_alive_gem` was defined.
56
+ - `deployment.job_apps[].resources` (Hash, optional): Configure depending on the job app requirements. Sample: `{ cpu: { max: '1', min: '500m' }, mem: { max: '1Gi', min: '500Mi' } }`
57
57
 
58
58
  ### Applications secrets.yml (Optional)
59
59
  - `secrets.name` (String): K8s secrets name where env vars will be saved and fetched from. Sample: `my-app-secrets`
@@ -88,7 +88,7 @@ Configuration and customization can be done for multiple environments and at any
88
88
  - `continuous_deployment.update_deployment` (Boolean, default: false): If true permits to re-generate and update the k8s deployment(s) before applying the new version (new docker image)
89
89
 
90
90
  ### Gem templating partials
91
- - `_container_extra_settings.yml` Partial template to add custom container settings. Receives `pod` as local variable (`web` | `job` | `cloudsql` | `logs`). Sample:
91
+ - `_container_extra_settings.yml` Partial template to add custom container settings. Receives `pod` as local variable (`web` | `job` | `cloudsql` | `logs`) and `pod_name`. Sample:
92
92
  ```yaml
93
93
  <% if locals[:pod] == 'job' %>
94
94
  resources:
@@ -100,7 +100,7 @@ Configuration and customization can be done for multiple environments and at any
100
100
  memory: 1Gi
101
101
  <% end %>
102
102
  ```
103
- - `_custom_containers.yml` Partial template to add extra containers (Receives `pod` as local variable: `web` | `job`). Sample:
103
+ - `_custom_containers.yml` Partial template to add extra containers (Receives `pod` as local variable: `web` | `job`) and `pod_name`. Sample:
104
104
  ```yaml
105
105
  <% if locals[:pod] == 'job' %>
106
106
  - name: scraper
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesHelper
4
- VERSION = '1.16.0'
4
+ VERSION = '1.17.0'
5
5
  end
@@ -25,7 +25,8 @@ module KubernetesHelper
25
25
  deployment: {
26
26
  log_container: true,
27
27
  log_folder: '/app/log',
28
- external_secrets: {}
28
+ external_secrets: {},
29
+ job_apps: settings[:job_apps] || job_apps_from_old_settings(settings)
29
30
  },
30
31
  service: {
31
32
  port_name: 'http-port',
@@ -75,4 +76,18 @@ module KubernetesHelper
75
76
  FileUtils.cp(templates_path(name), path) unless File.exist?(path)
76
77
  end
77
78
  end
79
+
80
+ def self.job_apps_from_old_settings(settings)
81
+ return [] unless settings[:deployment][:job_name]
82
+
83
+ [
84
+ {
85
+ name: settings[:deployment][:job_name],
86
+ command: settings[:deployment][:job_command],
87
+ services: settings[:deployment][:job_services],
88
+ resources: settings[:deployment][:job_resources],
89
+ sidekiq_alive_gem: settings[:deployment][:job_sidekiq_alive_gem]
90
+ }
91
+ ]
92
+ end
78
93
  end
@@ -13,7 +13,7 @@ documents:
13
13
  rollingUpdate:
14
14
  maxSurge: 1
15
15
  maxUnavailable: 1
16
- minReadySeconds: 5
16
+ minReadySeconds: 10
17
17
  template:
18
18
  metadata:
19
19
  labels:
@@ -98,18 +98,19 @@ documents:
98
98
  volumes:
99
99
  <%= include_template "_volumes.yml", { pod: 'web' } %>
100
100
 
101
-
102
- <% if deployment.job_name %>
101
+ <% deployment.job_apps.each do |job_app| %>
103
102
  - apiVersion: apps/v1
104
103
  kind: Deployment
105
104
  metadata:
106
- name: &job_app_name <%=deployment.job_name%>
105
+ name: &job_app_name <%= job_app[:name] %>
107
106
  spec:
108
107
  <<: *default_spec
109
108
  replicas: 1
110
109
  selector:
111
110
  matchLabels:
112
111
  name: *job_app_name
112
+ strategy:
113
+ type: Recreate
113
114
  template:
114
115
  metadata:
115
116
  labels:
@@ -119,18 +120,18 @@ documents:
119
120
  containers:
120
121
  - <<: *app_container
121
122
  name: *job_app_name
122
- <% if deployment.job_command %>
123
- command: [ "/bin/bash", "-c", "<%= deployment.job_command %>" ]
123
+ <% if job_app[:command] %>
124
+ command: [ "/bin/bash", "-c", "<%= job_app[:command] %>" ]
124
125
  <% end %>
125
- <% if deployment.job_resources %>
126
- <%= include_template "_resources.yml", deployment.job_resources %>
126
+ <% if job_app[:resources] %>
127
+ <%= include_template "_resources.yml", job_app[:resources] %>
127
128
  <% end %>
128
- <%= include_template "_container_extra_settings.yml", { pod: 'job' } %>
129
+ <%= include_template "_container_extra_settings.yml", { pod: 'job', pod_name: job_app[:name] } %>
129
130
 
130
- <% if deployment.job_sidekiq_alive_gem %>
131
- <%= include_template "_sidekiq_alive_gem.yml" %>
131
+ <% if job_app[:sidekiq_alive_gem] %>
132
+ <%= include_template "_sidekiq_alive_gem.yml" %>
132
133
  <% else %>
133
- <%= include_template "_job_liveness.yml" %>
134
+ <%= include_template "_job_liveness.yml" %>
134
135
  <% end %>
135
136
 
136
137
  <% if deployment.cloud_secret_name %>
@@ -141,10 +142,10 @@ documents:
141
142
  - <<: *logs_container
142
143
  <% end %>
143
144
 
144
- <%= include_template "_custom_containers.yml", { pod: 'job' } %>
145
+ <%= include_template "_custom_containers.yml", { pod: 'job', pod_name: job_app[:name] } %>
145
146
 
146
147
  volumes:
147
- <%= include_template "_volumes.yml", { pod: 'job' } %>
148
+ <%= include_template "_volumes.yml", { pod: 'job', pod_name: job_app[:name] } %>
148
149
  <% end %>
149
150
 
150
151
  <% if deployment.replicas_range %>
@@ -12,10 +12,14 @@ settings = {
12
12
  env_vars: {}, # Sample: { 'CUSTOM_VAR' => 'value' }
13
13
  # command: '', # custom container command (default empty to be managed by Dockerfile)
14
14
  # liveness_path: '/check_liveness', # nil if not exist
15
- # job_name: "#{app_name}-job", # enable if there is any background service
16
- # job_command: 'bundle exec sidekiq -C config/sidekiq.yml',
17
- # job_services: ['sidekiq', 'cron'] # list of linux services needed.
18
15
  # custom_volumes: { my_volume: { kind: 'hostPath', mount_path: '/', settings: { path: '..', type: 'Directory' } } }
16
+ job_apps: [
17
+ # {
18
+ # name: "#{app_name}-job", # enable if there is any background service
19
+ # command: 'bundle exec sidekiq -C config/sidekiq.yml',
20
+ # services: ['sidekiq', 'cron'] # list of linux services needed.
21
+ # }
22
+ ]
19
23
  },
20
24
  secrets: {
21
25
  name: "#{app_name}-secrets"
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.16.0
4
+ version: 1.17.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-04-28 00:00:00.000000000 Z
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb