rubypitaya 2.18.0 → 2.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubypitaya/app-template/Gemfile +1 -1
  3. data/lib/rubypitaya/app-template/Gemfile.lock +7 -8
  4. data/lib/rubypitaya/app-template/Makefile +1 -1
  5. data/lib/rubypitaya/app-template/Rakefile +5 -10
  6. data/lib/rubypitaya/app-template/app/bll/player_bll.rb +1 -1
  7. data/lib/rubypitaya/app-template/app/config/initial_player.json +4 -1
  8. data/lib/rubypitaya/app-template/app/setup/rubypitaya.yml +27 -0
  9. data/lib/rubypitaya/app-template/bin/console +1 -2
  10. data/lib/rubypitaya/app-template/docker-compose.yml +0 -11
  11. data/lib/rubypitaya/app-template/docker/dev/Dockerfile +11 -6
  12. data/lib/rubypitaya/app-template/docker/entrypoint.sh +5 -4
  13. data/lib/rubypitaya/app-template/docker/prod/Dockerfile +16 -7
  14. data/lib/rubypitaya/app-template/docker/wait_for.sh +184 -0
  15. data/lib/rubypitaya/app-template/features/player.feature +1 -1
  16. data/lib/rubypitaya/app-template/helm/Chart.yaml +4 -0
  17. data/lib/rubypitaya/app-template/helm/templates/config-maps/nginx-config.yaml +9 -0
  18. data/lib/rubypitaya/app-template/helm/templates/deployments/connector.yaml +38 -0
  19. data/lib/rubypitaya/app-template/helm/templates/deployments/gameserver-nginx.yaml +40 -0
  20. data/lib/rubypitaya/app-template/helm/templates/deployments/rubypitaya.yaml +67 -0
  21. data/lib/rubypitaya/app-template/helm/templates/role-bindings/rubypitaya.yaml +12 -0
  22. data/lib/rubypitaya/app-template/helm/templates/roles/rubypitaya.yaml +31 -0
  23. data/lib/rubypitaya/app-template/helm/templates/service-accounts/rubypitaya.yaml +4 -0
  24. data/lib/rubypitaya/app-template/helm/templates/services/connector.yaml +13 -0
  25. data/lib/rubypitaya/app-template/helm/templates/services/etcd.yaml +18 -0
  26. data/lib/rubypitaya/app-template/helm/templates/services/gameserver-nginx.yaml +20 -0
  27. data/lib/rubypitaya/app-template/helm/templates/services/gameserver.yaml +20 -0
  28. data/lib/rubypitaya/app-template/helm/templates/services/nats.yaml +13 -0
  29. data/lib/rubypitaya/app-template/helm/templates/services/redis.yaml +14 -0
  30. data/lib/rubypitaya/app-template/helm/templates/services/rubypitaya.yaml +13 -0
  31. data/lib/rubypitaya/app-template/helm/templates/statefulsets/etcd.yaml +28 -0
  32. data/lib/rubypitaya/app-template/helm/templates/statefulsets/nats.yaml +26 -0
  33. data/lib/rubypitaya/app-template/helm/templates/statefulsets/redis.yaml +26 -0
  34. data/lib/rubypitaya/app-template/helm/values.yaml +36 -0
  35. data/lib/rubypitaya/app-template/kubernetes/deployment-rubypitaya.yaml +10 -14
  36. data/lib/rubypitaya/app-template/spec/player_handler_spec.rb +4 -3
  37. data/lib/rubypitaya/core/config.rb +10 -1
  38. data/lib/rubypitaya/core/database_config.rb +15 -10
  39. data/lib/rubypitaya/core/handler_base.rb +11 -0
  40. data/lib/rubypitaya/core/handler_router.rb +3 -11
  41. data/lib/rubypitaya/core/helpers/setup_helper.rb +1 -2
  42. data/lib/rubypitaya/core/http_routes.rb +33 -3
  43. data/lib/rubypitaya/core/main.rb +16 -13
  44. data/lib/rubypitaya/core/path.rb +0 -2
  45. data/lib/rubypitaya/core/setup.rb +10 -0
  46. data/lib/rubypitaya/core/spec-helpers/config_spec_helper.rb +2 -2
  47. data/lib/rubypitaya/core/spec-helpers/handler_spec_helper.rb +3 -1
  48. data/lib/rubypitaya/version.rb +1 -1
  49. metadata +37 -18
  50. data/lib/rubypitaya/app-template/app/setup/initial_player.yml +0 -2
  51. data/lib/rubypitaya/app-template/config/database.yml +0 -20
@@ -3,7 +3,7 @@ Feature: Player
3
3
  As a game player I want to have a player on database
4
4
 
5
5
  Scenario: Create new player
6
- Given setup key 'initial_player.wallet.gold' is '10'
6
+ Given config key 'initial_player.wallet.gold' is '10'
7
7
  And config key 'initial_player.name' is 'Guest'
8
8
  When client call route 'rubypitaya.playerHandler.authenticate'
9
9
  Then server should response 'code' as 'RP-200'
@@ -0,0 +1,4 @@
1
+ apiVersion: v1
2
+ description: [Game Name]
3
+ name: [game-name]
4
+ version: 0.0.1
@@ -0,0 +1,9 @@
1
+ apiVersion: v1
2
+ kind: ConfigMap
3
+ metadata:
4
+ name: nginx-config
5
+ data:
6
+ nginx.conf: "events {\n worker_connections 1024;\n}\n\nstream {\n server
7
+ {\n listen {{ .Values.gameserver.port.first }}-{{ .Values.gameserver.port.last }};\n \n resolver kube-dns.kube-system.svc.cluster.local
8
+ valid=5s;\n\n proxy_pass gameserver-$server_port.{{ .Values.namespace }}.svc.cluster.local:$server_port;\n
9
+ \ }\n}\n"
@@ -0,0 +1,38 @@
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: connector
5
+ labels:
6
+ app: {{ .Values.app }}
7
+ component: connector
8
+ spec:
9
+ replicas: 1
10
+ selector:
11
+ matchLabels:
12
+ app: {{ .Values.app }}
13
+ component: connector
14
+ template:
15
+ metadata:
16
+ labels:
17
+ app: {{ .Values.app }}
18
+ component: connector
19
+ spec:
20
+ containers:
21
+ - name: connector
22
+ image: {{ .Values.connector.image.repository }}:{{ .Values.connector.image.tag }}
23
+ ports:
24
+ - containerPort: 3250
25
+ name: connector
26
+ env:
27
+ - name: PITAYA_CLUSTER_RPC_SERVER_NATS_CONNECT
28
+ value: "nats://nats.{{ .Values.namespace }}.svc.cluster.local:4222"
29
+ - name: PITAYA_CLUSTER_RPC_CLIENT_NATS_CONNECT
30
+ value: "nats://nats.{{ .Values.namespace }}.svc.cluster.local:4222"
31
+ - name: PITAYA_CLUSTER_RPC_CLIENT_NATS_REQUESTTIMEOUT
32
+ value: "10s"
33
+ - name: PITAYA_CLUSTER_SD_ETCD_ENDPOINTS
34
+ value: "etcd.{{ .Values.namespace }}.svc.cluster.local:2379"
35
+ - name: PITAYA_CLUSTER_SD_ETCD_PREFIX
36
+ value: "rubypitaya/"
37
+ - name: SERVER_ROUTES
38
+ value: "rubypitaya"
@@ -0,0 +1,40 @@
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: gameserver-nginx
5
+ labels:
6
+ app: gameserver
7
+ component: gameserver-nginx
8
+ spec:
9
+ replicas: 10
10
+ selector:
11
+ matchLabels:
12
+ app: gameserver
13
+ component: gameserver-nginx
14
+ template:
15
+ metadata:
16
+ labels:
17
+ app: gameserver
18
+ component: gameserver-nginx
19
+ spec:
20
+ containers:
21
+ - name: gameserver-nginx
22
+ image: nginx:1.18.0
23
+ ports:
24
+ {{- $initialValue := int .Values.gameserver.port.first }}
25
+ {{- $finalValue := add .Values.gameserver.port.last 1 }}
26
+ {{- $finalValue = int $finalValue }}
27
+ {{- range untilStep $initialValue $finalValue 1 }}
28
+ {{- $port := . }}
29
+ - name: port-{{ $port }}
30
+ containerPort: {{ $port }}
31
+ protocol: TCP
32
+ {{- end }}
33
+ volumeMounts:
34
+ - name: nginx-config
35
+ mountPath: /etc/nginx/nginx.conf
36
+ subPath: nginx.conf
37
+ volumes:
38
+ - name: nginx-config
39
+ configMap:
40
+ name: nginx-config
@@ -0,0 +1,67 @@
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: rubypitaya
5
+ labels:
6
+ app: {{ .Values.app }}
7
+ component: rubypitaya
8
+ spec:
9
+ replicas: 1
10
+ selector:
11
+ matchLabels:
12
+ app: {{ .Values.app }}
13
+ component: rubypitaya
14
+ template:
15
+ metadata:
16
+ labels:
17
+ app: {{ .Values.app }}
18
+ component: rubypitaya
19
+ spec:
20
+ containers:
21
+ - name: rubypitaya
22
+ image: {{ .Values.rubypitaya.image.repository }}:{{ .Values.rubypitaya.image.tag }}
23
+ command: ["bundle", "exec", "rubypitaya", "run"]
24
+ ports:
25
+ - containerPort: 4567
26
+ name: rubypitaya
27
+ env:
28
+ - name: RUBYPITAYA_SERVER_ENVIRONMENT
29
+ value: {{ .Values.rubypitaya.server.environment | quote }}
30
+ - name: RUBYPITAYA_NATS_URL
31
+ value: "nats://nats.{{ .Values.namespace }}.svc.cluster.local:4222"
32
+ - name: RUBYPITAYA_ETCD_URL
33
+ value: "http://etcd.{{ .Values.namespace }}.svc.cluster.local:2379"
34
+ - name: RUBYPITAYA_REDIS_URL
35
+ value: "redis://redis.{{ .Values.namespace }}.svc.cluster.local:6379"
36
+ - name: RUBYPITAYA_DATABASE_NAME
37
+ value: {{ .Values.database.name | quote }}
38
+ - name: RUBYPITAYA_DATABASE_HOST
39
+ value: {{ .Values.database.host | quote }}
40
+ - name: RUBYPITAYA_DATABASE_USER
41
+ value: {{ .Values.database.user | quote }}
42
+ - name: RUBYPITAYA_DATABASE_PORT
43
+ value: {{ .Values.database.port | quote }}
44
+ - name: RUBYPITAYA_DATABASE_PASSWORD
45
+ value: {{ .Values.database.password | quote }}
46
+ - name: RUBYPITAYA_HTTP_AUTH_ENABLED
47
+ value: {{ .Values.http.auth.enabled | quote }}
48
+ - name: RUBYPITAYA_HTTP_AUTH_USER
49
+ value: {{ .Values.http.auth.user | quote }}
50
+ - name: RUBYPITAYA_HTTP_AUTH_PASS
51
+ value: {{ .Values.http.auth.password | quote }}
52
+ - name: MATCHMAKING_CURRENTROOMBLL
53
+ value: kubernetes
54
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_NAMESPACE
55
+ value: {{ .Values.namespace }}
56
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_CONTAINERIMAGE
57
+ value: {{ .Values.gameserver.image.repository }}:{{ .Values.gameserver.image.tag }}
58
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_INITIALPORT
59
+ value: {{ .Values.gameserver.port.first | quote }}
60
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_FINALPORT
61
+ value: {{ .Values.gameserver.port.last | quote }}
62
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_SERVICEHOST
63
+ value: {{ .Values.gameserver.servicehost }}
64
+ imagePullSecrets:
65
+ - name: gitlab-registry
66
+ serviceAccount: rubypitaya
67
+ serviceAccountName: rubypitaya
@@ -0,0 +1,12 @@
1
+ apiVersion: rbac.authorization.k8s.io/v1
2
+ kind: RoleBinding
3
+ metadata:
4
+ name: rubypitaya
5
+ roleRef:
6
+ apiGroup: rbac.authorization.k8s.io
7
+ kind: Role
8
+ name: rubypitaya
9
+ subjects:
10
+ - kind: ServiceAccount
11
+ name: rubypitaya
12
+ namespace: {{ .Values.namespace }}
@@ -0,0 +1,31 @@
1
+ apiVersion: rbac.authorization.k8s.io/v1
2
+ kind: Role
3
+ metadata:
4
+ name: rubypitaya
5
+ rules:
6
+ - apiGroups:
7
+ - ""
8
+ resources:
9
+ - services
10
+ - pods
11
+ verbs:
12
+ - get
13
+ - list
14
+ - watch
15
+ - create
16
+ - update
17
+ - patch
18
+ - delete
19
+ - apiGroups:
20
+ - apps
21
+ - extensions
22
+ resources:
23
+ - deployments
24
+ verbs:
25
+ - get
26
+ - list
27
+ - watch
28
+ - create
29
+ - update
30
+ - patch
31
+ - delete
@@ -0,0 +1,4 @@
1
+ apiVersion: v1
2
+ kind: ServiceAccount
3
+ metadata:
4
+ name: rubypitaya
@@ -0,0 +1,13 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: connector
5
+ spec:
6
+ selector:
7
+ app: {{ .Values.app }}
8
+ component: connector
9
+ ports:
10
+ - protocol: TCP
11
+ port: 3250
12
+ targetPort: 3250
13
+ type: LoadBalancer
@@ -0,0 +1,18 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: etcd
5
+ spec:
6
+ selector:
7
+ app: {{ .Values.app }}
8
+ component: etcd
9
+ ports:
10
+ - protocol: TCP
11
+ port: 2379
12
+ targetPort: 2379
13
+ name: etcd-2379
14
+ - protocol: TCP
15
+ port: 2380
16
+ targetPort: 2380
17
+ name: etcd-2380
18
+ type: ClusterIP
@@ -0,0 +1,20 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: gameserver-nginx
5
+ spec:
6
+ selector:
7
+ app: gameserver
8
+ component: gameserver-nginx
9
+ ports:
10
+ {{- $initialValue := int .Values.gameserver.port.first }}
11
+ {{- $finalValue := add .Values.gameserver.port.last 1 }}
12
+ {{- $finalValue = int $finalValue }}
13
+ {{- range untilStep $initialValue $finalValue 1 }}
14
+ {{- $port := . }}
15
+ - name: port-{{ $port }}
16
+ port: {{ $port }}
17
+ targetPort: {{ $port }}
18
+ protocol: TCP
19
+ {{- end }}
20
+ type: LoadBalancer
@@ -0,0 +1,20 @@
1
+ {{- $initialValue := int .Values.gameserver.port.first }}
2
+ {{- $finalValue := add .Values.gameserver.port.last 1 }}
3
+ {{- $finalValue = int $finalValue }}
4
+ {{- range untilStep $initialValue $finalValue 1 }}
5
+ {{- $port := . }}
6
+ apiVersion: v1
7
+ kind: Service
8
+ metadata:
9
+ name: gameserver-{{ $port }}
10
+ spec:
11
+ selector:
12
+ app: gameserver
13
+ component: gameserver-{{ $port }}
14
+ ports:
15
+ - protocol: TCP
16
+ port: {{ $port }}
17
+ targetPort: {{ $port }}
18
+ type: ClusterIP
19
+ ---
20
+ {{- end }}
@@ -0,0 +1,13 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: nats
5
+ spec:
6
+ selector:
7
+ app: {{ .Values.app }}
8
+ component: nats
9
+ ports:
10
+ - protocol: TCP
11
+ port: 4222
12
+ targetPort: 4222
13
+ type: ClusterIP
@@ -0,0 +1,14 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: redis
5
+ spec:
6
+ selector:
7
+ app: {{ .Values.app }}
8
+ component: redis
9
+ ports:
10
+ - protocol: TCP
11
+ port: 6379
12
+ targetPort: 6379
13
+ name: redis
14
+ type: ClusterIP
@@ -0,0 +1,13 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: rubypitaya
5
+ spec:
6
+ selector:
7
+ app: {{ .Values.app }}
8
+ component: rubypitaya
9
+ ports:
10
+ - protocol: TCP
11
+ port: 80
12
+ targetPort: 4567
13
+ type: LoadBalancer
@@ -0,0 +1,28 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: etcd
5
+ labels:
6
+ app: {{ .Values.app }}
7
+ component: etcd
8
+ spec:
9
+ serviceName: "etcd"
10
+ replicas: 1
11
+ selector:
12
+ matchLabels:
13
+ app: {{ .Values.app }}
14
+ component: etcd
15
+ template:
16
+ metadata:
17
+ labels:
18
+ app: {{ .Values.app }}
19
+ component: etcd
20
+ spec:
21
+ containers:
22
+ - name: etcd
23
+ image: appcelerator/etcd:3.0.15
24
+ ports:
25
+ - containerPort: 2379
26
+ name: etcd-2379
27
+ - containerPort: 2380
28
+ name: etcd-2380
@@ -0,0 +1,26 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: nats
5
+ labels:
6
+ app: {{ .Values.app }}
7
+ component: nats
8
+ spec:
9
+ serviceName: "nats"
10
+ replicas: 1
11
+ selector:
12
+ matchLabels:
13
+ app: {{ .Values.app }}
14
+ component: nats
15
+ template:
16
+ metadata:
17
+ labels:
18
+ app: {{ .Values.app }}
19
+ component: nats
20
+ spec:
21
+ containers:
22
+ - name: nats
23
+ image: nats:2.1.4
24
+ ports:
25
+ - containerPort: 4222
26
+ name: nats
@@ -0,0 +1,26 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: redis
5
+ labels:
6
+ app: {{ .Values.app }}
7
+ component: redis
8
+ spec:
9
+ serviceName: "redis"
10
+ replicas: 1
11
+ selector:
12
+ matchLabels:
13
+ app: {{ .Values.app }}
14
+ component: redis
15
+ template:
16
+ metadata:
17
+ labels:
18
+ app: {{ .Values.app }}
19
+ component: redis
20
+ spec:
21
+ containers:
22
+ - name: redis
23
+ image: redis:6.0.5-alpine
24
+ ports:
25
+ - containerPort: 6379
26
+ name: redis
@@ -0,0 +1,36 @@
1
+ app: [app-name]
2
+ namespace: [kubernetes-namespace]
3
+
4
+ connector:
5
+ image:
6
+ repository: registry.gitlab.com/lucianopc/pitaya-connector
7
+ tag: 0.2.0
8
+
9
+ rubypitaya:
10
+ server:
11
+ environment: production
12
+ image:
13
+ repository: [metagame-repository-link]
14
+ tag: latest
15
+
16
+ database:
17
+ name: [database-name]
18
+ host: [database-host]
19
+ user: [database-user]
20
+ port: [database-port]
21
+ password: [database-password]
22
+
23
+ http:
24
+ auth:
25
+ user: 'user'
26
+ pass: 'pass'
27
+ enabled: 'false'
28
+
29
+ gameserver:
30
+ image:
31
+ repository: [gameserver-repository-link]
32
+ tag: latest
33
+ port:
34
+ first: 5000
35
+ last: 5099
36
+ servicehost: [gameserver-service-url]