kubernetes_helper 0.3.1 → 0.3.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: d90e5910eaf66ffcc3df7cde769ca54136f106993afe0452f003a0997ab8b802
4
- data.tar.gz: edd494736fad99801f3ce1b35e7c9c57c760a3854a6e5e213d9b502ca7fee03a
3
+ metadata.gz: 9ef481cc4f5afcb7c2bca9605b7ecc72649ac2e2522400a58e2dc964802f22bd
4
+ data.tar.gz: 2b2aa0863511f4aa192a1332d87f12c80ce1c30a435248ade3f5437192e83384
5
5
  SHA512:
6
- metadata.gz: 31415960ef3adbd3168fe0c76ba6343b85f0dbf0ef8718056b7468cf17f0db5909c8ed9cabb216d2e429171f63cd911fbb57a367de970e2656e7f820639cb338
7
- data.tar.gz: 5d94999264d596f7a3c0c483262c7b5b186b64674ad552e66607193c36c9ca72817a0cd31db1cc10d50f430d1ed66e785f7ca6876482c00989caa878c7de0dc0
6
+ metadata.gz: 7c0250a176f8acc04262bceab8cf550306006b540a4df43590b94f5bbb81e69f768fa023bcf0e88ffbd84dbd1d15964f374cf1950a6ddfc23211b1413487c380
7
+ data.tar.gz: bddf79fea09a01c9329592482866f552744ba0113952500cb3d032bf619ae2855613f8b9acc5567a87587c38f780c92e983c20338c68e5ec0289c3b455f1cbfb
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KubernetesHelper
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
@@ -0,0 +1,12 @@
1
+ - apiVersion: autoscaling/v1
2
+ kind: HorizontalPodAutoscaler
3
+ metadata:
4
+ name: <%= "#{deployment.name}-replicas" %>
5
+ spec:
6
+ scaleTargetRef:
7
+ apiVersion: apps/v1
8
+ kind: Deployment
9
+ name: <%= deployment.name %>
10
+ minReplicas: <%= deployment.replicas_range[0] %>
11
+ maxReplicas: <%= deployment.replicas_range[1] %>
12
+ targetCPUUtilizationPercentage: 50
data/lib/templates/cd.sh CHANGED
@@ -16,6 +16,8 @@ CI_COMMIT_SHA=$(git rev-parse --verify HEAD)
16
16
  DEPLOY_NAME="${IMAGE_NAME}:${CI_COMMIT_SHA}"
17
17
  LATEST_NAME="${IMAGE_NAME}:latest"
18
18
  AUTH_PATH="$SCRIPT_DIR/k8s-auth-token.json"
19
+
20
+ rm -f -- $AUTH_PATH
19
21
  echo $KB_AUTH_TOKEN >> $AUTH_PATH
20
22
 
21
23
  ## ***** GOOGLE CONNECTOR
@@ -43,5 +45,5 @@ for deployment in "${deployments[@]}"; do
43
45
  [ -z "$deployment" ] && continue # if empty value
44
46
 
45
47
  kubectl set image deployment/$deployment $deployment=$DEPLOY_NAME
46
- [ "$deployment" = "${deployments[0]}" ] && kubectl rollout status deployment/$deployment
48
+ [ "$deployment" = "${deployments[0]}" ] && kubectl rollout status deployment/$deployment || true
47
49
  done
@@ -65,6 +65,7 @@ documents:
65
65
  volumeMounts:
66
66
  - *log_volume
67
67
 
68
+ terminationGracePeriodSeconds: 120
68
69
  volumes:
69
70
  - name: cloudsql-creds
70
71
  secret:
@@ -116,3 +117,7 @@ documents:
116
117
  - *cloudsql_container
117
118
  - <<: *logs_container
118
119
  <% end %>
120
+
121
+ <% if deployment.replicas_range %>
122
+ <%= include_template "_replicas.yml.erb" %>
123
+ <% end %>
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- is_beta = ENV['DEPLOY_ENV'] == 'beta'
4
- app_name = is_beta ? 'my_beta_app' : 'my_app'
3
+ is_production = ENV['DEPLOY_ENV'] == 'production'
4
+ app_name = is_production ? 'my_app' : 'my_beta_app'
5
5
  settings = {
6
6
  deployment: {
7
7
  name: app_name,
8
- replicas: is_beta ? 1 : 2,
9
- cloud_secret_name: "#{is_beta ? 'beta' : 'production'}-cloud-secret",
8
+ replicas: is_production ? 2 : 1,
9
+ cloud_secret_name: "#{is_production ? 'production' : 'beta'}-cloud-secret",
10
10
  cloud_sql_instance: 'xxx:xxx:xxx=tcp:5432', # 5432 => postgres, 3306 => mysql
11
11
  env_vars: {}, # Sample: { 'CUSTOM_VAR' => 'value' }
12
12
  # command: '', # custom container command (default empty to be managed by Dockerfile)
@@ -19,7 +19,7 @@ settings = {
19
19
  name: "#{app_name}-ingress",
20
20
  ip_name: "#{app_name}-static-ip", # nil if static ip is not necessary
21
21
  certificate_name: "#{app_name}-lets-encrypt", # nil if ssl is not required
22
- domain_name: is_beta ? 'beta.myapp.com' : 'myapp.com' # nil if domain is not required
22
+ domain_name: is_production ? 'myapp.com' : 'beta.myapp.com' # nil if domain is not required
23
23
  },
24
24
  continuous_deployment: {
25
25
  image_name: "gcr.io/my-account/#{app_name}",
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: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - owen2345
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-03 00:00:00.000000000 Z
11
+ date: 2021-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb
@@ -40,6 +40,7 @@ files:
40
40
  - lib/kubernetes_helper/railtie.rb
41
41
  - lib/kubernetes_helper/version.rb
42
42
  - lib/templates/README.md
43
+ - lib/templates/_replicas.yml.erb
43
44
  - lib/templates/_sidekiq_alive_gem.yml.erb
44
45
  - lib/templates/cd.sh
45
46
  - lib/templates/deployment.yml