Skip to content

Commit

Permalink
Updated website docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
roberthbailey committed Jul 5, 2019
1 parent 98d785b commit b83f3a0
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 6 deletions.
52 changes: 48 additions & 4 deletions site/content/en/docs/Getting Started/create-fleetautoscaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/{{< rel
You should see a successful output similar to this :

```
fleetautoscaler.autoscaling.agones.sev "simple-udp-autoscaler" created
fleetautoscaler.autoscaling.agones.dev "simple-udp-autoscaler" created
```

This has created a FleetAutoscaler record inside Kubernetes.
Expand All @@ -44,13 +44,14 @@ kubectl describe fleetautoscaler simple-udp-autoscaler

It should look something like this:

{{% feature expiryVersion="0.12.0" %}}
```
Name: simple-udp-autoscaler
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"st
able.agones.dev/v1alpha1","kind":"FleetAutoscaler","metadata":{"annotations":{},
"name":"simple-udp-autoscaler","namespace":"default"},...
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"au
toscaling.agones.dev/v1alpha1","kind":"FleetAutoscaler","metadata":{"annotations
":{},"name":"simple-udp-autoscaler","namespace":"default"},...
API Version: autoscaling.agones.dev/v1alpha1
Kind: FleetAutoscaler
Metadata:
Expand Down Expand Up @@ -84,6 +85,49 @@ Status:
Scaling Limited: false
Events: <none>
```
{{% /feature %}}
{{% feature publishversion="0.12.0" %}}
```
Name: simple-udp-autoscaler
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"au
toscaling.agones.dev/v1","kind":"FleetAutoscaler","metadata":{"annotations":{},
"name":"simple-udp-autoscaler","namespace":"default"},...
API Version: autoscaling.agones.dev/v1
Kind: FleetAutoscaler
Metadata:
Cluster Name:
Creation Timestamp: 2018-10-02T15:19:58Z
Generation: 1
Owner References:
API Version: autoscaling.agones.dev/v1
Block Owner Deletion: true
Controller: true
Kind: Fleet
Name: simple-udp
UID: 9960762e-c656-11e8-933e-fa163e07a1d4
Resource Version: 6123197
Self Link: /apis/autoscaling.agones.dev/v1/namespaces/default/f
leetautoscalers/simple-udp-autoscaler
UID: 9fd0efa1-c656-11e8-933e-fa163e07a1d4
Spec:
Fleet Name: simple-udp
Policy:
Buffer:
Buffer Size: 2
Max Replicas: 10
Min Replicas: 2
Type: Buffer
Status:
Able To Scale: true
Current Replicas: 2
Desired Replicas: 2
Last Scale Time: <nil>
Scaling Limited: false
Events: <none>
```
{{% /feature %}}

You can see the status (able to scale, not limited), the last time the fleet was scaled (nil for never)
and the current and desired fleet size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ kubectl apply -f https://raw.githubusercontent.com/googleforgames/agones/{{< rel
You should see a successful output similar to this:

```
fleetautoscaler.autoscaling.agones.sev "webhook-fleet-autoscaler" created
fleetautoscaler.autoscaling.agones.dev "webhook-fleet-autoscaler" created
```

This has created a FleetAutoscaler record inside Kubernetes.
Expand All @@ -94,6 +94,7 @@ kubectl describe fleetautoscaler webhook-fleet-autoscaler

It should look something like this:

{{% feature expiryVersion="0.12.0" %}}
```
Name: webhook-fleet-autoscaler
Namespace: default
Expand Down Expand Up @@ -126,6 +127,44 @@ Status:
Scaling Limited: false
Events: <none>
```
{{% /feature %}}
{{% feature publishversion="0.12.0" %}}
```
Name: webhook-fleet-autoscaler
Namespace: default
Labels: <none>
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":
"autoscaling.agones.dev/v1","kind":"FleetAutoscaler","metadata":{"annotations"
:{},"name":"webhook-fleet-autoscaler","namespace":"default...
API Version: autoscaling.agones.dev/v1
Kind: FleetAutoscaler
etadata:
Cluster Name:
Creation Timestamp: 2018-12-22T12:52:23Z
Generation: 1
Resource Version: 2274579
Self Link: /apis/autoscaling.agones.dev/v1/namespaces/default/fleet
autoscalers/webhook-fleet-autoscaler
UID: 6d03eae4-05e8-11e9-84c2-42010a8a01c9
Spec:
Fleet Name: simple-udp
Policy:
Type: Webhook
Webhook:
Service:
Name: autoscaler-webhook-service
Namespace: default
Path: scale
URL:
Status:
Able To Scale: true
Current Replicas: 2
Desired Replicas: 2
Last Scale Time: <nil>
Scaling Limited: false
Events: <none>
```
{{% /feature %}}

You can see the status (able to scale, not limited), the last time the fleet was scaled (nil for never), current and desired fleet size.

Expand Down
87 changes: 86 additions & 1 deletion site/content/en/docs/Reference/fleetautoscaler.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ weight: 30
A full `FleetAutoscaler` specification is available below and in the
{{< ghlink href="examples/fleetautoscaler.yaml" >}}example folder{{< /ghlink >}} for reference :

{{% feature expiryVersion="0.12.0" %}}
```yaml
apiVersion: "autoscaling.agones.dev/v1alpha1"
kind: FleetAutoscaler
Expand All @@ -23,9 +24,27 @@ spec:
minReplicas: 10
maxReplicas: 20
```
{{% /feature %}}
{{% feature publishversion="0.12.0" %}}
```yaml
apiVersion: "autoscaling.agones.dev/v1"
kind: FleetAutoscaler
metadata:
name: fleet-autoscaler-example
spec:
fleetName: fleet-example
policy:
type: Buffer
buffer:
bufferSize: 5
minReplicas: 10
maxReplicas: 20
```
{{% /feature %}}
Or for Webhook FleetAutoscaler below and in {{< ghlink href="examples/webhookfleetautoscaler.yaml" >}}example folder{{< /ghlink >}}:
{{% feature expiryVersion="0.12.0" %}}
```yaml
apiVersion: "autoscaling.agones.dev/v1alpha1"
kind: FleetAutoscaler
Expand All @@ -41,11 +60,31 @@ spec:
path: "/scale"
caBundle: "<base64 encoded string>"
```
{{% /feature %}}
{{% feature publishversion="0.12.0" %}}
```yaml
apiVersion: "autoscaling.agones.dev/v1"
kind: FleetAutoscaler
metadata:
name: fleet-autoscaler-example
spec:
fleetName: fleet-example
policy:
type: Webhook
webhook:
name: "fleet-autoscaler-webhook"
namespace: "default"
path: "/scale"
caBundle: "<base64 encoded string>"
```
{{% /feature %}}
Since Agones defines a new
[Custom Resources Definition (CRD)](https://kubernetes.io/docs/concepts/api-extension/custom-resources/)
we can define a new resource using the kind `FleetAutoscaler` with the custom group `autoscaling.agones.dev`
and API version `v1alpha1`.
and API version
{{< feature expiryVersion="0.12.0" >}}`v1alpha1`{{< /feature >}}
{{< feature publishVersion="0.12.0" >}}`v1`{{< /feature >}}.

The `spec` field is the actual `FleetAutoscaler` specification and it is composed as follows:

Expand Down Expand Up @@ -85,6 +124,7 @@ In order to define the path to your Webhook you can use either `URL` or `service

The connection to this webhook endpoint should be defined in `FleetAutoscaler` using Webhook policy type.

{{% feature expiryVersion="0.12.0" %}}
```go
// FleetAutoscaleReview is passed to the webhook with a populated Request value,
// and then returned with a populated Response.
Expand Down Expand Up @@ -127,6 +167,51 @@ type FleetStatus struct {
AllocatedReplicas int32 `json:"allocatedReplicas"`
}
```
{{% /feature %}}
{{% feature publishversion="0.12.0" %}}
```go
// FleetAutoscaleReview is passed to the webhook with a populated Request value,
// and then returned with a populated Response.
type FleetAutoscaleReview struct {
Request *FleetAutoscaleRequest `json:"request"`
Response *FleetAutoscaleResponse `json:"response"`
}

type FleetAutoscaleRequest struct {
// UID is an identifier for the individual request/response. It allows us to distinguish instances of requests which are
// otherwise identical (parallel requests, requests when earlier requests did not modify etc)
// The UID is meant to track the round trip (request/response) between the Autoscaler and the WebHook, not the user request.
// It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging.
UID types.UID `json:"uid""`
// Name is the name of the Fleet being scaled
Name string `json:"name"`
// Namespace is the namespace associated with the request (if any).
Namespace string `json:"namespace"`
// The Fleet's status values
Status v1.FleetStatus `json:"status"`
}

type FleetAutoscaleResponse struct {
// UID is an identifier for the individual request/response.
// This should be copied over from the corresponding FleetAutoscaleRequest.
UID types.UID `json:"uid"`
// Set to false if no scaling should occur to the Fleet
Scale bool `json:"scale"`
// The targeted replica count
Replicas int32 `json:"replicas"`
}

// FleetStatus is the status of a Fleet
type FleetStatus struct {
// Replicas the total number of current GameServer replicas
Replicas int32 `json:"replicas"`
// ReadyReplicas are the number of Ready GameServer replicas
ReadyReplicas int32 `json:"readyReplicas"`
// AllocatedReplicas are the number of Allocated GameServer replicas
AllocatedReplicas int32 `json:"allocatedReplicas"`
}
```
{{% /feature %}}

For Webhook Fleetautoscaler Policy either HTTP or HTTPS could be used. Switching between them occurs depending on https presence in `URL` or by presence of `caBundle`.
The example of the webhook written in Go could be found {{< ghlink href="examples/autoscaler-webhook/main.go" >}}here{{< /ghlink >}}.
Expand Down

0 comments on commit b83f3a0

Please sign in to comment.