kubernetes_helper 1.12.8 → 1.13.2

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: fa7e78cceeb40228bdfb3dea0d9e89e9beb112e484eb61ca8e7302716b69abd4
4
- data.tar.gz: 1b6eda67f29f936e66714f08b538ef868b1f3e3c76f67d3e4f2e09098898e5a1
3
+ metadata.gz: 9257b84ef107ed3b39ce537325de4357b348023becbf0f14fcf761bdf652d3f0
4
+ data.tar.gz: 77abef0bae873a41b1ed2fce90d49c55f07b43acbef6b578ae9b0e7f45716893
5
5
  SHA512:
6
- metadata.gz: 2c7816fd3c3cea7dc303f2923b453338f4ad976cf577bea302d75e0b7c84ee0dee98fc58d06b76c9816de0dc14cb31b8ea0aa19ce7e5cc768bb20faf76cbee7e
7
- data.tar.gz: ea90240216df3170b2185203cc1d27688950eb83130caee7e339b368501dfeb1c613a480895c17dadb7a3e235b3338cabd80871079b0a5d428b4309e7c3949be
6
+ metadata.gz: f2798fb189f4e2ab77507dd8095d0f2741ef70d163a03d98f734f6d4772395b7521c77aed051a97a9d5241fca3ef0d8cdc0d19c4ea430ea81ed0af7e4d9f89ca
7
+ data.tar.gz: 4446e493e3cb37ec030d99e1ede09738bce1e8cd17f16f35c95ded98c1a18213cb7997d03d7b3e6c6c59d273fcf5468a09cd709aaaca6f87859bfa5f44d419f5
data/README.md CHANGED
@@ -59,10 +59,11 @@ Below settings are used when running Continuous Deployment
59
59
  - `continuous_deployment.project_name`: Cloud project name. Sample: `my-project-name`
60
60
  - `continuous_deployment.cluster_name`: Cluster cluster name. Sample: `my-cluster-name`
61
61
  - `continuous_deployment.cluster_region`: Cluster region name. Sample: `europe-west4-a`
62
- - `continuous_deployment.docker_build_cmd`: Docker command to build the corresponding image. Sample: `build --target production -f Dockerfile `
62
+ - `continuous_deployment.docker_build_cmd` (deprecated): Docker command to build the corresponding image. Sample: `build --target production -f Dockerfile `
63
+ - `continuous_deployment.docker_cmd` (String): Docker command to build the corresponding image.
64
+ Simple docker image: `docker build -f Dockerfile -t $DEPLOY_NAME .`
65
+ Docker image with target: `docker build --target production -f Dockerfile -t $DEPLOY_NAME .`
63
66
  - `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)
64
- - `continuous_deployment.before_building_image` (String, default: empty): Add the ability to enter commands before building docker image
65
- - `continuous_deployment.after_building_image` (String, default: empty): Add the ability to enter commands after building docker image
66
67
 
67
68
  Below settings are used when configuring the application in the k8s environment
68
69
  - `deployment.name` (String): Web deployment name (Note: Underscores are not accepted). Sample: `my-app`
@@ -70,7 +71,10 @@ Below settings are used when configuring the application in the k8s environment
70
71
  - `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
72
  - `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
73
  - `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.env_vars` (Hash, optional): List of static or external env variables (Note: Not recommended for sensitive values).
75
+ Sample: `{ 'RAILS_ENV' => 'production' }`
76
+ 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
+
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.
@@ -83,9 +83,11 @@ module KubernetesHelper
83
83
 
84
84
  def static_env_vars
85
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
86
88
  {
87
89
  'name' => key.to_s,
88
- 'value' => value
90
+ (external ? 'valueFrom' : 'value') => value
89
91
  }
90
92
  end
91
93
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesHelper
4
- VERSION = '1.12.8'
4
+ VERSION = '1.13.2'
5
5
  end
@@ -24,7 +24,8 @@ module KubernetesHelper
24
24
  },
25
25
  deployment: {
26
26
  log_container: true,
27
- log_folder: '/app/log'
27
+ log_folder: '/app/log',
28
+ external_secrets: {}
28
29
  },
29
30
  service: {
30
31
  port_name: 'http-port',
data/lib/templates/cd.sh CHANGED
@@ -10,7 +10,6 @@ IMAGE_NAME="<%=continuous_deployment.image_name%>"
10
10
  CLUSTER_NAME="<%=continuous_deployment.cluster_name%>"
11
11
  PROJECT_NAME="<%=continuous_deployment.project_name%>"
12
12
  CLUSTER_REGION="<%=continuous_deployment.cluster_region%>"
13
- DOCKER_BUILD_CMD="<%=continuous_deployment.docker_build_cmd || 'build -f Dockerfile'%>"
14
13
 
15
14
  CI_COMMIT_SHA=$(git rev-parse --verify HEAD || :)
16
15
  CI_COMMIT_SHA=${CI_COMMIT_SHA:-$(date +%s) }
@@ -42,9 +41,11 @@ if [ -z $ALREADY_DEPLOYED ]
42
41
  then
43
42
  ## Build and push containers
44
43
  echo "****** image not created yet, building image..."
45
- <%=continuous_deployment.before_building_image || ''%>
46
- docker $DOCKER_BUILD_CMD -t $DEPLOY_NAME .
47
- <%=continuous_deployment.after_building_image || ''%>
44
+ <% if continuous_deployment.docker_cmd %>
45
+ <%= continuous_deployment.docker_cmd %>
46
+ <% else %>
47
+ docker <%=continuous_deployment.docker_build_cmd || 'build -f Dockerfile'%> -t $DEPLOY_NAME .
48
+ <% end %>
48
49
  docker push $DEPLOY_NAME
49
50
  else
50
51
  echo "****** image was already created: $ALREADY_DEPLOYED"
@@ -35,7 +35,7 @@ settings = {
35
35
  project_name: 'my-project-name',
36
36
  cluster_name: 'my-cluster-name',
37
37
  cluster_region: 'europe-west4-a',
38
- docker_build_cmd: 'build -f Dockerfile', # using target: 'build --target production -f Dockerfile '
38
+ docker_cmd: 'docker build -f Dockerfile -t $DEPLOY_NAME .', # using target: 'docker build --target production -f Dockerfile -t $DEPLOY_NAME .'
39
39
  update_deployment: false # permits to reload secrets and re-generate/update deployment yaml
40
40
  },
41
41
  }
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.12.8
4
+ version: 1.13.2
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-16 00:00:00.000000000 Z
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb