kubernetes_helper 1.19.1 → 1.20.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: e72fcd92010ce2e1144a926d617c13985b39941ff58e177f24eb8b68828bd572
4
- data.tar.gz: f0798e685be4fde2efefd86e3869e05449c871a766686537db3085f7d6cb40d9
3
+ metadata.gz: 3c37c83c9ede6fe5f9dc67a2ae7d859290bb7d40f8801aa9c5a1481d3cc51666
4
+ data.tar.gz: 5e6c15ae2245fbcad4a80369a7718f6643a5fe10db415c01174247686ee4bb7e
5
5
  SHA512:
6
- metadata.gz: fe823997d5ea50090e1389b1224cd78d9819f2c3f9c64e34451d1902aa1985b0a563f6768be1c873fcc63cc89ef06ea7494f756e2042984eb8d431f9fced8f16
7
- data.tar.gz: ed8f9612237443578f3c6f862107e1e23639458290e2389409014f001734e6e71198c5b0abde07990d53ed6c4ee408ba3ea9abf4b409669103080cddded2eda1
6
+ metadata.gz: a8dfa0eec07574b5b8452a1c1075d98e857d85df6de095765c1910826d41a5c171fb95c39a71acbf6fff025ceff2f1ba50fe3ea4f14071d0de5e16f83728a6a7
7
+ data.tar.gz: 5ca3c54401bc67fc0aedf4a8152b652b3e26682c82bb200a3743af29ad6b97c9b668ec2add1d48aa845c908fd99f734d02d1699a15b3a32e72b3a6e67511e3a5
data/README.md CHANGED
@@ -49,19 +49,45 @@ 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
- Ideal to run sidekiq or similar jobs without internet connection. (TODO)
52
+ Ideal to run sidekiq or similar jobs as a service without interacting via HTTP.
53
53
  - `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
54
54
  - `deployment.job_apps[].command` (String, optional): Bash command to be used for job container. Sample: `bundle exec sidekiq`
55
55
  - `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)
56
56
  - `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.
57
57
  - `deployment.job_apps[].resources` (Hash, optional): Configure depending on the job app requirements. Sample: `{ cpu: { max: '1', min: '500m' }, mem: { max: '1Gi', min: '500Mi' } }`
58
+ - `deployment.job_apps[].rolling_update` (Boolean, default false): Uses `rollingUpdate` strategy instead of `recreate` (https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#rolling-update-deployment)
59
+ Sample:
60
+ ```ruby
61
+ {
62
+ job_apps: [
63
+ {
64
+ name: "my-app-sidekiq",
65
+ command: 'bundle exec sidekiq',
66
+ services: %w[sidekiq],
67
+ resources: { mem: { max: '10Gi', min: '5Gi' } }
68
+ }
69
+ ]
70
+ }
71
+
72
+ ```
58
73
 
59
74
  ### Required settings for Cronjob apps (Note: Cronjobs do not support `sidekiq_alive_gem` and `services`)
60
- Ideal to asasas (TODO)
75
+ Ideal to process periodic tasks
61
76
  - `deployment.job_apps[].schedule` (String): Cron schedule. Sample: `*/5 * * * *`
62
77
  - `deployment.job_apps[].kind` (String, default `Deployment`): Kind of job application [`Deployment` or `CronJob`]
63
78
  - `deployment.job_apps[].concurrency_policy` (String, default `Forbid`): [Documentation](https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#concurrency-policy)
64
79
  - `deployment.job_apps[].suspend` (String, default `false`): If `true` then marks as finished the job application (stops creating new pods).
80
+ Sample:
81
+ ```ruby
82
+ {
83
+ job_apps: [{
84
+ name: "my-promotions-cronjob",
85
+ command: 'bundle exec rake promotions:process > ./log/promotions.log 2>&1',
86
+ schedule: '0 22 * * *',
87
+ kind: 'CronJob'
88
+ }]
89
+ }
90
+ ```
65
91
 
66
92
  ### Applications secrets.yml (Optional)
67
93
  - `secrets.name` (String): K8s secrets name where env vars will be saved and fetched from. Sample: `my-app-secrets`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesHelper
4
- VERSION = '1.19.1'
4
+ VERSION = '1.20.2'
5
5
  end
@@ -86,7 +86,8 @@ module KubernetesHelper
86
86
  command: settings[:deployment][:job_command],
87
87
  services: settings[:deployment][:job_services],
88
88
  resources: settings[:deployment][:job_resources],
89
- sidekiq_alive_gem: settings[:deployment][:job_sidekiq_alive_gem]
89
+ sidekiq_alive_gem: settings[:deployment][:job_sidekiq_alive_gem],
90
+ rolling_update: settings[:deployment][:job_rolling_update]
90
91
  }
91
92
  ]
92
93
  end
@@ -84,50 +84,10 @@ This gem comes with continuous deployment script out of the box which can be exe
84
84
  PROD_CLOUD_TOKEN=<secret content here>
85
85
  ```
86
86
 
87
- * Add github workflow to automatically run deployment when merged into master or staging, something like:
88
- ```yml
89
- name: "Continuous Deployment"
90
- on:
91
- push:
92
- branches:
93
- - master
94
- - staging
95
-
96
- deployment:
97
- runs-on: ubuntu-latest
98
- jobs:
99
- steps:
100
- - uses: actions/checkout@v2
101
- with:
102
- ref: ${{ env.DEPLOY_BRANCH }}
103
- - name: Cancel previous Workflow Actions
104
- uses: styfle/cancel-workflow-action@0.6.0
105
- with:
106
- access_token: ${{ github.token }}
107
-
108
- - name: Set up Cloud SDK
109
- uses: google-github-actions/setup-gcloud@master
110
- - uses: satackey/action-docker-layer-caching@v0.0.11
111
- continue-on-error: true
112
- with:
113
- key: CD-docker-cache-${{ hashFiles('Dockerfile', 'Gemfile.lock') }}
114
-
115
- #### App deployment
116
- - run: sudo gem install kubernetes_helper
117
- - name: App deployment
118
- env:
119
- KB_AUTH_TOKEN: ${{ github.ref_name == 'master' && secrets.PROD_CLOUD_TOKEN || secrets.BETA_CLOUD_TOKEN }}
120
- DEPLOY_ENV: ${{ github.ref_name == 'master' && 'production' || 'beta' }}
121
- run: kubernetes_helper run_deployment 'cd.sh'
122
- ```
87
+ * Add github workflow to automatically run deployment when merged into master or staging: [See here](https://github.com/owen2345/reusable-ci-cd-actions#continuous-deployment)
123
88
 
124
- ## Apply any k8s setting changes
125
- - Secrets
126
- Open kubernetes secrets and add/edit/remove values and then save it
127
- `kubectl edit secret ...`
128
- Once secrets were updated, then restart all related pods, see: https://medium.com/devops-dudes/how-to-propagate-a-change-in-kubernetes-secrets-by-restarting-dependent-pods-b71231827656
129
-
130
- - Other settings
89
+ ## Apply deployment changes manually
90
+ Note: it can be enable for auto update with (`settings.rb`): `update_deployment: true`
131
91
  ```bash
132
92
  DEPLOY_ENV=beta kubernetes_helper run_yml 'deployment.yml' 'kubectl apply'
133
- ```
93
+ ```
@@ -12,11 +12,7 @@ fi
12
12
 
13
13
  ## Build and push containers
14
14
  echo "****** building image..."
15
- <% if continuous_deployment.docker_cmd %>
16
- <%= continuous_deployment.docker_cmd %>
17
- <% else %>
18
- docker <%=continuous_deployment.docker_build_cmd || 'build -f Dockerfile'%> -t $DEPLOY_NAME .
19
- <% end %>
15
+ eval $DOCKER_BUILD_CMD
20
16
  docker push $DEPLOY_NAME
21
17
 
22
18
  echo "****** tagging image $DEPLOY_NAME as $LATEST_NAME"
@@ -23,11 +23,7 @@ if [ -z $ALREADY_DEPLOYED ]
23
23
  then
24
24
  ## Build and push containers
25
25
  echo "****** image not created yet, building image..."
26
- <% if continuous_deployment.docker_cmd %>
27
- <%= continuous_deployment.docker_cmd %>
28
- <% else %>
29
- docker <%=continuous_deployment.docker_build_cmd || 'build -f Dockerfile'%> -t $DEPLOY_NAME .
30
- <% end %>
26
+ eval $DOCKER_BUILD_CMD
31
27
  docker push $DEPLOY_NAME
32
28
  else
33
29
  echo "****** image was already created: $ALREADY_DEPLOYED"
@@ -8,7 +8,14 @@
8
8
  matchLabels:
9
9
  name: *job_app_name
10
10
  strategy:
11
+ <% if locals[:job_app][:rolling_update] %>
12
+ type: RollingUpdate
13
+ rollingUpdate:
14
+ maxSurge: 1
15
+ maxUnavailable: 0
16
+ <% else %>
11
17
  type: Recreate
18
+ <% end %>
12
19
  minReadySeconds: 10
13
20
  template:
14
21
  metadata:
data/lib/templates/cd.sh CHANGED
@@ -16,6 +16,12 @@ CI_COMMIT_SHA=${CI_COMMIT_SHA:-$(date +%s) }
16
16
  DEPLOY_NAME="${IMAGE_NAME}:${CI_COMMIT_SHA}"
17
17
  LATEST_NAME="${IMAGE_NAME}:<%= continuous_deployment.image_tag || 'latest' %>"
18
18
 
19
+ <% if continuous_deployment.docker_cmd %>
20
+ DOCKER_BUILD_CMD="<%= continuous_deployment.docker_cmd %>"
21
+ <% else %>
22
+ DOCKER_BUILD_CMD="docker <%=continuous_deployment.docker_build_cmd || 'build -f Dockerfile'%> -t $DEPLOY_NAME --build-arg DEPLOY_VERSION=${DEPLOY_VERSION} --build-arg DEPLOY_ENV=${DEPLOY_ENV} ."
23
+ <% end %>
24
+
19
25
  <%= include_template "_cd_google.sh" if continuous_deployment.image_name.include?('gcr.io/') %>
20
26
  <%= include_template "_cd_digital.sh" if continuous_deployment.image_name.include?('digitalocean.com/') %>
21
27
 
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.19.1
4
+ version: 1.20.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-07-14 00:00:00.000000000 Z
11
+ date: 2022-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb