rubypitaya 2.15.0 → 2.19.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubypitaya/app-template/Gemfile +6 -6
  3. data/lib/rubypitaya/app-template/Gemfile.lock +94 -68
  4. data/lib/rubypitaya/app-template/Makefile +1 -1
  5. data/lib/rubypitaya/app-template/app/bll/player_bll.rb +2 -2
  6. data/lib/rubypitaya/app-template/app/handlers/player_handler.rb +1 -1
  7. data/lib/rubypitaya/app-template/docker-compose.yml +4 -0
  8. data/lib/rubypitaya/app-template/docker/dev/Dockerfile +14 -7
  9. data/lib/rubypitaya/app-template/docker/entrypoint.sh +2 -4
  10. data/lib/rubypitaya/app-template/docker/prod/Dockerfile +27 -18
  11. data/lib/rubypitaya/app-template/docker/wait_for.sh +184 -0
  12. data/lib/rubypitaya/app-template/helm/Chart.yaml +4 -0
  13. data/lib/rubypitaya/app-template/helm/templates/config-maps/nginx-config.yaml +9 -0
  14. data/lib/rubypitaya/app-template/helm/templates/deployments/connector.yaml +38 -0
  15. data/lib/rubypitaya/app-template/helm/templates/deployments/gameserver-nginx.yaml +40 -0
  16. data/lib/rubypitaya/app-template/helm/templates/deployments/rubypitaya.yaml +71 -0
  17. data/lib/rubypitaya/app-template/helm/templates/role-bindings/rubypitaya.yaml +12 -0
  18. data/lib/rubypitaya/app-template/helm/templates/roles/rubypitaya.yaml +31 -0
  19. data/lib/rubypitaya/app-template/helm/templates/service-accounts/rubypitaya.yaml +4 -0
  20. data/lib/rubypitaya/app-template/helm/templates/services/connector.yaml +13 -0
  21. data/lib/rubypitaya/app-template/helm/templates/services/etcd.yaml +18 -0
  22. data/lib/rubypitaya/app-template/helm/templates/services/gameserver-nginx.yaml +20 -0
  23. data/lib/rubypitaya/app-template/helm/templates/services/gameserver.yaml +20 -0
  24. data/lib/rubypitaya/app-template/helm/templates/services/nats.yaml +13 -0
  25. data/lib/rubypitaya/app-template/helm/templates/services/redis.yaml +14 -0
  26. data/lib/rubypitaya/app-template/helm/templates/services/rubypitaya.yaml +13 -0
  27. data/lib/rubypitaya/app-template/helm/templates/statefulsets/etcd.yaml +28 -0
  28. data/lib/rubypitaya/app-template/helm/templates/statefulsets/nats.yaml +26 -0
  29. data/lib/rubypitaya/app-template/helm/templates/statefulsets/redis.yaml +26 -0
  30. data/lib/rubypitaya/app-template/helm/values.yaml +32 -0
  31. data/lib/rubypitaya/core/config.rb +11 -4
  32. data/lib/rubypitaya/core/config_core.rb +4 -21
  33. data/lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb +1 -1
  34. data/lib/rubypitaya/core/handler_base.rb +11 -0
  35. data/lib/rubypitaya/core/handler_router.rb +3 -11
  36. data/lib/rubypitaya/core/http_routes.rb +30 -0
  37. data/lib/rubypitaya/core/main.rb +8 -7
  38. data/lib/rubypitaya/core/parameters.rb +449 -138
  39. data/lib/rubypitaya/core/spec-helpers/config_spec_helper.rb +2 -2
  40. data/lib/rubypitaya/core/templates/template_migration.rb.erb +1 -1
  41. data/lib/rubypitaya/version.rb +1 -1
  42. metadata +43 -37
@@ -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,71 @@
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: SERVER_NAME
29
+ value: "rubypitaya"
30
+ - name: RUBYPITAYA_ENV
31
+ value: "production"
32
+ - name: NATS_URL
33
+ value: "nats://nats.{{ .Values.namespace }}.svc.cluster.local:4222"
34
+ - name: ETCD_URL
35
+ value: "http://etcd.{{ .Values.namespace }}.svc.cluster.local:2379"
36
+ - name: ETCD_PREFIX
37
+ value: "rubypitaya/"
38
+ - name: ETCD_LEASE_SECONDS
39
+ value: "60"
40
+ - name: REDIS_URL
41
+ value: "redis://redis.{{ .Values.namespace }}.svc.cluster.local:6379"
42
+ - name: DATABASE_NAME
43
+ value: {{ .Values.database.name | quote }}
44
+ - name: DATABASE_HOST
45
+ value: {{ .Values.database.host | quote }}
46
+ - name: DATABASE_USER
47
+ value: {{ .Values.database.user | quote }}
48
+ - name: DATABASE_PASSWORD
49
+ value: {{ .Values.database.password | quote }}
50
+ - name: HTTP_AUTH_ENABLED
51
+ value: {{ .Values.http.enabled | quote }}
52
+ - name: HTTP_AUTH_USER
53
+ value: {{ .Values.http.user | quote }}
54
+ - name: HTTP_AUTH_PASS
55
+ value: {{ .Values.http.password | quote }}
56
+ - name: MATCHMAKING_CURRENTROOMBLL
57
+ value: kubernetes
58
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_NAMESPACE
59
+ value: {{ .Values.namespace }}
60
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_CONTAINERIMAGE
61
+ value: {{ .Values.gameserver.image.repository }}:{{ .Values.gameserver.image.tag }}
62
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_INITIALPORT
63
+ value: {{ .Values.gameserver.port.first | quote }}
64
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_FINALPORT
65
+ value: {{ .Values.gameserver.port.last | quote }}
66
+ - name: MATCHMAKING_ROOMBLL_KUBERNETES_SERVICEHOST
67
+ value: {{ .Values.gameserver.servicehost }}
68
+ imagePullSecrets:
69
+ - name: gitlab-registry
70
+ serviceAccount: rubypitaya
71
+ 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,32 @@
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
+ image:
11
+ repository: [metagame-repository-link]
12
+ tag: latest
13
+
14
+ database:
15
+ name: [database-name]
16
+ host: [database-host]
17
+ user: [database-user]
18
+ password: [database-password]
19
+
20
+ http:
21
+ enabled: false
22
+ user: user
23
+ password: pass
24
+
25
+ gameserver:
26
+ image:
27
+ repository: [gameserver-repository-link]
28
+ tag: latest
29
+ port:
30
+ first: 5000
31
+ last: 5099
32
+ servicehost: [gameserver-service-url]