rubypitaya 1.6.0 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubypitaya/app-template/Gemfile +1 -1
  3. data/lib/rubypitaya/app-template/Gemfile.lock +2 -2
  4. data/lib/rubypitaya/app-template/Makefile +9 -1
  5. data/lib/rubypitaya/app-template/docker-compose.yml +3 -3
  6. data/lib/rubypitaya/app-template/docker/dev/Dockerfile +1 -1
  7. data/lib/rubypitaya/app-template/docker/prod/Dockerfile +1 -1
  8. data/lib/rubypitaya/app-template/kubernetes/README.md +60 -0
  9. data/lib/rubypitaya/app-template/kubernetes/deployment-connector.yaml +35 -0
  10. data/lib/rubypitaya/app-template/kubernetes/deployment-rubypitaya.yaml +48 -0
  11. data/lib/rubypitaya/app-template/kubernetes/persistent-volume.yaml +11 -0
  12. data/lib/rubypitaya/app-template/kubernetes/service-connector.yaml +12 -0
  13. data/lib/rubypitaya/app-template/kubernetes/service-etcd.yaml +17 -0
  14. data/lib/rubypitaya/app-template/kubernetes/service-nats.yaml +12 -0
  15. data/lib/rubypitaya/app-template/kubernetes/service-postgres.yaml +12 -0
  16. data/lib/rubypitaya/app-template/kubernetes/service-redis.yaml +13 -0
  17. data/lib/rubypitaya/app-template/kubernetes/service-rubypitaya.yaml +12 -0
  18. data/lib/rubypitaya/app-template/kubernetes/statefulset-etcd.yaml +25 -0
  19. data/lib/rubypitaya/app-template/kubernetes/statefulset-nats.yaml +23 -0
  20. data/lib/rubypitaya/app-template/kubernetes/statefulset-postgres.yaml +37 -0
  21. data/lib/rubypitaya/app-template/kubernetes/statefulset-redis.yaml +23 -0
  22. data/lib/rubypitaya/core/database_config.rb +2 -0
  23. data/lib/rubypitaya/core/redis_connector.rb +7 -8
  24. data/lib/rubypitaya/version.rb +1 -1
  25. metadata +16 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3c2d65cb66c8a89ffc58b797ccef1f404d81056f912d98f7e656ea63271e5c7
4
- data.tar.gz: b8d089767fa6fff1c092fa570fcf730fdf77e83a656669ad71204a67585345e5
3
+ metadata.gz: f956732e23359892f97cd275d3d258b6937374f7f8e7ddb40f5d97d0abcce272
4
+ data.tar.gz: '09c66465d85c6814a83833afecec31dafdc229111d63a9534ba5a7fc2258921a'
5
5
  SHA512:
6
- metadata.gz: aa66e24ec0a0027136ebcd4d329f2b4fa3c7ee1347343d002b5e9d875040e7cfaf894bdd595060dfbacc43e0f102a760bcbf9177871cb4814e1c98bc5be1865c
7
- data.tar.gz: 37d7f64a4417a6544a8f9f3faca2f700dfdf7489de03c4f3321de1e359edc903281402b1ada1f8c31fc349756a900f0a796760b339193d46aac34da48a148f85
6
+ metadata.gz: e1c97191adfaac2e829355814ee88fcc3cc999b09219296ef3abe509eb2fbee6422044095bb220a0cb5fd23cb1b80ceb7d2b17773710c4d23470c10993226f23
7
+ data.tar.gz: 5c49869cb24b420f4a7bc4d7c255c1b29fae2adf550ccd0ebc3dfb74a2ccafc72f7c09ed41217dedff0fc33c68c893bcca21f5239f37df282d12ead48d59a0d4
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem 'rubypitaya', '1.6.0'
3
+ gem 'rubypitaya', '1.7.2'
4
4
 
5
5
  group :development do
6
6
  gem 'pry', '0.12.2'
@@ -62,7 +62,7 @@ GEM
62
62
  diff-lcs (>= 1.2.0, < 2.0)
63
63
  rspec-support (~> 3.8.0)
64
64
  rspec-support (3.8.3)
65
- rubypitaya (1.6.0)
65
+ rubypitaya (1.7.2)
66
66
  activerecord (= 6.0.2)
67
67
  etcdv3 (= 0.10.2)
68
68
  eventmachine (= 1.2.7)
@@ -85,7 +85,7 @@ DEPENDENCIES
85
85
  pry (= 0.12.2)
86
86
  rake (= 10.0)
87
87
  rspec (= 3.8.0)
88
- rubypitaya (= 1.6.0)
88
+ rubypitaya (= 1.7.2)
89
89
 
90
90
  BUNDLED WITH
91
91
  1.17.2
@@ -44,7 +44,15 @@ generate-gemfilelock:
44
44
 
45
45
  ## Build image to production environment
46
46
  prod-build-image:
47
- @docker build . -f docker/prod/Dockerfile -t rubypitaya-prod:latest
47
+ @docker build . -f docker/prod/Dockerfile -t [registry-address]:$(IMAGE_TAG)
48
+
49
+ ## Push prod image to gitlab
50
+ prod-push-image:
51
+ @docker push [registry-address]:$(IMAGE_TAG)
52
+
53
+ ## Deploy prod image to kubernetes cluster
54
+ prod-deploy-image:
55
+ kubectl -n $(PROD_NAMESPACE) set image deployment rubypitaya rubypitaya=[registry-address]:$(IMAGE_TAG)
48
56
 
49
57
  .DEFAULT_GOAL := show-help
50
58
 
@@ -12,7 +12,7 @@ services:
12
12
  - '2380:2380'
13
13
 
14
14
  redis:
15
- image: 'redis:3.2.5-alpine'
15
+ image: 'redis:6.0.5-alpine'
16
16
  ports:
17
17
  - '9001:6379'
18
18
 
@@ -22,7 +22,7 @@ services:
22
22
  - 'postgres:/var/lib/postgresql/data'
23
23
  environment:
24
24
  POSTGRES_USER: 'postgres'
25
- POSTGRES_HOST_AUTH_METHOD: 'trust'
25
+ POSTGRES_PASSWORD: 'postgres'
26
26
  ports:
27
27
  - '9100:5432'
28
28
 
@@ -67,7 +67,7 @@ services:
67
67
  REDIS_URL: 'redis://redis:6379'
68
68
  DATABASE_HOST: 'db'
69
69
  DATABASE_USER: 'postgres'
70
- DATABASE_PASSWORD: ''
70
+ DATABASE_PASSWORD: 'postgres'
71
71
  DATABASE_NAME: 'ruby_pitaya'
72
72
 
73
73
  volumes:
@@ -16,4 +16,4 @@ ENV LC_ALL=C.UTF-8
16
16
 
17
17
  ENTRYPOINT ["./docker/entrypoint.sh"]
18
18
 
19
- CMD ["bundle", "exec", "rubypitaya"]
19
+ CMD ["bundle", "exec", "rubypitaya", "run"]
@@ -29,4 +29,4 @@ ENV LC_ALL=C.UTF-8
29
29
 
30
30
  ENTRYPOINT ["./docker/entrypoint.sh"]
31
31
 
32
- CMD ["bundle", "exec", "rubypitaya"]
32
+ CMD ["bundle", "exec", "rubypitaya", "run"]
@@ -0,0 +1,60 @@
1
+ Kubernetes Configuration
2
+ ========================
3
+
4
+ Set namespace
5
+ -------------
6
+
7
+ Open files "deployment-*.yaml" and set the correct namespace on links
8
+
9
+
10
+ Apply sequence
11
+ --------------
12
+
13
+ Run the following command on the listed files.
14
+ But remember to put your namespace and your KUBECONFIG env var if you need.
15
+
16
+ ```sh
17
+ $ kubectl apply -f [file-path]
18
+ ```
19
+
20
+ persistent-volume.yaml
21
+
22
+ statefulset-etcd.yaml
23
+ statefulset-nats.yaml
24
+ statefulset-postgres.yaml
25
+ statefulset-redis.yaml
26
+
27
+ service-etcd.yaml
28
+ service-nats.yaml
29
+ service-postgres.yaml
30
+ service-redis.yaml
31
+
32
+ deployment-connector.yaml
33
+ service-connector.yaml
34
+
35
+
36
+ Create gitlab-registry secret
37
+ -----------------------------
38
+
39
+ Run the following command.
40
+ But remember to put your namespace and your KUBECONFIG env var if you need.
41
+
42
+ ```sh
43
+ $ kubectl create secret docker-registry gitlab-registry --docker-server=[registry-server] --docker-username=[username] --docker-password=[password]
44
+ ```
45
+
46
+ If you use a different registry name instead of "gitlab-registry" change the deployment-rubypitaya.yaml imagePullSecrets.name
47
+
48
+
49
+ Apply sequence
50
+ --------------
51
+
52
+ Run the following command on the listed files.
53
+ But remember to put your namespace and your KUBECONFIG env var if you need.
54
+
55
+ ```sh
56
+ $ kubectl apply -f [file-path]
57
+ ```
58
+
59
+ deployment-rubypitaya.yaml
60
+ service-rubypitaya.yaml
@@ -0,0 +1,35 @@
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: connector
5
+ labels:
6
+ app: connector
7
+ spec:
8
+ replicas: 1
9
+ selector:
10
+ matchLabels:
11
+ app: connector
12
+ template:
13
+ metadata:
14
+ labels:
15
+ app: connector
16
+ spec:
17
+ containers:
18
+ - name: connector
19
+ image: registry.gitlab.com/lucianopc/pitaya-connector:0.2.0
20
+ ports:
21
+ - containerPort: 3250
22
+ name: connector
23
+ env:
24
+ - name: PITAYA_CLUSTER_RPC_SERVER_NATS_CONNECT
25
+ value: "nats://nats.default.svc.cluster.local:4222"
26
+ - name: PITAYA_CLUSTER_RPC_CLIENT_NATS_CONNECT
27
+ value: "nats://nats.default.svc.cluster.local:4222"
28
+ - name: PITAYA_CLUSTER_RPC_CLIENT_NATS_REQUESTTIMEOUT
29
+ value: "10s"
30
+ - name: PITAYA_CLUSTER_SD_ETCD_ENDPOINTS
31
+ value: "etcd.default.svc.cluster.local:2379"
32
+ - name: PITAYA_CLUSTER_SD_ETCD_PREFIX
33
+ value: "rubypitaya/"
34
+ - name: SERVER_ROUTES
35
+ value: "rubypitaya"
@@ -0,0 +1,48 @@
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: rubypitaya
5
+ labels:
6
+ app: rubypitaya
7
+ spec:
8
+ replicas: 1
9
+ selector:
10
+ matchLabels:
11
+ app: rubypitaya
12
+ template:
13
+ metadata:
14
+ labels:
15
+ app: rubypitaya
16
+ spec:
17
+ containers:
18
+ - name: rubypitaya
19
+ image: git.topfreegames.com:4567/prestes/tech-prototype/rubypitaya:latest
20
+ command: ["bundle", "exec", "rubypitaya", "run"]
21
+ ports:
22
+ - containerPort: 4567
23
+ name: rubypitaya
24
+ env:
25
+ - name: SERVER_NAME
26
+ value: "rubypitaya"
27
+ - name: RUBYPITAYA_ENV
28
+ value: "production"
29
+ - name: NATS_URL
30
+ value: "nats://nats.default.svc.cluster.local:4222"
31
+ - name: ETCD_URL
32
+ value: "http://etcd.default.svc.cluster.local:2379"
33
+ - name: ETCD_PREFIX
34
+ value: "rubypitaya/"
35
+ - name: ETCD_LEASE_SECONDS
36
+ value: "60"
37
+ - name: REDIS_URL
38
+ value: "redis://redis.default.svc.cluster.local:6379"
39
+ - name: DATABASE_HOST
40
+ value: "postgres.default.svc.cluster.local"
41
+ - name: DATABASE_USER
42
+ value: "postgres"
43
+ - name: DATABASE_PASSWORD
44
+ value: "postgres"
45
+ - name: DATABASE_NAME
46
+ value: "ruby_pitaya"
47
+ imagePullSecrets:
48
+ - name: gitlab-registry
@@ -0,0 +1,11 @@
1
+ apiVersion: v1
2
+ kind: PersistentVolumeClaim
3
+ metadata:
4
+ name: postgres-pvc
5
+ spec:
6
+ accessModes:
7
+ - ReadWriteOnce
8
+ resources:
9
+ requests:
10
+ storage: 5Gi
11
+ storageClassName: standard
@@ -0,0 +1,12 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: connector
5
+ spec:
6
+ selector:
7
+ app: connector
8
+ ports:
9
+ - protocol: TCP
10
+ port: 3250
11
+ targetPort: 3250
12
+ type: LoadBalancer
@@ -0,0 +1,17 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: etcd
5
+ spec:
6
+ selector:
7
+ app: etcd
8
+ ports:
9
+ - protocol: TCP
10
+ port: 2379
11
+ targetPort: 2379
12
+ name: etcd-2379
13
+ - protocol: TCP
14
+ port: 2380
15
+ targetPort: 2380
16
+ name: etcd-2380
17
+ type: LoadBalancer
@@ -0,0 +1,12 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: nats
5
+ spec:
6
+ selector:
7
+ app: nats
8
+ ports:
9
+ - protocol: TCP
10
+ port: 4222
11
+ targetPort: 4222
12
+ type: LoadBalancer
@@ -0,0 +1,12 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: postgres
5
+ spec:
6
+ selector:
7
+ app: postgres
8
+ ports:
9
+ - protocol: TCP
10
+ port: 5432
11
+ targetPort: 5432
12
+ type: LoadBalancer
@@ -0,0 +1,13 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: redis
5
+ spec:
6
+ selector:
7
+ app: redis
8
+ ports:
9
+ - protocol: TCP
10
+ port: 6379
11
+ targetPort: 6379
12
+ name: redis
13
+ type: LoadBalancer
@@ -0,0 +1,12 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: rubypitaya
5
+ spec:
6
+ selector:
7
+ app: rubypitaya
8
+ ports:
9
+ - protocol: TCP
10
+ port: 80
11
+ targetPort: 4567
12
+ type: LoadBalancer
@@ -0,0 +1,25 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: etcd
5
+ labels:
6
+ app: etcd
7
+ spec:
8
+ serviceName: "etcd"
9
+ replicas: 1
10
+ selector:
11
+ matchLabels:
12
+ app: etcd
13
+ template:
14
+ metadata:
15
+ labels:
16
+ app: etcd
17
+ spec:
18
+ containers:
19
+ - name: etcd
20
+ image: appcelerator/etcd:3.0.15
21
+ ports:
22
+ - containerPort: 2379
23
+ name: etcd-2379
24
+ - containerPort: 2380
25
+ name: etcd-2380
@@ -0,0 +1,23 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: nats
5
+ labels:
6
+ app: nats
7
+ spec:
8
+ serviceName: "nats"
9
+ replicas: 1
10
+ selector:
11
+ matchLabels:
12
+ app: nats
13
+ template:
14
+ metadata:
15
+ labels:
16
+ app: nats
17
+ spec:
18
+ containers:
19
+ - name: nats
20
+ image: nats:2.1.4
21
+ ports:
22
+ - containerPort: 4222
23
+ name: nats
@@ -0,0 +1,37 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: postgres
5
+ labels:
6
+ app: postgres
7
+ spec:
8
+ serviceName: "postgres"
9
+ replicas: 1
10
+ selector:
11
+ matchLabels:
12
+ app: postgres
13
+ template:
14
+ metadata:
15
+ labels:
16
+ app: postgres
17
+ spec:
18
+ containers:
19
+ - name: postgres
20
+ image: postgres:9.6.17
21
+ env:
22
+ - name: POSTGRES_USER
23
+ value: "postgres"
24
+ - name: POSTGRES_PASSWORD
25
+ value: "postgres"
26
+ - name: PGDATA
27
+ value: "/var/lib/postgresql/data/pgdata"
28
+ ports:
29
+ - containerPort: 5432
30
+ name: postgres
31
+ volumeMounts:
32
+ - name: postgres
33
+ mountPath: /var/lib/postgresql/data
34
+ volumes:
35
+ - name: postgres
36
+ persistentVolumeClaim:
37
+ claimName: postgres-pvc
@@ -0,0 +1,23 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: redis
5
+ labels:
6
+ app: redis
7
+ spec:
8
+ serviceName: "redis"
9
+ replicas: 1
10
+ selector:
11
+ matchLabels:
12
+ app: redis
13
+ template:
14
+ metadata:
15
+ labels:
16
+ app: redis
17
+ spec:
18
+ containers:
19
+ - name: redis
20
+ image: redis:6.0.5-alpine
21
+ ports:
22
+ - containerPort: 6379
23
+ name: redis
@@ -25,6 +25,7 @@ module RubyPitaya
25
25
  'pool': config['pool'],
26
26
  'host': config['host'],
27
27
  'user': config['user'],
28
+ 'password': config['password'],
28
29
  'database': config['database'],
29
30
  }
30
31
  end
@@ -36,6 +37,7 @@ module RubyPitaya
36
37
  'pool': config['pool'],
37
38
  'host': config['host'],
38
39
  'user': config['user'],
40
+ 'password': config['password'],
39
41
  }
40
42
  end
41
43
 
@@ -12,15 +12,14 @@ module RubyPitaya
12
12
  end
13
13
 
14
14
  def connect
15
- @redis = Redis.new(url: @redis_address)
15
+ @redis = Redis.new(
16
+ url: @redis_address,
17
+ :reconnect_attempts => 10,
18
+ :reconnect_delay => 1.5,
19
+ :reconnect_delay_max => 2.0,
20
+ )
16
21
 
17
- test_connection
18
- end
19
-
20
- def test_connection
21
- @redis.set('tmp', 'value')
22
- @redis.get('tmp')
23
- @redis.del('tmp')
22
+ @redis.ping
24
23
  end
25
24
  end
26
25
  end
@@ -1,3 +1,3 @@
1
1
  module RubyPitaya
2
- VERSION = "1.6.0"
2
+ VERSION = "1.7.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubypitaya
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luciano Prestes Cavalcanti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-20 00:00:00.000000000 Z
11
+ date: 2020-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -201,7 +201,6 @@ files:
201
201
  - "./lib/rubypitaya/app-template/app/handlers/player_handler.rb"
202
202
  - "./lib/rubypitaya/app-template/app/models/player.rb"
203
203
  - "./lib/rubypitaya/app-template/app/models/user.rb"
204
- - "./lib/rubypitaya/app-template/apptemplate-0.1.0.gem"
205
204
  - "./lib/rubypitaya/app-template/bin/console"
206
205
  - "./lib/rubypitaya/app-template/config/database.yml"
207
206
  - "./lib/rubypitaya/app-template/config/routes.rb"
@@ -212,6 +211,20 @@ files:
212
211
  - "./lib/rubypitaya/app-template/docker/entrypoint.sh"
213
212
  - "./lib/rubypitaya/app-template/docker/prod/Dockerfile"
214
213
  - "./lib/rubypitaya/app-template/docker/prod/Makefile"
214
+ - "./lib/rubypitaya/app-template/kubernetes/README.md"
215
+ - "./lib/rubypitaya/app-template/kubernetes/deployment-connector.yaml"
216
+ - "./lib/rubypitaya/app-template/kubernetes/deployment-rubypitaya.yaml"
217
+ - "./lib/rubypitaya/app-template/kubernetes/persistent-volume.yaml"
218
+ - "./lib/rubypitaya/app-template/kubernetes/service-connector.yaml"
219
+ - "./lib/rubypitaya/app-template/kubernetes/service-etcd.yaml"
220
+ - "./lib/rubypitaya/app-template/kubernetes/service-nats.yaml"
221
+ - "./lib/rubypitaya/app-template/kubernetes/service-postgres.yaml"
222
+ - "./lib/rubypitaya/app-template/kubernetes/service-redis.yaml"
223
+ - "./lib/rubypitaya/app-template/kubernetes/service-rubypitaya.yaml"
224
+ - "./lib/rubypitaya/app-template/kubernetes/statefulset-etcd.yaml"
225
+ - "./lib/rubypitaya/app-template/kubernetes/statefulset-nats.yaml"
226
+ - "./lib/rubypitaya/app-template/kubernetes/statefulset-postgres.yaml"
227
+ - "./lib/rubypitaya/app-template/kubernetes/statefulset-redis.yaml"
215
228
  - "./lib/rubypitaya/core/application_files_importer.rb"
216
229
  - "./lib/rubypitaya/core/config.rb"
217
230
  - "./lib/rubypitaya/core/database_config.rb"