Skip to content

Commit

Permalink
Creating a Fleet creates a GameServerSet
Browse files Browse the repository at this point in the history
All this commit is doing is create a GameServerSet
when a Fleet is created. Also, if the Replicas in
a Fleet are updated, then the owned GameServerSet's
Replicas are also updated.

For this commit, we are not worrying about handling
updates to the Spec (e.g. new image) to the Fleet,
and doing updates to a live Fleet, we are just concerned
with scaling up and down.

Parent ticket: #70
  • Loading branch information
markmandel committed Apr 12, 2018
1 parent 4a6e774 commit 26c9365
Show file tree
Hide file tree
Showing 30 changed files with 1,642 additions and 51 deletions.
Empty file removed build/install.yaml
Empty file.
25 changes: 17 additions & 8 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"agones.dev/agones/pkg"
"agones.dev/agones/pkg/client/clientset/versioned"
"agones.dev/agones/pkg/client/informers/externalversions"
"agones.dev/agones/pkg/fleets"
"agones.dev/agones/pkg/gameservers"
"agones.dev/agones/pkg/gameserversets"
"agones.dev/agones/pkg/util/runtime"
Expand All @@ -41,12 +42,13 @@ import (
)

const (
sidecarFlag = "sidecar"
pullSidecarFlag = "always-pull-sidecar"
minPortFlag = "min-port"
maxPortFlag = "max-port"
certFileFlag = "cert-file"
keyFileFlag = "key-file"
sidecarFlag = "sidecar"
pullSidecarFlag = "always-pull-sidecar"
minPortFlag = "min-port"
maxPortFlag = "max-port"
certFileFlag = "cert-file"
keyFileFlag = "key-file"
controllerThreadiness = 2
)

var (
Expand Down Expand Up @@ -131,6 +133,7 @@ func main() {

gsController := gameservers.NewController(wh, health, minPort, maxPort, sidecarImage, alwaysPullSidecar, kubeClient, kubeInformationFactory, extClient, agonesClient, agonesInformerFactory)
gsSetController := gameserversets.NewController(wh, health, kubeClient, extClient, agonesClient, agonesInformerFactory)
fleetController := fleets.NewController(health, kubeClient, extClient, agonesClient, agonesInformerFactory)

stop := signals.NewStopChannel()

Expand All @@ -143,17 +146,23 @@ func main() {
}
}()
go func() {
err = gsController.Run(2, stop)
err = gsController.Run(controllerThreadiness, stop)
if err != nil {
logger.WithError(err).Fatal("Could not run gameserver controller")
}
}()
go func() {
err = gsSetController.Run(2, stop)
err = gsSetController.Run(controllerThreadiness, stop)
if err != nil {
logger.WithError(err).Fatal("Could not run gameserverset controller")
}
}()
go func() {
err = fleetController.Run(controllerThreadiness, stop)
if err != nil {
logger.WithError(err).Fatal("Could not run fleet controller")
}
}()
go func() {
logger.Info("Starting health check...")
srv := &http.Server{
Expand Down
28 changes: 28 additions & 0 deletions examples/cpp-simple/fleet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: "stable.agones.dev/v1alpha1"
kind: Fleet
metadata:
# generate a unique name
# will need to be created with `kubectl create`
generateName: cpp-simple-
spec:
containerPort: 7654
template:
spec:
containers:
- name: cpp-simple
image: gcr.io/agones-images/cpp-simple-server:0.1
# imagePullPolicy: Always # add for development
31 changes: 31 additions & 0 deletions examples/simple-udp/server/fleet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Usually you would define a Fleet rather than a GameServerSet
# directly. This is here mostly for testing purposes

apiVersion: "stable.agones.dev/v1alpha1"
kind: Fleet
metadata:
name: simple-udp
spec:
replicas: 2
template:
spec:
containerPort: 7654
template:
spec:
containers:
- name: simple-udp
image: gcr.io/agones-images/udp-server:0.1
41 changes: 41 additions & 0 deletions install/helm/agones/templates/crds/fleet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: fleets.stable.agones.dev
spec:
group: stable.agones.dev
version: v1alpha1
scope: Namespaced
names:
kind: Fleet
plural: fleets
shortNames:
- flt
singular: fleet
validation:
openAPIV3Schema:
properties:
spec:
required:
- replicas
- template
properties:
replicas:
type: integer
minimum: 0
template:
{{- include "gameserver.validation" . | indent 14 }}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ rules:
resources: ["customresourcedefinitions"]
verbs: ["get"]
- apiGroups: ["stable.agones.dev"]
resources: ["gameservers", "gameserversets"]
resources: ["gameservers", "gameserversets", "fleets"]
verbs: ["create", "delete", "get", "list", "update", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
135 changes: 134 additions & 1 deletion install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ rules:
resources: ["customresourcedefinitions"]
verbs: ["get"]
- apiGroups: ["stable.agones.dev"]
resources: ["gameservers", "gameserversets"]
resources: ["gameservers", "gameserversets", "fleets"]
verbs: ["create", "delete", "get", "list", "update", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -156,6 +156,139 @@ roleRef:
kind: ClusterRole
name: agones-sdk
---
# Source: agones/templates/crds/fleet.yaml
# Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: fleets.stable.agones.dev
spec:
group: stable.agones.dev
version: v1alpha1
scope: Namespaced
names:
kind: Fleet
plural: fleets
shortNames:
- flt
singular: fleet
validation:
openAPIV3Schema:
properties:
spec:
required:
- replicas
- template
properties:
replicas:
type: integer
minimum: 0
template:
required:
- spec
properties:
spec:
required:
- containerPort
- template
properties:
template:
type: object
required:
- spec
properties:
spec:
type: object
required:
- containers
properties:
containers:
type: array
items:
type: object
required:
- image
properties:
name:
type: string
minLength: 0
maxLength: 63
pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
image:
type: string
minLength: 1
minItems: 1
container:
title: The container name running the gameserver
description: if there is more than one container, specify which one is the game server
type: string
minLength: 0
maxLength: 63
pattern: "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$"
portPolicy:
title: the port policy that will be applied to the game server
description: |
portPolicy has two options:
- "dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to
- "static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the
port is available. When static is the policy specified, `hostPort` is required to be populated
type: string
enum:
- dynamic
- static
protocol:
title: Protocol being used. Defaults to UDP. TCP is the only other option
type: string
enum:
- UDP
- TCP
containerPort:
title: The port that is being opened on the game server process
type: integer
minimum: 0
maximum: 65535
hostPort:
title: The port exposed on the host
description: Only required when `portPolicy` is "static". Overwritten when portPolicy is "dynamic".
type: integer
minimum: 0
maximum: 65535
health:
type: object
title: Health checking for the running game server
properties:
disabled:
title: Disable health checking. defaults to false, but can be set to true
type: boolean
initialDelaySeconds:
title: Number of seconds after the container has started before health check is initiated. Defaults to 5 seconds
type: integer
minimum: 0
maximum: 2147483648
periodSeconds:
title: How long before the server is considered not healthy
type: integer
minimum: 0
maximum: 2147483648
failureThreshold:
title: Minimum consecutive failures for the health probe to be considered failed after having succeeded.
type: integer
minimum: 1
maximum: 2147483648
---
# Source: agones/templates/crds/gameserver.yaml
# Copyright 2018 Google Inc. All Rights Reserved.
#
Expand Down
Loading

0 comments on commit 26c9365

Please sign in to comment.