kubernetes_helper 1.10.0 → 1.11.3

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: ad11b73ac23d45b86c9b5789ae815af2ee565d6360462368e96c4b15dfcc3301
4
- data.tar.gz: 61df31315a5b137c9e1c4575002b875f87175d72d5319cf0e1439d8c01afaee6
3
+ metadata.gz: 235b38e0301bf3d021a192dc336183f89bd3ca214d5c5464b701d4ed03e1faef
4
+ data.tar.gz: 28ffb4e42d000427b08643c14f24b626d2ee78ace071219bddaf64b35b7b88af
5
5
  SHA512:
6
- metadata.gz: f1a177f81e8bf2a9337d233369c39dd7cc42e2baf0c7dca7fdba25984d86014837db2207bcab10a1b9f8b8bc2060b55dee8c0dc0054074ac4846592856c8d778
7
- data.tar.gz: 8be87c0b86cc7e4a7711d20d6360e96d5b99d7655ea3a3bed0a8291dec59cc552a9a326911355d2427f0e5548c0976045d7d28204af1c9dcee2c5fd1bc2af1f9
6
+ metadata.gz: f8556cd967823100b097347f1a02e2e8681ab16e319c44faf5baa959accb3ca52c08339c1eb1ca04f61c712f63d8e8b76e51e21c5caa1da78e8f79c82c541d8e
7
+ data.tar.gz: bdbf65ea0309743fb11567d30b2be2bea66382932553a253860762aef5637e04781e07fc78119735d1d9ea30d2e0854d2c58478cc75627b4f100e2710e6973e2
data/README.md CHANGED
@@ -54,8 +54,8 @@ it looks for the file inside kubernetes_helper template folder.
54
54
 
55
55
  ## Settings API
56
56
  Below settings are used when running Continuous Deployment
57
- - `continuous_deployment.image_name` (String, Optional): Partial docker image url where `:latest` will be automatically added. Sample: `gcr.io/my-account/my_app_name`
58
- - `continuous_deployment.image` (String, Optional, is mandatory if `image_name` is empty): Full docker image url. Sample: `gcr.io/my-account/my_app_name:latest`
57
+ - `continuous_deployment.image_name` (String): Partial docker image url. Sample: `gcr.io/my-account/my_app_name`
58
+ - `continuous_deployment.image_tag` (String, default 'latest'): Image tag to be used for this application
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`
@@ -71,7 +71,9 @@ Below settings are used when configuring the application in the k8s environment
71
71
  - `deployment.env_vars` (Hash, optional): List of static env variables (Note: Not recommended for sensitive values). Sample: `{ 'RAILS_ENV' => 'production' }`
72
72
  - `deployment.command` (String, Optional): Bash command to be used for web containers. Sample: `rails s -b 0.0.0.0`
73
73
  - `deployment.liveness_path` (String, Optional): Relative path to be used for readiness and liveness checker of the web app. Sample: `/check_liveness`
74
- - `deployment.custom_volumes` (Hash<name: path>, Optional): Custom volumes to be mounted. Sample: `{ my_volume: { kind: 'hostPath', mount_path: '/', settings: { path: '..', type: 'Directory' } } }`
74
+ - `deployment.custom_volumes` (Hash<name: path>, Optional): Custom volumes to be mounted.
75
+ Sample volume: `{ my_volume: { kind: 'hostPath', mount_path: '/', settings: { path: '..', type: 'Directory' } } }`
76
+ Sample secret: `{ pubsub_secret: { kind: 'secret', mount_path: '/secrets/pubsub', settings: { secretName: 'my_secret_name' } } }`
75
77
 
76
78
  - `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
77
79
  - `deployment.job_command` (String, optional): Bash command to be used for job container. Sample: `bundle exec sidekiq`
@@ -90,6 +92,8 @@ Below settings are used when configuring the application in the k8s environment
90
92
  - `ingress.certificate_name` (Optional): Ssl certificate is not created nor assigned if empty value. Sample: `my-app-lets-encrypt`. Note: requires `certificate_domain`
91
93
  - `ingress.certificate_domain` (Optional): Domain name for the certificate. Sample: `myapp.com`. Note: does not support for willcard domains
92
94
 
95
+ - `cloud.name` (String, optional): Cloud service name. Default `gcloud`.
96
+
93
97
  ### Partials
94
98
  - `_container_extra_settings.yml` Partial template to add custom container settings. Receives `pod` as local variable (`web` | `job` | `cloudsql` | `logs`). Sample:
95
99
  ```yaml
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesHelper
4
- VERSION = '1.10.0'
4
+ VERSION = '1.11.3'
5
5
  end
@@ -3,7 +3,7 @@
3
3
  livenessProbe: &liveness_probe
4
4
  exec:
5
5
  command: [ /bin/sh, -c,
6
- 'if [ $(ps -ef | grep "<%= deployment.job_services.join("\|") %>" | grep -v "grep" | wc -l) -lt <%= deployment.job_services.count %> ]; then
6
+ 'if [ $(ps -ef | grep "<%= deployment.job_services.join("\\|") %>" | grep -v "grep" | wc -l) -lt <%= deployment.job_services.count %> ]; then
7
7
  echo "Some required services are not running"; exit 1;
8
8
  fi' ]
9
9
  initialDelaySeconds: 120
@@ -8,7 +8,6 @@
8
8
  emptyDir: {}
9
9
 
10
10
  # Custom volumes
11
- # { my_volume: { kind: 'hostPath', mount_path: '/', settings: { path: '..', type: 'Directory' } } }
12
11
  <% (deployment.custom_volumes || {}).each do |name, vol| %>
13
12
  - name: <%= name %>
14
13
  <%= vol[:kind] %>:
data/lib/templates/cd.sh CHANGED
@@ -15,7 +15,7 @@ DOCKER_BUILD_CMD="<%=continuous_deployment.docker_build_cmd || 'build -f Dockerf
15
15
  CI_COMMIT_SHA=$(git rev-parse --verify HEAD || :)
16
16
  CI_COMMIT_SHA=${CI_COMMIT_SHA:-$(date +%s) }
17
17
  DEPLOY_NAME="${IMAGE_NAME}:${CI_COMMIT_SHA}"
18
- LATEST_NAME="${IMAGE_NAME}:latest"
18
+ LATEST_NAME="${IMAGE_NAME}:<%= continuous_deployment.image_tag || 'latest' %>"
19
19
 
20
20
  if [ ! -z "$KB_AUTH_TOKEN" ]
21
21
  then
@@ -37,10 +37,17 @@ then
37
37
  fi
38
38
 
39
39
 
40
- ## Build and push containers
41
- docker $DOCKER_BUILD_CMD -t $DEPLOY_NAME .
40
+ ALREADY_DEPLOYED="$(gcloud container images list-tags --format='get(tags)' $IMAGE_NAME | grep $CI_COMMIT_SHA || :;)"
41
+ if [ -z $ALREADY_DEPLOYED ]
42
+ then
43
+ ## Build and push containers
44
+ echo "****** image not created yet, building image..."
45
+ docker $DOCKER_BUILD_CMD -t $DEPLOY_NAME .
46
+ docker push $DEPLOY_NAME
47
+ fi
48
+
49
+ echo "****** tagging image $DEPLOY_NAME as $LATEST_NAME"
42
50
  docker tag $DEPLOY_NAME $LATEST_NAME
43
- docker push $DEPLOY_NAME
44
51
  docker push $LATEST_NAME
45
52
 
46
53
  ## Update new secrets defined in secrets.yml as ENV vars for deployments
@@ -54,5 +61,4 @@ for deployment in "${deployments[@]}"; do
54
61
  [ -z "$deployment" ] && continue # if empty value
55
62
 
56
63
  <%= include_template "_cd_apply_images.sh" %>
57
- done
58
-
64
+ done
@@ -21,12 +21,7 @@ documents:
21
21
  spec: &template_spec
22
22
  containers:
23
23
  - &app_container
24
- <% if continuous_deployment.image_name %>
25
- image: '<%= continuous_deployment.image_name %>:latest'
26
- <% else %>
27
- image: '<%= continuous_deployment.image %>'
28
- <% end %>
29
-
24
+ image: '<%= continuous_deployment.image_name %>:<%= continuous_deployment.image_tag || "latest" %>'
30
25
  <% if deployment.command %>
31
26
  command: ["/bin/bash", "-c", "<%= deployment.command %>"]
32
27
  <% end %>
@@ -24,7 +24,8 @@ settings = {
24
24
  certificate_domain: is_production ? 'myapp.com' : 'beta.myapp.com' # nil if domain is not required
25
25
  },
26
26
  continuous_deployment: {
27
- image: "gcr.io/my-account/#{app_name}:latest",
27
+ image_name: "gcr.io/my-account/#{app_name}",
28
+ image_tag: 'latest',
28
29
  project_name: 'my-project-name',
29
30
  cluster_name: 'my-cluster-name',
30
31
  cluster_region: 'europe-west4-a',
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.10.0
4
+ version: 1.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - owen2345
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-03 00:00:00.000000000 Z
11
+ date: 2022-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb