kubernetes_helper 1.17.0 → 1.18.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 +4 -1
- data/lib/kubernetes_helper/core.rb +1 -1
- data/lib/kubernetes_helper/version.rb +1 -1
- data/lib/templates/README.md +1 -2
- data/lib/templates/cd.sh +2 -2
- data/lib/templates/deployment.yml +10 -2
- data/lib/templates/secrets.yml +3 -4
- data/lib/templates/settings.rb +2 -1
- 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: 2dbeb51cb4e066084e681ea3a15c69b56780641bfbf38efa9dc8595b785de68c
|
4
|
+
data.tar.gz: 11c03302e5c59638b3fb0fa64602be15cfc24ddd41e7818c65afc5ac4df2cf2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addb118b0d1d53ccc36843b1ca108d449aba773382ea54dbff665131a8282d9173d57b81a4b95d87a5ffa27f8dbce039fac989a36afd1d579aa48260f823515e
|
7
|
+
data.tar.gz: 17b845c6b15502d98294a82b33d08ddf6109aa2b0e49685ac1f299722980ae17f1d8fb07dc2f4242e093703a0448f20f4556fc2016bc8afdabf3b5088c7eba7d
|
data/README.md
CHANGED
@@ -57,7 +57,10 @@ Configuration and customization can be done for multiple environments and at any
|
|
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`
|
60
|
-
|
60
|
+
- `secrets.import_all_secrets` (Boolean, default false):
|
61
|
+
- `true`: Allows k8s to auto import all secrets from `secrets.yml` as env values for the apps (No longer needed to update `deployment.yml` everytime there is a new env var)
|
62
|
+
- `false`: Permits to the gem to auto include each secret from `secrets.yml -> data` as env value for the apps (base64 encoded values. Requires to update `deployment.yml` everytime there is a new env var)
|
63
|
+
|
61
64
|
### Application service.yml (Optional)
|
62
65
|
- `service.name`: K8s service name. Sample: `my-app-service`
|
63
66
|
- `service.port_name` (String, default `http-port`): Http port name to connect between k8s ingress and service. Sample: `http-port`. Note: max 15 characters
|
@@ -67,7 +67,7 @@ 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
|
+
(data['data'] || {}).keys.map do |secret|
|
71
71
|
{
|
72
72
|
'name' => secret.upcase,
|
73
73
|
'valueFrom' => { 'secretKeyRef' => { 'name' => secrets_name, 'key' => secret } }
|
data/lib/templates/README.md
CHANGED
@@ -25,9 +25,8 @@
|
|
25
25
|
DEPLOY_ENV=beta kubernetes_helper run_command "kubectl create secret generic <%=deployment.cloud_secret_name%> --from-file=credentials.json=<path-to-downloaded/credentials.json>"
|
26
26
|
```
|
27
27
|
|
28
|
-
- Register manually env vars
|
28
|
+
- Register manually env vars
|
29
29
|
Open and register secret values in `.kubernetes/secrets.yml`
|
30
|
-
Note: Enter base64 encoded values
|
31
30
|
```bash
|
32
31
|
DEPLOY_ENV=beta kubernetes_helper run_yml 'secrets.yml' 'kubectl create'
|
33
32
|
# kubectl get secrets # to list all secrets registered
|
data/lib/templates/cd.sh
CHANGED
@@ -5,7 +5,7 @@ set -e
|
|
5
5
|
SCRIPT_DIR=`dirname "$(realpath -s "$0")"` # app_dir/.kubernetes/
|
6
6
|
cd "$SCRIPT_DIR/../" # project directory
|
7
7
|
|
8
|
-
DEPLOYMENTS="<%=
|
8
|
+
DEPLOYMENTS="<%=(deployment.job_apps.map { |a| a[:name] } + [deployment.name]).join(',')%>"
|
9
9
|
IMAGE_NAME="<%=continuous_deployment.image_name%>"
|
10
10
|
CLUSTER_NAME="<%=continuous_deployment.cluster_name%>"
|
11
11
|
PROJECT_NAME="<%=continuous_deployment.project_name%>"
|
@@ -21,7 +21,7 @@ LATEST_NAME="${IMAGE_NAME}:<%= continuous_deployment.image_tag || 'latest' %>"
|
|
21
21
|
|
22
22
|
## Update new secrets defined in secrets.yml as ENV vars for deployments
|
23
23
|
<% if continuous_deployment.update_deployment %>
|
24
|
-
kubernetes_helper run_yml 'deployment.yml' 'kubectl apply'
|
24
|
+
DEPLOY_IMAGE_TAG=$CI_COMMIT_SHA kubernetes_helper run_yml 'deployment.yml' 'kubectl apply'
|
25
25
|
<% end %>
|
26
26
|
|
27
27
|
## Apply deployments
|
@@ -12,7 +12,7 @@ documents:
|
|
12
12
|
type: RollingUpdate
|
13
13
|
rollingUpdate:
|
14
14
|
maxSurge: 1
|
15
|
-
maxUnavailable:
|
15
|
+
maxUnavailable: 0
|
16
16
|
minReadySeconds: 10
|
17
17
|
template:
|
18
18
|
metadata:
|
@@ -21,13 +21,21 @@ documents:
|
|
21
21
|
spec: &template_spec
|
22
22
|
containers:
|
23
23
|
- &app_container
|
24
|
-
image: '<%= continuous_deployment.image_name %>:<%= continuous_deployment.image_tag || "latest" %>'
|
24
|
+
image: '<%= continuous_deployment.image_name %>:<%= ENV['DEPLOY_IMAGE_TAG'] || continuous_deployment.image_tag || "latest" %>'
|
25
25
|
<% if deployment.command %>
|
26
26
|
command: ["/bin/bash", "-c", "<%= deployment.command %>"]
|
27
27
|
<% end %>
|
28
28
|
name: *app_name
|
29
|
+
|
29
30
|
static_env: true
|
31
|
+
<% if secrets.import_all_secrets %>
|
32
|
+
envFrom:
|
33
|
+
- secretRef:
|
34
|
+
name: <%= secrets.name %>
|
35
|
+
<% else %>
|
30
36
|
import_secrets: ['secrets.yml', '<%=secrets.name%>']
|
37
|
+
<% end %>
|
38
|
+
|
31
39
|
ports:
|
32
40
|
- containerPort: &port <%= deployment.app_port || 3000 %>
|
33
41
|
name: '<%=service.backend_port_name || 'b-port'%>'
|
data/lib/templates/secrets.yml
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# Every Value has to be base64 encoded
|
2
1
|
# IMPORTANT: For security reason, never ever commit secret values, only keys
|
3
2
|
|
4
3
|
apiVersion: v1
|
@@ -6,6 +5,6 @@ kind: Secret
|
|
6
5
|
metadata:
|
7
6
|
name: '<%=secrets.name%>'
|
8
7
|
type: Opaque
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
stringData:
|
9
|
+
MY_KEY1: "my value1"
|
10
|
+
MY_KEY2: "my value2"
|
data/lib/templates/settings.rb
CHANGED
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.18.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-07-
|
11
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erb
|