From 31c212fe9916f5854ba10694496d375adb8cdf51 Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Mon, 17 Jun 2019 16:38:31 -0700 Subject: [PATCH] Move FleetAutoscaling to autoscaling.agones.dev group (#829) This is a pure refactor, to move FleetAutoscaling to the group outlined in #703, where it will stay. Did this one first, since it seemed like the easiest one to tackle. --- build/build-image/Dockerfile | 2 +- build/build-image/gen-crd-client.sh | 2 +- examples/autoscaler-webhook/main.go | 2 +- examples/fleetautoscaler.yaml | 2 +- examples/simple-udp/fleetautoscaler.yaml | 2 +- examples/webhookfleetautoscaler.yaml | 2 +- examples/webhookfleetautoscalertls.yaml | 2 +- examples/xonotic/fleetautoscaler.yaml | 2 +- .../templates/crds/fleetautoscaler.yaml | 4 +- install/helm/agones/templates/extensions.yaml | 10 +- install/helm/agones/templates/hooks/sa.yaml | 2 +- .../templates/serviceaccounts/controller.yaml | 10 +- install/yaml/install.yaml | 24 +- .../v1alpha1/zz_generated.deepcopy.go | 18 + pkg/apis/autoscaling/register.go | 20 + pkg/apis/autoscaling/v1alpha1/doc.go | 19 + .../v1alpha1/fleetautoscaler.go | 5 +- .../v1alpha1/fleetautoscaler_test.go | 0 pkg/apis/autoscaling/v1alpha1/register.go | 59 + .../v1alpha1/zz_generated.deepcopy.go | 285 +++++ pkg/apis/stable/v1alpha1/register.go | 2 - .../stable/v1alpha1/zz_generated.deepcopy.go | 260 ----- pkg/client/clientset/versioned/clientset.go | 22 + .../versioned/fake/clientset_generated.go | 12 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../v1alpha1/autoscaling_client.go | 90 ++ .../typed/autoscaling/v1alpha1/doc.go | 20 + .../typed/autoscaling/v1alpha1/fake/doc.go | 20 + .../v1alpha1/fake/fake_autoscaling_client.go | 40 + .../v1alpha1/fake/fake_fleetautoscaler.go | 8 +- .../v1alpha1/fleetautoscaler.go | 4 +- .../v1alpha1/generated_expansion.go | 21 + .../v1alpha1/fake/fake_stable_client.go | 4 - .../stable/v1alpha1/generated_expansion.go | 2 - .../typed/stable/v1alpha1/stable_client.go | 5 - .../externalversions/autoscaling/interface.go | 46 + .../v1alpha1/fleetautoscaler.go | 12 +- .../autoscaling/v1alpha1/interface.go | 45 + .../informers/externalversions/factory.go | 6 + .../informers/externalversions/generic.go | 13 +- .../stable/v1alpha1/interface.go | 7 - .../v1alpha1/expansion_generated.go | 27 + .../v1alpha1/fleetautoscaler.go | 2 +- .../stable/v1alpha1/expansion_generated.go | 8 - pkg/fleetautoscalers/controller.go | 47 +- pkg/fleetautoscalers/controller_test.go | 27 +- pkg/fleetautoscalers/fleetautoscalers.go | 12 +- pkg/fleetautoscalers/fleetautoscalers_test.go | 2 +- pkg/metrics/controller.go | 14 +- pkg/metrics/util_test.go | 18 +- .../Getting Started/create-fleetautoscaler.md | 53 + .../create-webhook-fleetautoscaler.md | 45 + .../Reference/agones_crd_api_reference.html | 1009 +++++++++-------- .../en/docs/Reference/fleetautoscaler.md | 44 +- test/e2e/fleetautoscaler_test.go | 49 +- test/e2e/framework/framework.go | 53 +- 57 files changed, 1589 insertions(+), 936 deletions(-) create mode 100644 pkg/apis/autoscaling/register.go create mode 100644 pkg/apis/autoscaling/v1alpha1/doc.go rename pkg/apis/{stable => autoscaling}/v1alpha1/fleetautoscaler.go (98%) rename pkg/apis/{stable => autoscaling}/v1alpha1/fleetautoscaler_test.go (100%) create mode 100644 pkg/apis/autoscaling/v1alpha1/register.go create mode 100644 pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go create mode 100644 pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go create mode 100644 pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go rename pkg/client/clientset/versioned/typed/{stable => autoscaling}/v1alpha1/fake/fake_fleetautoscaler.go (94%) rename pkg/client/clientset/versioned/typed/{stable => autoscaling}/v1alpha1/fleetautoscaler.go (97%) create mode 100644 pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go create mode 100644 pkg/client/informers/externalversions/autoscaling/interface.go rename pkg/client/informers/externalversions/{stable => autoscaling}/v1alpha1/fleetautoscaler.go (88%) create mode 100644 pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go create mode 100644 pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go rename pkg/client/listers/{stable => autoscaling}/v1alpha1/fleetautoscaler.go (98%) diff --git a/build/build-image/Dockerfile b/build/build-image/Dockerfile index e77299b9f3..a9169f1a17 100644 --- a/build/build-image/Dockerfile +++ b/build/build-image/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -# ForceUpdate 7 -- change here if you need to force a rebuild +# ForceUpdate 8 -- change here if you need to force a rebuild FROM debian:stretch diff --git a/build/build-image/gen-crd-client.sh b/build/build-image/gen-crd-client.sh index 8f38f1e11e..6cc0205f8d 100644 --- a/build/build-image/gen-crd-client.sh +++ b/build/build-image/gen-crd-client.sh @@ -23,6 +23,6 @@ rsync -r /go/src/agones.dev/agones/vendor/k8s.io/ /go/src/k8s.io/ cd /go/src/k8s.io/code-generator ./generate-groups.sh "all" \ agones.dev/agones/pkg/client \ - agones.dev/agones/pkg/apis "allocation:v1alpha1 stable:v1alpha1 multicluster:v1alpha1" \ + agones.dev/agones/pkg/apis "allocation:v1alpha1 stable:v1alpha1 multicluster:v1alpha1 autoscaling:v1alpha1" \ --go-header-file=/go/src/agones.dev/agones/build/boilerplate.go.txt diff --git a/examples/autoscaler-webhook/main.go b/examples/autoscaler-webhook/main.go index ecc0998784..e32a24a954 100644 --- a/examples/autoscaler-webhook/main.go +++ b/examples/autoscaler-webhook/main.go @@ -25,7 +25,7 @@ import ( "os" "strconv" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" "agones.dev/agones/pkg/util/runtime" // for the logger ) diff --git a/examples/fleetautoscaler.yaml b/examples/fleetautoscaler.yaml index 742d438d7f..074218f98d 100644 --- a/examples/fleetautoscaler.yaml +++ b/examples/fleetautoscaler.yaml @@ -17,7 +17,7 @@ # automatically depending on load # -apiVersion: "stable.agones.dev/v1alpha1" +apiVersion: "autoscaling.agones.dev/v1alpha1" kind: FleetAutoscaler metadata: # FleetAutoscaler Metadata diff --git a/examples/simple-udp/fleetautoscaler.yaml b/examples/simple-udp/fleetautoscaler.yaml index 77381abf7e..c355115eea 100644 --- a/examples/simple-udp/fleetautoscaler.yaml +++ b/examples/simple-udp/fleetautoscaler.yaml @@ -17,7 +17,7 @@ # up and down depending on usage # -apiVersion: "stable.agones.dev/v1alpha1" +apiVersion: "autoscaling.agones.dev/v1alpha1" kind: FleetAutoscaler metadata: name: simple-udp-autoscaler diff --git a/examples/webhookfleetautoscaler.yaml b/examples/webhookfleetautoscaler.yaml index ca4ecc286f..d3f36ec816 100644 --- a/examples/webhookfleetautoscaler.yaml +++ b/examples/webhookfleetautoscaler.yaml @@ -16,7 +16,7 @@ # Full example of a FleetAutoscaler - this is used to scale a Fleet # automatically depending on load # -apiVersion: "stable.agones.dev/v1alpha1" +apiVersion: "autoscaling.agones.dev/v1alpha1" kind: FleetAutoscaler metadata: name: webhook-fleet-autoscaler diff --git a/examples/webhookfleetautoscalertls.yaml b/examples/webhookfleetautoscalertls.yaml index 55f0479a35..61dc4083b1 100644 --- a/examples/webhookfleetautoscalertls.yaml +++ b/examples/webhookfleetautoscalertls.yaml @@ -16,7 +16,7 @@ # Full example of a FleetAutoscaler - this is used to scale a Fleet # automatically depending on load # -apiVersion: "stable.agones.dev/v1alpha1" +apiVersion: "autoscaling.agones.dev/v1alpha1" kind: FleetAutoscaler metadata: name: webhook-fleetautoscaler-tls diff --git a/examples/xonotic/fleetautoscaler.yaml b/examples/xonotic/fleetautoscaler.yaml index 45348fc410..3f9a4d8f6c 100644 --- a/examples/xonotic/fleetautoscaler.yaml +++ b/examples/xonotic/fleetautoscaler.yaml @@ -17,7 +17,7 @@ # up and down depending on usage # -apiVersion: "stable.agones.dev/v1alpha1" +apiVersion: "autoscaling.agones.dev/v1alpha1" kind: FleetAutoscaler metadata: name: xonotic-autoscaler diff --git a/install/helm/agones/templates/crds/fleetautoscaler.yaml b/install/helm/agones/templates/crds/fleetautoscaler.yaml index 819233dc3d..8224a87a72 100644 --- a/install/helm/agones/templates/crds/fleetautoscaler.yaml +++ b/install/helm/agones/templates/crds/fleetautoscaler.yaml @@ -17,7 +17,7 @@ apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: - name: fleetautoscalers.stable.agones.dev + name: fleetautoscalers.autoscaling.agones.dev labels: component: crd app: {{ template "agones.name" . }} @@ -25,7 +25,7 @@ metadata: release: {{ .Release.Name }} heritage: {{ .Release.Service }} spec: - group: stable.agones.dev + group: autoscaling.agones.dev version: v1alpha1 scope: Namespaced names: diff --git a/install/helm/agones/templates/extensions.yaml b/install/helm/agones/templates/extensions.yaml index 7f1acdcb7f..19eba65dc5 100644 --- a/install/helm/agones/templates/extensions.yaml +++ b/install/helm/agones/templates/extensions.yaml @@ -75,7 +75,6 @@ webhooks: - "gameservers" - "gameserversets" - "fleetallocations" - - "fleetautoscalers" apiVersions: - "v1alpha1" operations: @@ -86,11 +85,20 @@ webhooks: - "fleets" - "gameserversets" - "fleetallocations" + apiVersions: + - "v1alpha1" + operations: + - UPDATE + - apiGroups: + - autoscaling.agones.dev + resources: - "fleetautoscalers" apiVersions: - "v1alpha1" operations: + - CREATE - UPDATE + --- apiVersion: admissionregistration.k8s.io/v1beta1 kind: MutatingWebhookConfiguration diff --git a/install/helm/agones/templates/hooks/sa.yaml b/install/helm/agones/templates/hooks/sa.yaml index c90017e9da..8cbaa950c5 100644 --- a/install/helm/agones/templates/hooks/sa.yaml +++ b/install/helm/agones/templates/hooks/sa.yaml @@ -44,7 +44,7 @@ metadata: "helm.sh/hook-weight": "-5" "helm.sh/hook-delete-policy": before-hook-creation rules: -- apiGroups: ["stable.agones.dev", "multicluster.agones.dev"] +- apiGroups: ["stable.agones.dev", "multicluster.agones.dev", "autoscaling.agones.dev"] resources: ["fleets", "fleetallocations", "fleetautoscalers", "gameservers", "gameserversets", "gameserverallocationpolicies"] verbs: ["delete", "list" ] - apiGroups: [""] diff --git a/install/helm/agones/templates/serviceaccounts/controller.yaml b/install/helm/agones/templates/serviceaccounts/controller.yaml index 1a4360b96c..6eb0c9e383 100644 --- a/install/helm/agones/templates/serviceaccounts/controller.yaml +++ b/install/helm/agones/templates/serviceaccounts/controller.yaml @@ -56,14 +56,20 @@ rules: resources: ["gameservers"] verbs: ["patch"] - apiGroups: ["stable.agones.dev"] - resources: ["fleets", "fleetallocations", "fleetautoscalers"] + resources: ["fleets", "fleetallocations"] verbs: ["get", "list", "update", "watch"] - apiGroups: ["stable.agones.dev"] - resources: ["fleets/status", "fleetautoscalers/status", "gameserversets/status"] + resources: ["fleets/status", "gameserversets/status"] verbs: ["update"] - apiGroups: ["multicluster.agones.dev"] resources: ["gameserverallocationpolicies"] verbs: ["create", "delete", "get", "list", "update", "watch"] +- apiGroups: ["autoscaling.agones.dev"] + resources: ["fleetautoscalers"] + verbs: ["get", "list", "update", "watch"] +- apiGroups: ["autoscaling.agones.dev"] + resources: ["fleetautoscalers/status"] + verbs: ["update"] --- diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index bb6093428e..877af0403e 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -54,14 +54,20 @@ rules: resources: ["gameservers"] verbs: ["patch"] - apiGroups: ["stable.agones.dev"] - resources: ["fleets", "fleetallocations", "fleetautoscalers"] + resources: ["fleets", "fleetallocations"] verbs: ["get", "list", "update", "watch"] - apiGroups: ["stable.agones.dev"] - resources: ["fleets/status", "fleetautoscalers/status", "gameserversets/status"] + resources: ["fleets/status", "gameserversets/status"] verbs: ["update"] - apiGroups: ["multicluster.agones.dev"] resources: ["gameserverallocationpolicies"] verbs: ["create", "delete", "get", "list", "update", "watch"] +- apiGroups: ["autoscaling.agones.dev"] + resources: ["fleetautoscalers"] + verbs: ["get", "list", "update", "watch"] +- apiGroups: ["autoscaling.agones.dev"] + resources: ["fleetautoscalers/status"] + verbs: ["update"] --- @@ -458,7 +464,7 @@ spec: apiVersion: apiextensions.k8s.io/v1beta1 kind: CustomResourceDefinition metadata: - name: fleetautoscalers.stable.agones.dev + name: fleetautoscalers.autoscaling.agones.dev labels: component: crd app: agones @@ -466,7 +472,7 @@ metadata: release: agones-manual heritage: Tiller spec: - group: stable.agones.dev + group: autoscaling.agones.dev version: v1alpha1 scope: Namespaced names: @@ -1486,7 +1492,6 @@ webhooks: - "gameservers" - "gameserversets" - "fleetallocations" - - "fleetautoscalers" apiVersions: - "v1alpha1" operations: @@ -1497,11 +1502,20 @@ webhooks: - "fleets" - "gameserversets" - "fleetallocations" + apiVersions: + - "v1alpha1" + operations: + - UPDATE + - apiGroups: + - autoscaling.agones.dev + resources: - "fleetautoscalers" apiVersions: - "v1alpha1" operations: + - CREATE - UPDATE + --- apiVersion: admissionregistration.k8s.io/v1beta1 kind: MutatingWebhookConfiguration diff --git a/pkg/apis/allocation/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/allocation/v1alpha1/zz_generated.deepcopy.go index 53a3739a06..a6cca75b24 100644 --- a/pkg/apis/allocation/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/allocation/v1alpha1/zz_generated.deepcopy.go @@ -90,6 +90,7 @@ func (in *GameServerAllocationList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *GameServerAllocationSpec) DeepCopyInto(out *GameServerAllocationSpec) { *out = *in + in.MultiClusterSetting.DeepCopyInto(&out.MultiClusterSetting) in.Required.DeepCopyInto(&out.Required) if in.Preferred != nil { in, out := &in.Preferred, &out.Preferred @@ -162,3 +163,20 @@ func (in *MetaPatch) DeepCopy() *MetaPatch { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MultiClusterSetting) DeepCopyInto(out *MultiClusterSetting) { + *out = *in + in.PolicySelector.DeepCopyInto(&out.PolicySelector) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MultiClusterSetting. +func (in *MultiClusterSetting) DeepCopy() *MultiClusterSetting { + if in == nil { + return nil + } + out := new(MultiClusterSetting) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/autoscaling/register.go b/pkg/apis/autoscaling/register.go new file mode 100644 index 0000000000..0b032f89f5 --- /dev/null +++ b/pkg/apis/autoscaling/register.go @@ -0,0 +1,20 @@ +// Copyright 2019 Google LLC 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. + +package autoscaling + +const ( + // GroupName is the Scheme Group Name for Agones Custom Resource Definitions + GroupName = "autoscaling.agones.dev" +) diff --git a/pkg/apis/autoscaling/v1alpha1/doc.go b/pkg/apis/autoscaling/v1alpha1/doc.go new file mode 100644 index 0000000000..eaa75fc431 --- /dev/null +++ b/pkg/apis/autoscaling/v1alpha1/doc.go @@ -0,0 +1,19 @@ +// Copyright 2019 Google LLC 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. + +// +k8s:deepcopy-gen=package,register + +// Package v1alpha1 is the v1alpha1 version of the API. +// +groupName=autoscaling.agones.dev +package v1alpha1 diff --git a/pkg/apis/stable/v1alpha1/fleetautoscaler.go b/pkg/apis/autoscaling/v1alpha1/fleetautoscaler.go similarity index 98% rename from pkg/apis/stable/v1alpha1/fleetautoscaler.go rename to pkg/apis/autoscaling/v1alpha1/fleetautoscaler.go index 73a18c3450..14c688d472 100644 --- a/pkg/apis/stable/v1alpha1/fleetautoscaler.go +++ b/pkg/apis/autoscaling/v1alpha1/fleetautoscaler.go @@ -1,4 +1,4 @@ -// Copyright 2018 Google LLC All Rights Reserved. +// Copyright 2019 Google LLC 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. @@ -18,6 +18,7 @@ import ( "crypto/x509" "net/url" + "agones.dev/agones/pkg/apis/stable/v1alpha1" admregv1b "k8s.io/api/admissionregistration/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" @@ -143,7 +144,7 @@ type FleetAutoscaleRequest struct { // Namespace is the namespace associated with the request (if any). Namespace string `json:"namespace"` // The Fleet's status values - Status FleetStatus `json:"status"` + Status v1alpha1.FleetStatus `json:"status"` } // FleetAutoscaleResponse defines the response of webhook autoscaler endpoint diff --git a/pkg/apis/stable/v1alpha1/fleetautoscaler_test.go b/pkg/apis/autoscaling/v1alpha1/fleetautoscaler_test.go similarity index 100% rename from pkg/apis/stable/v1alpha1/fleetautoscaler_test.go rename to pkg/apis/autoscaling/v1alpha1/fleetautoscaler_test.go diff --git a/pkg/apis/autoscaling/v1alpha1/register.go b/pkg/apis/autoscaling/v1alpha1/register.go new file mode 100644 index 0000000000..3f90f895a8 --- /dev/null +++ b/pkg/apis/autoscaling/v1alpha1/register.go @@ -0,0 +1,59 @@ +// Copyright 2019 Google LLC 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. + +package v1alpha1 + +import ( + "agones.dev/agones/pkg/apis/autoscaling" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + k8sruntime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/client-go/kubernetes/scheme" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: autoscaling.GroupName, Version: "v1alpha1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder registers our types + SchemeBuilder = k8sruntime.NewSchemeBuilder(addKnownTypes) + // AddToScheme local alias for SchemeBuilder.AddToScheme + AddToScheme = SchemeBuilder.AddToScheme +) + +func init() { + if err := AddToScheme(scheme.Scheme); err != nil { + panic(err) + } +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *k8sruntime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &FleetAutoscaler{}, + &FleetAutoscalerList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..064ac03a5c --- /dev/null +++ b/pkg/apis/autoscaling/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,285 @@ +// +build !ignore_autogenerated + +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1beta1 "k8s.io/api/admissionregistration/v1beta1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BufferPolicy) DeepCopyInto(out *BufferPolicy) { + *out = *in + out.BufferSize = in.BufferSize + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BufferPolicy. +func (in *BufferPolicy) DeepCopy() *BufferPolicy { + if in == nil { + return nil + } + out := new(BufferPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscaleRequest) DeepCopyInto(out *FleetAutoscaleRequest) { + *out = *in + out.Status = in.Status + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaleRequest. +func (in *FleetAutoscaleRequest) DeepCopy() *FleetAutoscaleRequest { + if in == nil { + return nil + } + out := new(FleetAutoscaleRequest) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscaleResponse) DeepCopyInto(out *FleetAutoscaleResponse) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaleResponse. +func (in *FleetAutoscaleResponse) DeepCopy() *FleetAutoscaleResponse { + if in == nil { + return nil + } + out := new(FleetAutoscaleResponse) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscaleReview) DeepCopyInto(out *FleetAutoscaleReview) { + *out = *in + if in.Request != nil { + in, out := &in.Request, &out.Request + if *in == nil { + *out = nil + } else { + *out = new(FleetAutoscaleRequest) + **out = **in + } + } + if in.Response != nil { + in, out := &in.Response, &out.Response + if *in == nil { + *out = nil + } else { + *out = new(FleetAutoscaleResponse) + **out = **in + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaleReview. +func (in *FleetAutoscaleReview) DeepCopy() *FleetAutoscaleReview { + if in == nil { + return nil + } + out := new(FleetAutoscaleReview) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscaler) DeepCopyInto(out *FleetAutoscaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaler. +func (in *FleetAutoscaler) DeepCopy() *FleetAutoscaler { + if in == nil { + return nil + } + out := new(FleetAutoscaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FleetAutoscaler) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscalerList) DeepCopyInto(out *FleetAutoscalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + out.ListMeta = in.ListMeta + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FleetAutoscaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerList. +func (in *FleetAutoscalerList) DeepCopy() *FleetAutoscalerList { + if in == nil { + return nil + } + out := new(FleetAutoscalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FleetAutoscalerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscalerPolicy) DeepCopyInto(out *FleetAutoscalerPolicy) { + *out = *in + if in.Buffer != nil { + in, out := &in.Buffer, &out.Buffer + if *in == nil { + *out = nil + } else { + *out = new(BufferPolicy) + **out = **in + } + } + if in.Webhook != nil { + in, out := &in.Webhook, &out.Webhook + if *in == nil { + *out = nil + } else { + *out = new(WebhookPolicy) + (*in).DeepCopyInto(*out) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerPolicy. +func (in *FleetAutoscalerPolicy) DeepCopy() *FleetAutoscalerPolicy { + if in == nil { + return nil + } + out := new(FleetAutoscalerPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscalerSpec) DeepCopyInto(out *FleetAutoscalerSpec) { + *out = *in + in.Policy.DeepCopyInto(&out.Policy) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerSpec. +func (in *FleetAutoscalerSpec) DeepCopy() *FleetAutoscalerSpec { + if in == nil { + return nil + } + out := new(FleetAutoscalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FleetAutoscalerStatus) DeepCopyInto(out *FleetAutoscalerStatus) { + *out = *in + if in.LastScaleTime != nil { + in, out := &in.LastScaleTime, &out.LastScaleTime + if *in == nil { + *out = nil + } else { + *out = (*in).DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerStatus. +func (in *FleetAutoscalerStatus) DeepCopy() *FleetAutoscalerStatus { + if in == nil { + return nil + } + out := new(FleetAutoscalerStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *WebhookPolicy) DeepCopyInto(out *WebhookPolicy) { + *out = *in + if in.URL != nil { + in, out := &in.URL, &out.URL + if *in == nil { + *out = nil + } else { + *out = new(string) + **out = **in + } + } + if in.Service != nil { + in, out := &in.Service, &out.Service + if *in == nil { + *out = nil + } else { + *out = new(v1beta1.ServiceReference) + (*in).DeepCopyInto(*out) + } + } + if in.CABundle != nil { + in, out := &in.CABundle, &out.CABundle + *out = make([]byte, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookPolicy. +func (in *WebhookPolicy) DeepCopy() *WebhookPolicy { + if in == nil { + return nil + } + out := new(WebhookPolicy) + in.DeepCopyInto(out) + return out +} diff --git a/pkg/apis/stable/v1alpha1/register.go b/pkg/apis/stable/v1alpha1/register.go index b3005942ec..6d181e1fda 100644 --- a/pkg/apis/stable/v1alpha1/register.go +++ b/pkg/apis/stable/v1alpha1/register.go @@ -59,8 +59,6 @@ func addKnownTypes(scheme *k8sruntime.Scheme) error { &FleetList{}, &FleetAllocation{}, &FleetAllocationList{}, - &FleetAutoscaler{}, - &FleetAutoscalerList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/apis/stable/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/stable/v1alpha1/zz_generated.deepcopy.go index c1996cea4e..a4bc18c98b 100644 --- a/pkg/apis/stable/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/stable/v1alpha1/zz_generated.deepcopy.go @@ -21,27 +21,9 @@ package v1alpha1 import ( - v1beta1 "k8s.io/api/admissionregistration/v1beta1" runtime "k8s.io/apimachinery/pkg/runtime" ) -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *BufferPolicy) DeepCopyInto(out *BufferPolicy) { - *out = *in - out.BufferSize = in.BufferSize - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BufferPolicy. -func (in *BufferPolicy) DeepCopy() *BufferPolicy { - if in == nil { - return nil - } - out := new(BufferPolicy) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Fleet) DeepCopyInto(out *Fleet) { *out = *in @@ -173,209 +155,6 @@ func (in *FleetAllocationStatus) DeepCopy() *FleetAllocationStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscaleRequest) DeepCopyInto(out *FleetAutoscaleRequest) { - *out = *in - out.Status = in.Status - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaleRequest. -func (in *FleetAutoscaleRequest) DeepCopy() *FleetAutoscaleRequest { - if in == nil { - return nil - } - out := new(FleetAutoscaleRequest) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscaleResponse) DeepCopyInto(out *FleetAutoscaleResponse) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaleResponse. -func (in *FleetAutoscaleResponse) DeepCopy() *FleetAutoscaleResponse { - if in == nil { - return nil - } - out := new(FleetAutoscaleResponse) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscaleReview) DeepCopyInto(out *FleetAutoscaleReview) { - *out = *in - if in.Request != nil { - in, out := &in.Request, &out.Request - if *in == nil { - *out = nil - } else { - *out = new(FleetAutoscaleRequest) - **out = **in - } - } - if in.Response != nil { - in, out := &in.Response, &out.Response - if *in == nil { - *out = nil - } else { - *out = new(FleetAutoscaleResponse) - **out = **in - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaleReview. -func (in *FleetAutoscaleReview) DeepCopy() *FleetAutoscaleReview { - if in == nil { - return nil - } - out := new(FleetAutoscaleReview) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscaler) DeepCopyInto(out *FleetAutoscaler) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscaler. -func (in *FleetAutoscaler) DeepCopy() *FleetAutoscaler { - if in == nil { - return nil - } - out := new(FleetAutoscaler) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FleetAutoscaler) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscalerList) DeepCopyInto(out *FleetAutoscalerList) { - *out = *in - out.TypeMeta = in.TypeMeta - out.ListMeta = in.ListMeta - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]FleetAutoscaler, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerList. -func (in *FleetAutoscalerList) DeepCopy() *FleetAutoscalerList { - if in == nil { - return nil - } - out := new(FleetAutoscalerList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *FleetAutoscalerList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscalerPolicy) DeepCopyInto(out *FleetAutoscalerPolicy) { - *out = *in - if in.Buffer != nil { - in, out := &in.Buffer, &out.Buffer - if *in == nil { - *out = nil - } else { - *out = new(BufferPolicy) - **out = **in - } - } - if in.Webhook != nil { - in, out := &in.Webhook, &out.Webhook - if *in == nil { - *out = nil - } else { - *out = new(WebhookPolicy) - (*in).DeepCopyInto(*out) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerPolicy. -func (in *FleetAutoscalerPolicy) DeepCopy() *FleetAutoscalerPolicy { - if in == nil { - return nil - } - out := new(FleetAutoscalerPolicy) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscalerSpec) DeepCopyInto(out *FleetAutoscalerSpec) { - *out = *in - in.Policy.DeepCopyInto(&out.Policy) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerSpec. -func (in *FleetAutoscalerSpec) DeepCopy() *FleetAutoscalerSpec { - if in == nil { - return nil - } - out := new(FleetAutoscalerSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *FleetAutoscalerStatus) DeepCopyInto(out *FleetAutoscalerStatus) { - *out = *in - if in.LastScaleTime != nil { - in, out := &in.LastScaleTime, &out.LastScaleTime - if *in == nil { - *out = nil - } else { - *out = (*in).DeepCopy() - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FleetAutoscalerStatus. -func (in *FleetAutoscalerStatus) DeepCopy() *FleetAutoscalerStatus { - if in == nil { - return nil - } - out := new(FleetAutoscalerStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FleetList) DeepCopyInto(out *FleetList) { *out = *in @@ -737,42 +516,3 @@ func (in *MetaPatch) DeepCopy() *MetaPatch { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *WebhookPolicy) DeepCopyInto(out *WebhookPolicy) { - *out = *in - if in.URL != nil { - in, out := &in.URL, &out.URL - if *in == nil { - *out = nil - } else { - *out = new(string) - **out = **in - } - } - if in.Service != nil { - in, out := &in.Service, &out.Service - if *in == nil { - *out = nil - } else { - *out = new(v1beta1.ServiceReference) - (*in).DeepCopyInto(*out) - } - } - if in.CABundle != nil { - in, out := &in.CABundle, &out.CABundle - *out = make([]byte, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new WebhookPolicy. -func (in *WebhookPolicy) DeepCopy() *WebhookPolicy { - if in == nil { - return nil - } - out := new(WebhookPolicy) - in.DeepCopyInto(out) - return out -} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index ebfbb84f04..19be232e6b 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -20,6 +20,7 @@ package versioned import ( allocationv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1alpha1" + autoscalingv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" multiclusterv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/multicluster/v1alpha1" stablev1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/stable/v1alpha1" discovery "k8s.io/client-go/discovery" @@ -32,6 +33,9 @@ type Interface interface { AllocationV1alpha1() allocationv1alpha1.AllocationV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Allocation() allocationv1alpha1.AllocationV1alpha1Interface + AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface + // Deprecated: please explicitly pick a version if possible. + Autoscaling() autoscalingv1alpha1.AutoscalingV1alpha1Interface MulticlusterV1alpha1() multiclusterv1alpha1.MulticlusterV1alpha1Interface // Deprecated: please explicitly pick a version if possible. Multicluster() multiclusterv1alpha1.MulticlusterV1alpha1Interface @@ -45,6 +49,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient allocationV1alpha1 *allocationv1alpha1.AllocationV1alpha1Client + autoscalingV1alpha1 *autoscalingv1alpha1.AutoscalingV1alpha1Client multiclusterV1alpha1 *multiclusterv1alpha1.MulticlusterV1alpha1Client stableV1alpha1 *stablev1alpha1.StableV1alpha1Client } @@ -60,6 +65,17 @@ func (c *Clientset) Allocation() allocationv1alpha1.AllocationV1alpha1Interface return c.allocationV1alpha1 } +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return c.autoscalingV1alpha1 +} + +// Deprecated: Autoscaling retrieves the default version of AutoscalingClient. +// Please explicitly pick a version. +func (c *Clientset) Autoscaling() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return c.autoscalingV1alpha1 +} + // MulticlusterV1alpha1 retrieves the MulticlusterV1alpha1Client func (c *Clientset) MulticlusterV1alpha1() multiclusterv1alpha1.MulticlusterV1alpha1Interface { return c.multiclusterV1alpha1 @@ -102,6 +118,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.autoscalingV1alpha1, err = autoscalingv1alpha1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.multiclusterV1alpha1, err = multiclusterv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -123,6 +143,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.allocationV1alpha1 = allocationv1alpha1.NewForConfigOrDie(c) + cs.autoscalingV1alpha1 = autoscalingv1alpha1.NewForConfigOrDie(c) cs.multiclusterV1alpha1 = multiclusterv1alpha1.NewForConfigOrDie(c) cs.stableV1alpha1 = stablev1alpha1.NewForConfigOrDie(c) @@ -134,6 +155,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.allocationV1alpha1 = allocationv1alpha1.New(c) + cs.autoscalingV1alpha1 = autoscalingv1alpha1.New(c) cs.multiclusterV1alpha1 = multiclusterv1alpha1.New(c) cs.stableV1alpha1 = stablev1alpha1.New(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 401597965d..b78ea1352d 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -22,6 +22,8 @@ import ( clientset "agones.dev/agones/pkg/client/clientset/versioned" allocationv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1alpha1" fakeallocationv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1alpha1/fake" + autoscalingv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + fakeautoscalingv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake" multiclusterv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/multicluster/v1alpha1" fakemulticlusterv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/multicluster/v1alpha1/fake" stablev1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/stable/v1alpha1" @@ -85,6 +87,16 @@ func (c *Clientset) Allocation() allocationv1alpha1.AllocationV1alpha1Interface return &fakeallocationv1alpha1.FakeAllocationV1alpha1{Fake: &c.Fake} } +// AutoscalingV1alpha1 retrieves the AutoscalingV1alpha1Client +func (c *Clientset) AutoscalingV1alpha1() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake} +} + +// Autoscaling retrieves the AutoscalingV1alpha1Client +func (c *Clientset) Autoscaling() autoscalingv1alpha1.AutoscalingV1alpha1Interface { + return &fakeautoscalingv1alpha1.FakeAutoscalingV1alpha1{Fake: &c.Fake} +} + // MulticlusterV1alpha1 retrieves the MulticlusterV1alpha1Client func (c *Clientset) MulticlusterV1alpha1() multiclusterv1alpha1.MulticlusterV1alpha1Interface { return &fakemulticlusterv1alpha1.FakeMulticlusterV1alpha1{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 729b860dea..2ee523200f 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -20,6 +20,7 @@ package fake import ( allocationv1alpha1 "agones.dev/agones/pkg/apis/allocation/v1alpha1" + autoscalingv1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" multiclusterv1alpha1 "agones.dev/agones/pkg/apis/multicluster/v1alpha1" stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -53,6 +54,7 @@ func init() { // correctly. func AddToScheme(scheme *runtime.Scheme) { allocationv1alpha1.AddToScheme(scheme) + autoscalingv1alpha1.AddToScheme(scheme) multiclusterv1alpha1.AddToScheme(scheme) stablev1alpha1.AddToScheme(scheme) } diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 7698386ea4..8df1dfdd95 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -20,6 +20,7 @@ package scheme import ( allocationv1alpha1 "agones.dev/agones/pkg/apis/allocation/v1alpha1" + autoscalingv1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" multiclusterv1alpha1 "agones.dev/agones/pkg/apis/multicluster/v1alpha1" stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -53,6 +54,7 @@ func init() { // correctly. func AddToScheme(scheme *runtime.Scheme) { allocationv1alpha1.AddToScheme(scheme) + autoscalingv1alpha1.AddToScheme(scheme) multiclusterv1alpha1.AddToScheme(scheme) stablev1alpha1.AddToScheme(scheme) } diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go new file mode 100644 index 0000000000..f244b7a867 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/autoscaling_client.go @@ -0,0 +1,90 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" + "agones.dev/agones/pkg/client/clientset/versioned/scheme" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + rest "k8s.io/client-go/rest" +) + +type AutoscalingV1alpha1Interface interface { + RESTClient() rest.Interface + FleetAutoscalersGetter +} + +// AutoscalingV1alpha1Client is used to interact with features provided by the autoscaling.agones.dev group. +type AutoscalingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *AutoscalingV1alpha1Client) FleetAutoscalers(namespace string) FleetAutoscalerInterface { + return newFleetAutoscalers(c, namespace) +} + +// NewForConfig creates a new AutoscalingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*AutoscalingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &AutoscalingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new AutoscalingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *AutoscalingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new AutoscalingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *AutoscalingV1alpha1Client { + return &AutoscalingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs} + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *AutoscalingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go new file mode 100644 index 0000000000..e9b701578e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/doc.go @@ -0,0 +1,20 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..36d8114553 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go new file mode 100644 index 0000000000..c15cea443d --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_autoscaling_client.go @@ -0,0 +1,40 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" +) + +type FakeAutoscalingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeAutoscalingV1alpha1) FleetAutoscalers(namespace string) v1alpha1.FleetAutoscalerInterface { + return &FakeFleetAutoscalers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeAutoscalingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_fleetautoscaler.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_fleetautoscaler.go similarity index 94% rename from pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_fleetautoscaler.go rename to pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_fleetautoscaler.go index fb4dc9589d..eb2cdb5739 100644 --- a/pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_fleetautoscaler.go +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fake/fake_fleetautoscaler.go @@ -19,7 +19,7 @@ package fake import ( - v1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" + v1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" labels "k8s.io/apimachinery/pkg/labels" schema "k8s.io/apimachinery/pkg/runtime/schema" @@ -30,13 +30,13 @@ import ( // FakeFleetAutoscalers implements FleetAutoscalerInterface type FakeFleetAutoscalers struct { - Fake *FakeStableV1alpha1 + Fake *FakeAutoscalingV1alpha1 ns string } -var fleetautoscalersResource = schema.GroupVersionResource{Group: "stable.agones.dev", Version: "v1alpha1", Resource: "fleetautoscalers"} +var fleetautoscalersResource = schema.GroupVersionResource{Group: "autoscaling.agones.dev", Version: "v1alpha1", Resource: "fleetautoscalers"} -var fleetautoscalersKind = schema.GroupVersionKind{Group: "stable.agones.dev", Version: "v1alpha1", Kind: "FleetAutoscaler"} +var fleetautoscalersKind = schema.GroupVersionKind{Group: "autoscaling.agones.dev", Version: "v1alpha1", Kind: "FleetAutoscaler"} // Get takes name of the fleetAutoscaler, and returns the corresponding fleetAutoscaler object, and an error if there is any. func (c *FakeFleetAutoscalers) Get(name string, options v1.GetOptions) (result *v1alpha1.FleetAutoscaler, err error) { diff --git a/pkg/client/clientset/versioned/typed/stable/v1alpha1/fleetautoscaler.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fleetautoscaler.go similarity index 97% rename from pkg/client/clientset/versioned/typed/stable/v1alpha1/fleetautoscaler.go rename to pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fleetautoscaler.go index 7e3c85b6b3..72d90afbc5 100644 --- a/pkg/client/clientset/versioned/typed/stable/v1alpha1/fleetautoscaler.go +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/fleetautoscaler.go @@ -19,7 +19,7 @@ package v1alpha1 import ( - v1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" + v1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" scheme "agones.dev/agones/pkg/client/clientset/versioned/scheme" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" types "k8s.io/apimachinery/pkg/types" @@ -54,7 +54,7 @@ type fleetAutoscalers struct { } // newFleetAutoscalers returns a FleetAutoscalers -func newFleetAutoscalers(c *StableV1alpha1Client, namespace string) *fleetAutoscalers { +func newFleetAutoscalers(c *AutoscalingV1alpha1Client, namespace string) *fleetAutoscalers { return &fleetAutoscalers{ client: c.RESTClient(), ns: namespace, diff --git a/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..e63f85d556 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1/generated_expansion.go @@ -0,0 +1,21 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type FleetAutoscalerExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_stable_client.go b/pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_stable_client.go index dd19ac4b2e..07b7ad60d7 100644 --- a/pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_stable_client.go +++ b/pkg/client/clientset/versioned/typed/stable/v1alpha1/fake/fake_stable_client.go @@ -36,10 +36,6 @@ func (c *FakeStableV1alpha1) FleetAllocations(namespace string) v1alpha1.FleetAl return &FakeFleetAllocations{c, namespace} } -func (c *FakeStableV1alpha1) FleetAutoscalers(namespace string) v1alpha1.FleetAutoscalerInterface { - return &FakeFleetAutoscalers{c, namespace} -} - func (c *FakeStableV1alpha1) GameServers(namespace string) v1alpha1.GameServerInterface { return &FakeGameServers{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/stable/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/stable/v1alpha1/generated_expansion.go index 4d85e6033f..c4feea7a1f 100644 --- a/pkg/client/clientset/versioned/typed/stable/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/stable/v1alpha1/generated_expansion.go @@ -22,8 +22,6 @@ type FleetExpansion interface{} type FleetAllocationExpansion interface{} -type FleetAutoscalerExpansion interface{} - type GameServerExpansion interface{} type GameServerSetExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/stable/v1alpha1/stable_client.go b/pkg/client/clientset/versioned/typed/stable/v1alpha1/stable_client.go index 95246ac41a..73333d3b1d 100644 --- a/pkg/client/clientset/versioned/typed/stable/v1alpha1/stable_client.go +++ b/pkg/client/clientset/versioned/typed/stable/v1alpha1/stable_client.go @@ -29,7 +29,6 @@ type StableV1alpha1Interface interface { RESTClient() rest.Interface FleetsGetter FleetAllocationsGetter - FleetAutoscalersGetter GameServersGetter GameServerSetsGetter } @@ -47,10 +46,6 @@ func (c *StableV1alpha1Client) FleetAllocations(namespace string) FleetAllocatio return newFleetAllocations(c, namespace) } -func (c *StableV1alpha1Client) FleetAutoscalers(namespace string) FleetAutoscalerInterface { - return newFleetAutoscalers(c, namespace) -} - func (c *StableV1alpha1Client) GameServers(namespace string) GameServerInterface { return newGameServers(c, namespace) } diff --git a/pkg/client/informers/externalversions/autoscaling/interface.go b/pkg/client/informers/externalversions/autoscaling/interface.go new file mode 100644 index 0000000000..c5627aa7c6 --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/interface.go @@ -0,0 +1,46 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by informer-gen. DO NOT EDIT. + +package autoscaling + +import ( + v1alpha1 "agones.dev/agones/pkg/client/informers/externalversions/autoscaling/v1alpha1" + internalinterfaces "agones.dev/agones/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface +} + +type group struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/stable/v1alpha1/fleetautoscaler.go b/pkg/client/informers/externalversions/autoscaling/v1alpha1/fleetautoscaler.go similarity index 88% rename from pkg/client/informers/externalversions/stable/v1alpha1/fleetautoscaler.go rename to pkg/client/informers/externalversions/autoscaling/v1alpha1/fleetautoscaler.go index 373a96944e..bf059227b7 100644 --- a/pkg/client/informers/externalversions/stable/v1alpha1/fleetautoscaler.go +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha1/fleetautoscaler.go @@ -21,10 +21,10 @@ package v1alpha1 import ( time "time" - stable_v1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" + autoscaling_v1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" versioned "agones.dev/agones/pkg/client/clientset/versioned" internalinterfaces "agones.dev/agones/pkg/client/informers/externalversions/internalinterfaces" - v1alpha1 "agones.dev/agones/pkg/client/listers/stable/v1alpha1" + v1alpha1 "agones.dev/agones/pkg/client/listers/autoscaling/v1alpha1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" watch "k8s.io/apimachinery/pkg/watch" @@ -61,16 +61,16 @@ func NewFilteredFleetAutoscalerInformer(client versioned.Interface, namespace st if tweakListOptions != nil { tweakListOptions(&options) } - return client.StableV1alpha1().FleetAutoscalers(namespace).List(options) + return client.AutoscalingV1alpha1().FleetAutoscalers(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.StableV1alpha1().FleetAutoscalers(namespace).Watch(options) + return client.AutoscalingV1alpha1().FleetAutoscalers(namespace).Watch(options) }, }, - &stable_v1alpha1.FleetAutoscaler{}, + &autoscaling_v1alpha1.FleetAutoscaler{}, resyncPeriod, indexers, ) @@ -81,7 +81,7 @@ func (f *fleetAutoscalerInformer) defaultInformer(client versioned.Interface, re } func (f *fleetAutoscalerInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&stable_v1alpha1.FleetAutoscaler{}, f.defaultInformer) + return f.factory.InformerFor(&autoscaling_v1alpha1.FleetAutoscaler{}, f.defaultInformer) } func (f *fleetAutoscalerInformer) Lister() v1alpha1.FleetAutoscalerLister { diff --git a/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go b/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go new file mode 100644 index 0000000000..f301d6f7a3 --- /dev/null +++ b/pkg/client/informers/externalversions/autoscaling/v1alpha1/interface.go @@ -0,0 +1,45 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + internalinterfaces "agones.dev/agones/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // FleetAutoscalers returns a FleetAutoscalerInformer. + FleetAutoscalers() FleetAutoscalerInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// FleetAutoscalers returns a FleetAutoscalerInformer. +func (v *version) FleetAutoscalers() FleetAutoscalerInformer { + return &fleetAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index f59cf55af8..2d4683dfb5 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -24,6 +24,7 @@ import ( time "time" versioned "agones.dev/agones/pkg/client/clientset/versioned" + autoscaling "agones.dev/agones/pkg/client/informers/externalversions/autoscaling" internalinterfaces "agones.dev/agones/pkg/client/informers/externalversions/internalinterfaces" multicluster "agones.dev/agones/pkg/client/informers/externalversions/multicluster" stable "agones.dev/agones/pkg/client/informers/externalversions/stable" @@ -173,10 +174,15 @@ type SharedInformerFactory interface { ForResource(resource schema.GroupVersionResource) (GenericInformer, error) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + Autoscaling() autoscaling.Interface Multicluster() multicluster.Interface Stable() stable.Interface } +func (f *sharedInformerFactory) Autoscaling() autoscaling.Interface { + return autoscaling.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Multicluster() multicluster.Interface { return multicluster.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index c9e6c0f7c2..f02cbf495c 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -21,7 +21,8 @@ package externalversions import ( "fmt" - v1alpha1 "agones.dev/agones/pkg/apis/multicluster/v1alpha1" + v1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" + multicluster_v1alpha1 "agones.dev/agones/pkg/apis/multicluster/v1alpha1" stable_v1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" @@ -53,8 +54,12 @@ func (f *genericInformer) Lister() cache.GenericLister { // TODO extend this to unknown resources with a client pool func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { - // Group=multicluster, Version=v1alpha1 - case v1alpha1.SchemeGroupVersion.WithResource("gameserverallocationpolicies"): + // Group=autoscaling.agones.dev, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("fleetautoscalers"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Autoscaling().V1alpha1().FleetAutoscalers().Informer()}, nil + + // Group=multicluster, Version=v1alpha1 + case multicluster_v1alpha1.SchemeGroupVersion.WithResource("gameserverallocationpolicies"): return &genericInformer{resource: resource.GroupResource(), informer: f.Multicluster().V1alpha1().GameServerAllocationPolicies().Informer()}, nil // Group=stable.agones.dev, Version=v1alpha1 @@ -62,8 +67,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Stable().V1alpha1().Fleets().Informer()}, nil case stable_v1alpha1.SchemeGroupVersion.WithResource("fleetallocations"): return &genericInformer{resource: resource.GroupResource(), informer: f.Stable().V1alpha1().FleetAllocations().Informer()}, nil - case stable_v1alpha1.SchemeGroupVersion.WithResource("fleetautoscalers"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Stable().V1alpha1().FleetAutoscalers().Informer()}, nil case stable_v1alpha1.SchemeGroupVersion.WithResource("gameservers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Stable().V1alpha1().GameServers().Informer()}, nil case stable_v1alpha1.SchemeGroupVersion.WithResource("gameserversets"): diff --git a/pkg/client/informers/externalversions/stable/v1alpha1/interface.go b/pkg/client/informers/externalversions/stable/v1alpha1/interface.go index 5528e666ed..a0a1e84f06 100644 --- a/pkg/client/informers/externalversions/stable/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/stable/v1alpha1/interface.go @@ -28,8 +28,6 @@ type Interface interface { Fleets() FleetInformer // FleetAllocations returns a FleetAllocationInformer. FleetAllocations() FleetAllocationInformer - // FleetAutoscalers returns a FleetAutoscalerInformer. - FleetAutoscalers() FleetAutoscalerInformer // GameServers returns a GameServerInformer. GameServers() GameServerInformer // GameServerSets returns a GameServerSetInformer. @@ -57,11 +55,6 @@ func (v *version) FleetAllocations() FleetAllocationInformer { return &fleetAllocationInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } -// FleetAutoscalers returns a FleetAutoscalerInformer. -func (v *version) FleetAutoscalers() FleetAutoscalerInformer { - return &fleetAutoscalerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // GameServers returns a GameServerInformer. func (v *version) GameServers() GameServerInformer { return &gameServerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go b/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go new file mode 100644 index 0000000000..b43b90b331 --- /dev/null +++ b/pkg/client/listers/autoscaling/v1alpha1/expansion_generated.go @@ -0,0 +1,27 @@ +// Copyright 2019 Google LLC 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. + +// This code was autogenerated. Do not edit directly. + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha1 + +// FleetAutoscalerListerExpansion allows custom methods to be added to +// FleetAutoscalerLister. +type FleetAutoscalerListerExpansion interface{} + +// FleetAutoscalerNamespaceListerExpansion allows custom methods to be added to +// FleetAutoscalerNamespaceLister. +type FleetAutoscalerNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/stable/v1alpha1/fleetautoscaler.go b/pkg/client/listers/autoscaling/v1alpha1/fleetautoscaler.go similarity index 98% rename from pkg/client/listers/stable/v1alpha1/fleetautoscaler.go rename to pkg/client/listers/autoscaling/v1alpha1/fleetautoscaler.go index 0613f9369f..5caba1bdee 100644 --- a/pkg/client/listers/stable/v1alpha1/fleetautoscaler.go +++ b/pkg/client/listers/autoscaling/v1alpha1/fleetautoscaler.go @@ -19,7 +19,7 @@ package v1alpha1 import ( - v1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" + v1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" diff --git a/pkg/client/listers/stable/v1alpha1/expansion_generated.go b/pkg/client/listers/stable/v1alpha1/expansion_generated.go index 01d0f48245..fb2a0ba7b2 100644 --- a/pkg/client/listers/stable/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/stable/v1alpha1/expansion_generated.go @@ -34,14 +34,6 @@ type FleetAllocationListerExpansion interface{} // FleetAllocationNamespaceLister. type FleetAllocationNamespaceListerExpansion interface{} -// FleetAutoscalerListerExpansion allows custom methods to be added to -// FleetAutoscalerLister. -type FleetAutoscalerListerExpansion interface{} - -// FleetAutoscalerNamespaceListerExpansion allows custom methods to be added to -// FleetAutoscalerNamespaceLister. -type FleetAutoscalerNamespaceListerExpansion interface{} - // GameServerListerExpansion allows custom methods to be added to // GameServerLister. type GameServerListerExpansion interface{} diff --git a/pkg/fleetautoscalers/controller.go b/pkg/fleetautoscalers/controller.go index cba04cb5c8..e01ba63e15 100644 --- a/pkg/fleetautoscalers/controller.go +++ b/pkg/fleetautoscalers/controller.go @@ -19,13 +19,15 @@ import ( "fmt" "time" - "agones.dev/agones/pkg/apis/stable" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + "agones.dev/agones/pkg/apis/autoscaling" + "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" "agones.dev/agones/pkg/client/clientset/versioned" - getterv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/stable/v1alpha1" + autoscalingv1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/autoscaling/v1alpha1" + typedstablev1alpha1 "agones.dev/agones/pkg/client/clientset/versioned/typed/stable/v1alpha1" "agones.dev/agones/pkg/client/informers/externalversions" - listerv1alpha1 "agones.dev/agones/pkg/client/listers/stable/v1alpha1" + listerv1alpha1 "agones.dev/agones/pkg/client/listers/autoscaling/v1alpha1" + listerstablev1alpha1 "agones.dev/agones/pkg/client/listers/stable/v1alpha1" "agones.dev/agones/pkg/util/crd" "agones.dev/agones/pkg/util/logfields" "agones.dev/agones/pkg/util/runtime" @@ -52,10 +54,10 @@ import ( type Controller struct { baseLogger *logrus.Entry crdGetter v1beta1.CustomResourceDefinitionInterface - fleetGetter getterv1alpha1.FleetsGetter - fleetLister listerv1alpha1.FleetLister + fleetGetter typedstablev1alpha1.FleetsGetter + fleetLister listerstablev1alpha1.FleetLister fleetSynced cache.InformerSynced - fleetAutoscalerGetter getterv1alpha1.FleetAutoscalersGetter + fleetAutoscalerGetter autoscalingv1alpha1.FleetAutoscalersGetter fleetAutoscalerLister listerv1alpha1.FleetAutoscalerLister fleetAutoscalerSynced cache.InformerSynced workerqueue *workerqueue.WorkerQueue @@ -71,20 +73,19 @@ func NewController( agonesClient versioned.Interface, agonesInformerFactory externalversions.SharedInformerFactory) *Controller { - agonesInformer := agonesInformerFactory.Stable().V1alpha1() - fasInformer := agonesInformer.FleetAutoscalers().Informer() - + autoscaler := agonesInformerFactory.Autoscaling().V1alpha1().FleetAutoscalers() + fleetInformer := agonesInformerFactory.Stable().V1alpha1().Fleets() c := &Controller{ crdGetter: extClient.ApiextensionsV1beta1().CustomResourceDefinitions(), fleetGetter: agonesClient.StableV1alpha1(), - fleetLister: agonesInformer.Fleets().Lister(), - fleetSynced: agonesInformer.Fleets().Informer().HasSynced, - fleetAutoscalerGetter: agonesClient.StableV1alpha1(), - fleetAutoscalerLister: agonesInformer.FleetAutoscalers().Lister(), - fleetAutoscalerSynced: fasInformer.HasSynced, + fleetLister: fleetInformer.Lister(), + fleetSynced: fleetInformer.Informer().HasSynced, + fleetAutoscalerGetter: agonesClient.AutoscalingV1alpha1(), + fleetAutoscalerLister: autoscaler.Lister(), + fleetAutoscalerSynced: autoscaler.Informer().HasSynced, } c.baseLogger = runtime.NewLoggerWithType(c) - c.workerqueue = workerqueue.NewWorkerQueue(c.syncFleetAutoscaler, c.baseLogger, logfields.FleetAutoscalerKey, stable.GroupName+".FleetAutoscalerController") + c.workerqueue = workerqueue.NewWorkerQueue(c.syncFleetAutoscaler, c.baseLogger, logfields.FleetAutoscalerKey, autoscaling.GroupName+".FleetAutoscalerController") health.AddLivenessCheck("fleetautoscaler-workerqueue", healthcheck.Check(c.workerqueue.Healthy)) eventBroadcaster := record.NewBroadcaster() @@ -92,11 +93,11 @@ func NewController( eventBroadcaster.StartRecordingToSink(&typedcorev1.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")}) c.recorder = eventBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: "fleetautoscaler-controller"}) - kind := stablev1alpha1.Kind("FleetAutoscaler") + kind := v1alpha1.Kind("FleetAutoscaler") wh.AddHandler("/validate", kind, admv1beta1.Create, c.validationHandler) wh.AddHandler("/validate", kind, admv1beta1.Update, c.validationHandler) - fasInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{ + autoscaler.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{ AddFunc: c.workerqueue.Enqueue, UpdateFunc: func(_, newObj interface{}) { c.workerqueue.Enqueue(newObj) @@ -109,7 +110,7 @@ func NewController( // Run the FleetAutoscaler controller. Will block until stop is closed. // Runs threadiness number workers to process the rate limited queue func (c *Controller) Run(workers int, stop <-chan struct{}) error { - err := crd.WaitForEstablishedCRD(c.crdGetter, "fleetautoscalers."+stable.GroupName, c.baseLogger) + err := crd.WaitForEstablishedCRD(c.crdGetter, "fleetautoscalers."+autoscaling.GroupName, c.baseLogger) if err != nil { return err } @@ -139,7 +140,7 @@ func (c *Controller) loggerForFleetAutoscaler(fas *v1alpha1.FleetAutoscaler) *lo // validate its settings. func (c *Controller) validationHandler(review admv1beta1.AdmissionReview) (admv1beta1.AdmissionReview, error) { obj := review.Request.Object - fas := &stablev1alpha1.FleetAutoscaler{} + fas := &v1alpha1.FleetAutoscaler{} err := json.Unmarshal(obj.Raw, fas) if err != nil { c.baseLogger.WithField("review", review).WithError(err).Info("validationHandler") @@ -230,7 +231,7 @@ func (c *Controller) syncFleetAutoscaler(key string) error { } // scaleFleet scales the fleet of the autoscaler to a new number of replicas -func (c *Controller) scaleFleet(fas *stablev1alpha1.FleetAutoscaler, f *stablev1alpha1.Fleet, replicas int32) error { +func (c *Controller) scaleFleet(fas *v1alpha1.FleetAutoscaler, f *stablev1alpha1.Fleet, replicas int32) error { if replicas != f.Spec.Replicas { fCopy := f.DeepCopy() fCopy.Spec.Replicas = replicas @@ -249,7 +250,7 @@ func (c *Controller) scaleFleet(fas *stablev1alpha1.FleetAutoscaler, f *stablev1 } // updateStatus updates the status of the given FleetAutoscaler -func (c *Controller) updateStatus(fas *stablev1alpha1.FleetAutoscaler, currentReplicas int32, desiredReplicas int32, scaled bool, scalingLimited bool) error { +func (c *Controller) updateStatus(fas *v1alpha1.FleetAutoscaler, currentReplicas int32, desiredReplicas int32, scaled bool, scalingLimited bool) error { fasCopy := fas.DeepCopy() fasCopy.Status.AbleToScale = true fasCopy.Status.ScalingLimited = scalingLimited @@ -275,7 +276,7 @@ func (c *Controller) updateStatus(fas *stablev1alpha1.FleetAutoscaler, currentRe } // updateStatus updates the status of the given FleetAutoscaler in the case we're not able to scale -func (c *Controller) updateStatusUnableToScale(fas *stablev1alpha1.FleetAutoscaler) error { +func (c *Controller) updateStatusUnableToScale(fas *v1alpha1.FleetAutoscaler) error { fasCopy := fas.DeepCopy() fasCopy.Status.AbleToScale = false fasCopy.Status.ScalingLimited = false diff --git a/pkg/fleetautoscalers/controller_test.go b/pkg/fleetautoscalers/controller_test.go index a3f25b7958..23b5adf918 100644 --- a/pkg/fleetautoscalers/controller_test.go +++ b/pkg/fleetautoscalers/controller_test.go @@ -20,7 +20,8 @@ import ( "net/http" "testing" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" + stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" agtesting "agones.dev/agones/pkg/testing" "agones.dev/agones/pkg/util/webhooks" "github.com/heptiolabs/healthcheck" @@ -34,7 +35,7 @@ import ( ) var ( - gvk = metav1.GroupVersionKind(v1alpha1.SchemeGroupVersion.WithKind("FleetAutoscaler")) + gvk = metav1.GroupVersionKind(stablev1alpha1.SchemeGroupVersion.WithKind("FleetAutoscaler")) ) func TestControllerCreationValidationHandler(t *testing.T) { @@ -149,13 +150,13 @@ func TestControllerSyncFleetAutoscaler(t *testing.T) { }) m.AgonesClient.AddReactor("list", "fleets", func(action k8stesting.Action) (bool, runtime.Object, error) { - return true, &v1alpha1.FleetList{Items: []v1alpha1.Fleet{*f}}, nil + return true, &stablev1alpha1.FleetList{Items: []stablev1alpha1.Fleet{*f}}, nil }) m.AgonesClient.AddReactor("update", "fleets", func(action k8stesting.Action) (bool, runtime.Object, error) { fUpdated = true ca := action.(k8stesting.UpdateAction) - f := ca.GetObject().(*v1alpha1.Fleet) + f := ca.GetObject().(*stablev1alpha1.Fleet) assert.Equal(t, f.Spec.Replicas, int32(12)) return true, f, nil }) @@ -202,13 +203,13 @@ func TestControllerSyncFleetAutoscaler(t *testing.T) { }) m.AgonesClient.AddReactor("list", "fleets", func(action k8stesting.Action) (bool, runtime.Object, error) { - return true, &v1alpha1.FleetList{Items: []v1alpha1.Fleet{*f}}, nil + return true, &stablev1alpha1.FleetList{Items: []stablev1alpha1.Fleet{*f}}, nil }) m.AgonesClient.AddReactor("update", "fleets", func(action k8stesting.Action) (bool, runtime.Object, error) { fUpdated = true ca := action.(k8stesting.UpdateAction) - f := ca.GetObject().(*v1alpha1.Fleet) + f := ca.GetObject().(*stablev1alpha1.Fleet) assert.Equal(t, f.Spec.Replicas, int32(13)) return true, f, nil @@ -304,7 +305,7 @@ func TestControllerScaleFleet(t *testing.T) { m.AgonesClient.AddReactor("update", "fleets", func(action k8stesting.Action) (bool, runtime.Object, error) { update = true ca := action.(k8stesting.UpdateAction) - f := ca.GetObject().(*v1alpha1.Fleet) + f := ca.GetObject().(*stablev1alpha1.Fleet) assert.Equal(t, replicas, f.Spec.Replicas) return true, f, nil @@ -448,18 +449,18 @@ func TestControllerUpdateStatusUnableToScale(t *testing.T) { }) } -func defaultFixtures() (*v1alpha1.FleetAutoscaler, *v1alpha1.Fleet) { - f := &v1alpha1.Fleet{ +func defaultFixtures() (*v1alpha1.FleetAutoscaler, *stablev1alpha1.Fleet) { + f := &stablev1alpha1.Fleet{ ObjectMeta: metav1.ObjectMeta{ Name: "fleet-1", Namespace: "default", UID: "1234", }, - Spec: v1alpha1.FleetSpec{ + Spec: stablev1alpha1.FleetSpec{ Replicas: 8, - Template: v1alpha1.GameServerTemplateSpec{}, + Template: stablev1alpha1.GameServerTemplateSpec{}, }, - Status: v1alpha1.FleetStatus{ + Status: stablev1alpha1.FleetStatus{ Replicas: 5, ReadyReplicas: 3, ReservedReplicas: 3, @@ -487,7 +488,7 @@ func defaultFixtures() (*v1alpha1.FleetAutoscaler, *v1alpha1.Fleet) { return fas, f } -func defaultWebhookFixtures() (*v1alpha1.FleetAutoscaler, *v1alpha1.Fleet) { +func defaultWebhookFixtures() (*v1alpha1.FleetAutoscaler, *stablev1alpha1.Fleet) { fas, f := defaultFixtures() fas.Spec.Policy.Type = v1alpha1.WebhookPolicyType fas.Spec.Policy.Buffer = nil diff --git a/pkg/fleetautoscalers/fleetautoscalers.go b/pkg/fleetautoscalers/fleetautoscalers.go index 089e82b51a..bb74438f23 100644 --- a/pkg/fleetautoscalers/fleetautoscalers.go +++ b/pkg/fleetautoscalers/fleetautoscalers.go @@ -28,7 +28,7 @@ import ( "strings" "time" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" "github.com/pkg/errors" "k8s.io/apimachinery/pkg/util/intstr" @@ -40,19 +40,19 @@ var client = http.Client{ } // computeDesiredFleetSize computes the new desired size of the given fleet -func computeDesiredFleetSize(fas *stablev1alpha1.FleetAutoscaler, f *stablev1alpha1.Fleet) (int32, bool, error) { +func computeDesiredFleetSize(fas *v1alpha1.FleetAutoscaler, f *stablev1alpha1.Fleet) (int32, bool, error) { switch fas.Spec.Policy.Type { - case stablev1alpha1.BufferPolicyType: + case v1alpha1.BufferPolicyType: return applyBufferPolicy(fas.Spec.Policy.Buffer, f) - case stablev1alpha1.WebhookPolicyType: + case v1alpha1.WebhookPolicyType: return applyWebhookPolicy(fas.Spec.Policy.Webhook, f) } return f.Status.Replicas, false, errors.New("wrong policy type, should be one of: Buffer, Webhook") } -func applyWebhookPolicy(w *stablev1alpha1.WebhookPolicy, f *stablev1alpha1.Fleet) (int32, bool, error) { +func applyWebhookPolicy(w *v1alpha1.WebhookPolicy, f *stablev1alpha1.Fleet) (int32, bool, error) { faReq := v1alpha1.FleetAutoscaleReview{ Request: &v1alpha1.FleetAutoscaleRequest{ UID: uuid.NewUUID(), @@ -135,7 +135,7 @@ func applyWebhookPolicy(w *stablev1alpha1.WebhookPolicy, f *stablev1alpha1.Fleet return f.Status.Replicas, false, nil } -func applyBufferPolicy(b *stablev1alpha1.BufferPolicy, f *stablev1alpha1.Fleet) (int32, bool, error) { +func applyBufferPolicy(b *v1alpha1.BufferPolicy, f *stablev1alpha1.Fleet) (int32, bool, error) { var replicas int32 if b.BufferSize.Type == intstr.Int { diff --git a/pkg/fleetautoscalers/fleetautoscalers_test.go b/pkg/fleetautoscalers/fleetautoscalers_test.go index 09cb6ae2a4..94fa9abbc4 100644 --- a/pkg/fleetautoscalers/fleetautoscalers_test.go +++ b/pkg/fleetautoscalers/fleetautoscalers_test.go @@ -24,7 +24,7 @@ import ( "net/http/httptest" "testing" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/util/intstr" ) diff --git a/pkg/metrics/controller.go b/pkg/metrics/controller.go index 1530628a50..fe2c82e602 100644 --- a/pkg/metrics/controller.go +++ b/pkg/metrics/controller.go @@ -21,9 +21,7 @@ import ( "sync" "time" - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/client-go/listers/core/v1" - + autoscalingv1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" "agones.dev/agones/pkg/client/clientset/versioned" "agones.dev/agones/pkg/client/informers/externalversions" @@ -33,11 +31,13 @@ import ( "github.com/sirupsen/logrus" "go.opencensus.io/stats" "go.opencensus.io/tag" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" + v1 "k8s.io/client-go/listers/core/v1" "k8s.io/client-go/tools/cache" ) @@ -80,7 +80,7 @@ func NewController( faInformer := fa.Informer() fleets := agonesInformerFactory.Stable().V1alpha1().Fleets() fInformer := fleets.Informer() - fas := agonesInformerFactory.Stable().V1alpha1().FleetAutoscalers() + fas := agonesInformerFactory.Autoscaling().V1alpha1().FleetAutoscalers() fasInformer := fas.Informer() node := kubeInformerFactory.Core().V1().Nodes() nodeInformer := node.Informer() @@ -129,7 +129,7 @@ func NewController( func (c *Controller) recordFleetAutoScalerChanges(old, new interface{}) { - fas, ok := new.(*stablev1alpha1.FleetAutoscaler) + fas, ok := new.(*autoscalingv1alpha1.FleetAutoscaler) if !ok { return } @@ -137,7 +137,7 @@ func (c *Controller) recordFleetAutoScalerChanges(old, new interface{}) { // we looking for fleet name changes if that happens we need to reset // metrics for the old fas. if old != nil { - if oldFas, ok := old.(*stablev1alpha1.FleetAutoscaler); ok && + if oldFas, ok := old.(*autoscalingv1alpha1.FleetAutoscaler); ok && oldFas.Spec.FleetName != fas.Spec.FleetName { c.recordFleetAutoScalerDeletion(old) } @@ -194,7 +194,7 @@ func (c *Controller) recordFleetAutoScalerChanges(old, new interface{}) { } func (c *Controller) recordFleetAutoScalerDeletion(obj interface{}) { - fas, ok := obj.(*stablev1alpha1.FleetAutoscaler) + fas, ok := obj.(*autoscalingv1alpha1.FleetAutoscaler) if !ok { return } diff --git a/pkg/metrics/util_test.go b/pkg/metrics/util_test.go index 1c82cd7d68..31365e6e89 100644 --- a/pkg/metrics/util_test.go +++ b/pkg/metrics/util_test.go @@ -18,11 +18,11 @@ import ( "context" "testing" - v1 "k8s.io/api/core/v1" - + autoscalingv1alpha1 "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" "agones.dev/agones/pkg/apis/stable/v1alpha1" agtesting "agones.dev/agones/pkg/testing" "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/rand" @@ -183,25 +183,25 @@ func fleet(fleetName string, total, allocated, ready, desired int32) *v1alpha1.F } } -func fleetAutoScaler(fleetName string, fasName string) *v1alpha1.FleetAutoscaler { - return &v1alpha1.FleetAutoscaler{ +func fleetAutoScaler(fleetName string, fasName string) *autoscalingv1alpha1.FleetAutoscaler { + return &autoscalingv1alpha1.FleetAutoscaler{ ObjectMeta: metav1.ObjectMeta{ Name: fasName, Namespace: "default", UID: uuid.NewUUID(), }, - Spec: v1alpha1.FleetAutoscalerSpec{ + Spec: autoscalingv1alpha1.FleetAutoscalerSpec{ FleetName: fleetName, - Policy: v1alpha1.FleetAutoscalerPolicy{ - Type: v1alpha1.BufferPolicyType, - Buffer: &v1alpha1.BufferPolicy{ + Policy: autoscalingv1alpha1.FleetAutoscalerPolicy{ + Type: autoscalingv1alpha1.BufferPolicyType, + Buffer: &autoscalingv1alpha1.BufferPolicy{ MaxReplicas: 30, MinReplicas: 10, BufferSize: intstr.FromInt(11), }, }, }, - Status: v1alpha1.FleetAutoscalerStatus{ + Status: autoscalingv1alpha1.FleetAutoscalerStatus{ AbleToScale: true, ScalingLimited: false, CurrentReplicas: 10, diff --git a/site/content/en/docs/Getting Started/create-fleetautoscaler.md b/site/content/en/docs/Getting Started/create-fleetautoscaler.md index c2f524f8f9..9399b392ea 100644 --- a/site/content/en/docs/Getting Started/create-fleetautoscaler.md +++ b/site/content/en/docs/Getting Started/create-fleetautoscaler.md @@ -30,9 +30,17 @@ kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/agones/{{ You should see a successful output similar to this : +{{% feature expiryVersion="0.11.0" %}} ``` fleetautoscaler.stable.agones.sev "simple-udp-autoscaler" created ``` +{{% /feature %}} +{{% feature publishversion="0.11.0" %}} +``` +fleetautoscaler.autoscaling.agones.sev "simple-udp-autoscaler" created +``` +{{% /feature %}} + This has created a FleetAutoscaler record inside Kubernetes. @@ -44,6 +52,7 @@ kubectl describe fleetautoscaler simple-udp-autoscaler It should look something like this: +{{% feature expiryVersion="0.11.0" %}} ``` Name: simple-udp-autoscaler Namespace: default @@ -84,6 +93,50 @@ Status: Scaling Limited: false Events: ``` +{{% /feature %}} +{{% feature publishversion="0.11.0" %}} +``` +Name: simple-udp-autoscaler +Namespace: default +Labels: +Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"st +able.agones.dev/v1alpha1","kind":"FleetAutoscaler","metadata":{"annotations":{}, +"name":"simple-udp-autoscaler","namespace":"default"},... +API Version: autoscaling.agones.dev/v1alpha1 +Kind: FleetAutoscaler +Metadata: + Cluster Name: + Creation Timestamp: 2018-10-02T15:19:58Z + Generation: 1 + Owner References: + API Version: autoscaling.agones.dev/v1alpha1 + 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/v1alpha1/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: + Scaling Limited: false +Events: +``` +{{% /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. diff --git a/site/content/en/docs/Getting Started/create-webhook-fleetautoscaler.md b/site/content/en/docs/Getting Started/create-webhook-fleetautoscaler.md index 790402f0b0..9fc8d4f206 100644 --- a/site/content/en/docs/Getting Started/create-webhook-fleetautoscaler.md +++ b/site/content/en/docs/Getting Started/create-webhook-fleetautoscaler.md @@ -71,9 +71,17 @@ kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/agones/{{ You should see a successful output similar to this: +{{% feature expiryVersion="0.11.0" %}} ``` fleetautoscaler.stable.agones.sev "webhook-fleet-autoscaler" created ``` +{{% /feature %}} +{{% feature publishversion="0.11.0" %}} +``` +fleetautoscaler.autoscaling.agones.sev "webhook-fleet-autoscaler" created +``` +{{% /feature %}} + This has created a FleetAutoscaler record inside Kubernetes. It has the link to Webhook service we deployed above. @@ -94,6 +102,7 @@ kubectl describe fleetautoscaler webhook-fleet-autoscaler It should look something like this: +{{% feature expiryVersion="0.11.0" %}} ``` Name: webhook-fleet-autoscaler Namespace: default @@ -126,6 +135,42 @@ Status: Scaling Limited: false Events: ``` +{{% /feature %}} +{{% feature publishversion="0.11.0" %}} +``` +Name: webhook-fleet-autoscaler +Namespace: default +Labels: +Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"autoscaling.agones.dev/v1alpha1","kind":"FleetAutoscaler","metadata":{"annotations":{},"name":"webhook-fleet-autoscaler","namespace":"default... +API Version: autoscaling.agones.dev/v1alpha1 +Kind: FleetAutoscaler +etadata: + Cluster Name: + Creation Timestamp: 2018-12-22T12:52:23Z + Generation: 1 + Resource Version: 2274579 + Self Link: /apis/autoscaling.agones.dev/v1alpha1/namespaces/default/fleetautoscalers/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: + Scaling Limited: false +Events: +``` +{{% /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. diff --git a/site/content/en/docs/Reference/agones_crd_api_reference.html b/site/content/en/docs/Reference/agones_crd_api_reference.html index f463e27f77..e6aeb2110b 100644 --- a/site/content/en/docs/Reference/agones_crd_api_reference.html +++ b/site/content/en/docs/Reference/agones_crd_api_reference.html @@ -4557,6 +4557,7 @@

WebhookPolicy {{% /feature %}} + {{% feature publishVersion="0.11.0" %}}

Packages:

@@ -4967,26 +4971,18 @@

MultiClusterSetting
-

stable.agones.dev

+

autoscaling.agones.dev

Package v1alpha1 is the v1alpha1 version of the API.

Resource Types: -

Fleet +

FleetAutoscaler

-

Fleet is the data structure for a Fleet resource

+

FleetAutoscaler is the data structure for a FleetAutoscaler resource

@@ -5002,7 +4998,7 @@

Fleet string

@@ -5011,7 +5007,7 @@

Fleet kind
string -

+ @@ -5042,50 +5038,25 @@

Fleet

-stable.agones.dev/v1alpha1 +autoscaling.agones.dev/v1alpha1
FleetFleetAutoscaler
@@ -5031,8 +5027,8 @@

Fleet

spec
- -FleetSpec + +FleetAutoscalerSpec
- - - - - - - -
-replicas
- -int32 - -
-

Replicas are the number of GameServers that should be in this set

-
-strategy
- - -Kubernetes apps/v1.DeploymentStrategy - - -
-

Deployment strategy

-
-scheduling
+fleetName
-agones.dev/agones/pkg/apis.SchedulingStrategy +string
-

Scheduling strategy. Defaults to “Packed”.

-template
+policy
- -GameServerTemplateSpec + +FleetAutoscalerPolicy
-

Template the GameServer template to apply for this Fleet

+

Autoscaling policy

@@ -5095,8 +5066,8 @@

Fleet status
- -FleetStatus + +FleetAutoscalerStatus @@ -5105,11 +5076,14 @@

Fleet -

FleetAllocation +

BufferPolicy

-

FleetAllocation is the data structure for allocating against a Fleet -Deprecated: Please use GameServerAllocation instead.

+(Appears on: +FleetAutoscalerPolicy) +

+

+

BufferPolicy controls the desired behavior of the buffer policy.

@@ -5121,91 +5095,127 @@

FleetAllocation

+maxReplicas
+ +int32 + + + - + +
-apiVersion
-string
- -stable.agones.dev/v1alpha1 - +

MaxReplicas is the maximum amount of replicas that the fleet may have. +It must be bigger than both MinReplicas and BufferSize

-kind
-string +minReplicas
+ +int32 + +
+

MinReplicas is the minimum amount of replicas that the fleet must have +If zero, it is ignored. +If non zero, it must be smaller than MaxReplicas and bigger than BufferSize

FleetAllocation
-metadata
+bufferSize
- -Kubernetes meta/v1.ObjectMeta - +k8s.io/apimachinery/pkg/util/intstr.IntOrString
-Refer to the Kubernetes API documentation for the fields of the -metadata field. +

BufferSize defines how many replicas the autoscaler tries to have ready all the time +Value can be an absolute number (ex: 5) or a percentage of desired gs instances (ex: 15%) +Absolute number is calculated from percentage by rounding up. +Example: when this is set to 20%, the autoscaler will make sure that 20% +of the fleet’s game server replicas are ready. When this is set to 20, +the autoscaler will make sure that there are 20 available game servers +Must be bigger than 0 +Note: by “ready” we understand in this case “non-allocated”; this is done to ensure robustness +and computation stability in different edge case (fleet just created, not enough +capacity in the cluster etc)

+

FleetAutoscaleRequest +

+

+(Appears on: +FleetAutoscaleReview) +

+

+

FleetAutoscaleRequest defines the request to webhook autoscaler endpoint

+

+ + + + + + + +
FieldDescription
-spec
+uid
- -FleetAllocationSpec - +k8s.io/apimachinery/pkg/types.UID
-
-
- +

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.

+ + - -
-fleetName
+name
string
+

Name is the name of the Fleet being scaled

-metadata
+namespace
- -MetaPatch - +string
-
+

Namespace is the namespace associated with the request (if any).

status
- -FleetAllocationStatus + +FleetStatus
+

The Fleet’s status values

-

FleetAutoscaler +

FleetAutoscaleResponse

-

FleetAutoscaler is the data structure for a FleetAutoscaler resource

+(Appears on: +FleetAutoscaleReview) +

+

+

FleetAutoscaleResponse defines the response of webhook autoscaler endpoint

@@ -5217,80 +5227,72 @@

FleetAutoscaler

- - - - + + +
-apiVersion
-string
- -stable.agones.dev/v1alpha1 - +uid
+ +k8s.io/apimachinery/pkg/types.UID +
-kind
-string +

UID is an identifier for the individual request/response. +This should be copied over from the corresponding FleetAutoscaleRequest.

FleetAutoscaler
-metadata
+scale
- -Kubernetes meta/v1.ObjectMeta - +bool
-Refer to the Kubernetes API documentation for the fields of the -metadata field. +

Set to false if no scaling should occur to the Fleet

-spec
+replicas
- -FleetAutoscalerSpec - +int32
-
-
+

The targeted replica count

+
+

FleetAutoscaleReview +

+

+

FleetAutoscaleReview is passed to the webhook with a populated Request value, +and then returned with a populated Response.

+

+ - - + + + + - -
-fleetName
- -string - -
-FieldDescription
-policy
+request
- -FleetAutoscalerPolicy + +FleetAutoscaleRequest
-

Autoscaling policy

-
-status
+response
- -FleetAutoscalerStatus + +FleetAutoscaleResponse @@ -5299,14 +5301,14 @@

FleetAutoscaler -

GameServer +

FleetAutoscalerPolicy

(Appears on: -FleetAllocationStatus) +FleetAutoscalerSpec)

-

GameServer is the data structure for a gameserver resource

+

FleetAutoscalerPolicy describes how to scale a fleet

@@ -5318,133 +5320,280 @@

GameServer

+type
+ + +FleetAutoscalerPolicyType + + + + - + + +
-apiVersion
-string
- -stable.agones.dev/v1alpha1 - +

Type of autoscaling policy.

-kind
-string +buffer
+ + +BufferPolicy + + +
+(Optional) +

Buffer policy config params. Present only if FleetAutoscalerPolicyType = Buffer.

GameServer
-metadata
+webhook
- -Kubernetes meta/v1.ObjectMeta + +WebhookPolicy
-Refer to the Kubernetes API documentation for the fields of the -metadata field. +(Optional) +

Webhook policy config params. Present only if FleetAutoscalerPolicyType = Webhook.

+
+

FleetAutoscalerPolicyType +(string alias)

+

+(Appears on: +FleetAutoscalerPolicy) +

+

+

FleetAutoscalerPolicyType is the policy for autoscaling +for a given Fleet

+

+

FleetAutoscalerSpec +

+

+(Appears on: +FleetAutoscaler) +

+

+

FleetAutoscalerSpec is the spec for a Fleet Scaler

+

+ + + + + + + + + + + + + +
FieldDescription
+fleetName
+ +string + +
-spec
+policy
- -GameServerSpec + +FleetAutoscalerPolicy
-
-
+

Autoscaling policy

+
+

FleetAutoscalerStatus +

+

+(Appears on: +FleetAutoscaler) +

+

+

FleetAutoscalerStatus defines the current status of a FleetAutoscaler

+

+ + + + + + + +
FieldDescription
-container
+currentReplicas
-string +int32
-

Container specifies which Pod container is the game server. Only required if there is more than one -container defined

+

CurrentReplicas is the current number of gameserver replicas +of the fleet managed by this autoscaler, as last seen by the autoscaler

-ports
+desiredReplicas
- -[]GameServerPort - +int32
-

Ports are the array of ports that can be exposed via the game server

+

DesiredReplicas is the desired number of gameserver replicas +of the fleet managed by this autoscaler, as last calculated by the autoscaler

-health
+lastScaleTime
- -Health + +Kubernetes meta/v1.Time
-

Health configures health checking

+(Optional) +

lastScaleTime is the last time the FleetAutoscaler scaled the attached fleet,

-scheduling
+ableToScale
-agones.dev/agones/pkg/apis.SchedulingStrategy +bool
-

Scheduling strategy. Defaults to “Packed”.

+

AbleToScale indicates that we can access the target fleet

-template
+scalingLimited
- -Kubernetes core/v1.PodTemplateSpec - +bool
-

Template describes the Pod that will be created for the GameServer

+

ScalingLimited indicates that the calculated scale would be above or below the range +defined by MinReplicas and MaxReplicas, and has thus been capped.

+

WebhookPolicy +

+

+(Appears on: +FleetAutoscalerPolicy) +

+

+

WebhookPolicy controls the desired behavior of the webhook policy. +It contains the description of the webhook autoscaler service +used to form url which is accessible inside the cluster

+

+ + + + + + + + + + + + + + +
FieldDescription
+url
+ +string + +
+(Optional) +

url gives the location of the webhook, in standard URL form +([scheme://]host:port/path). Exactly one of url or service +must be specified.

+

The host should not refer to a service running in the cluster; use +the service field instead. The host might be resolved via external +DNS in some apiservers (e.g., kube-apiserver cannot resolve +in-cluster DNS as that would be a layering violation). host may +also be an IP address.

+

Please note that using localhost or 127.0.0.1 as a host is +risky unless you take great care to run this webhook on all hosts +which run an apiserver which might need to make calls to this +webhook. Such installs are likely to be non-portable, i.e., not easy +to turn up in a new cluster.

+

The scheme must be “https”; the URL must begin with “https://”.

+

A path is optional, and if present may be any string permissible in +a URL. You may use the path to pass an arbitrary string to the +webhook, for example, a cluster identifier.

+

Attempting to use a user or basic auth e.g. “user:password@” is not +allowed. Fragments (“#…”) and query parameters (“?…”) are not +allowed, either.

-status
+service
- -GameServerStatus + +Kubernetes admissionregistration/v1beta1.ServiceReference
+(Optional) +

service is a reference to the service for this webhook. Either +service or url must be specified.

+

If the webhook is running within the cluster, then you should use service.

+

Port 443 will be used if it is open, otherwise it is an error.

+
+caBundle
+ +[]byte + +
+

caBundle is a PEM encoded CA bundle which will be used to validate +the webhook’s server certificate. +Required.

-

GameServerSet +
+

stable.agones.dev

+

+

Package v1alpha1 is the v1alpha1 version of the API.

+

+Resource Types: + +

Fleet

-

GameServerSet is the data structure a set of GameServers -This matches philosophically with the relationship between -Depoyments and ReplicaSets

+

Fleet is the data structure for a Fleet resource

@@ -5469,7 +5618,7 @@

GameServerSet kind
string -

+ @@ -5511,6 +5660,19 @@

GameServerSet

+ + + +
GameServerSetFleet
@@ -5489,8 +5638,8 @@

GameServerSet

spec
- -GameServerSetSpec + +FleetSpec
+strategy
+ + +Kubernetes apps/v1.DeploymentStrategy + + +
+

Deployment strategy

+
scheduling
agones.dev/agones/pkg/apis.SchedulingStrategy @@ -5530,7 +5692,7 @@

GameServerSet

-

Template the GameServer template to apply for this GameServerSet

+

Template the GameServer template to apply for this Fleet

@@ -5540,8 +5702,8 @@

GameServerSet status
- -GameServerSetStatus + +FleetStatus @@ -5550,14 +5712,11 @@

GameServerSet -

BufferPolicy +

FleetAllocation

-(Appears on: -FleetAutoscalerPolicy) -

-

-

BufferPolicy controls the desired behavior of the buffer policy.

+

FleetAllocation is the data structure for allocating against a Fleet +Deprecated: Please use GameServerAllocation instead.

@@ -5569,69 +5728,48 @@

BufferPolicy

+ + + + - - -
-maxReplicas
- -int32 - +apiVersion
+string
+ +stable.agones.dev/v1alpha1 +
-

MaxReplicas is the maximum amount of replicas that the fleet may have. -It must be bigger than both MinReplicas and BufferSize

+kind
+string
FleetAllocation
-minReplicas
+metadata
-int32 + +Kubernetes meta/v1.ObjectMeta +
-

MinReplicas is the minimum amount of replicas that the fleet must have -If zero, it is ignored. -If non zero, it must be smaller than MaxReplicas and bigger than BufferSize

+Refer to the Kubernetes API documentation for the fields of the +metadata field.
-bufferSize
+spec
-k8s.io/apimachinery/pkg/util/intstr.IntOrString + +FleetAllocationSpec +
-

BufferSize defines how many replicas the autoscaler tries to have ready all the time -Value can be an absolute number (ex: 5) or a percentage of desired gs instances (ex: 15%) -Absolute number is calculated from percentage by rounding up. -Example: when this is set to 20%, the autoscaler will make sure that 20% -of the fleet’s game server replicas are ready. When this is set to 20, -the autoscaler will make sure that there are 20 available game servers -Must be bigger than 0 -Note: by “ready” we understand in this case “non-allocated”; this is done to ensure robustness -and computation stability in different edge case (fleet just created, not enough -capacity in the cluster etc)

-
-

FleetAllocationSpec -

-

-(Appears on: -FleetAllocation) -

-

-

FleetAllocationSpec is the spec for a Fleet -Allocation

-

+
+
- - - - - - - -
FieldDescription
fleetName
@@ -5654,33 +5792,15 @@

FleetAllocationSpec

-

FleetAllocationStatus -

-

-(Appears on: -FleetAllocation) -

-

-

FleetAllocationStatus will contain the -GameServer that has been allocated from -a Fleet

-

- - - - - + - - @@ -5689,14 +5809,14 @@

FleetAllocationStatus

FieldDescription
-gameServer
+status
- -GameServer + +FleetAllocationStatus
-

FleetAutoscaleRequest +

GameServer

(Appears on: -FleetAutoscaleReview) +FleetAllocationStatus)

-

FleetAutoscaleRequest defines the request to webhook autoscaler endpoint

+

GameServer is the data structure for a gameserver resource

@@ -5708,226 +5828,247 @@

FleetAutoscaleRequest

+ + + + +
-uid
- -k8s.io/apimachinery/pkg/types.UID - +apiVersion
+string
+ +stable.agones.dev/v1alpha1 +
-

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.

+kind
+string
GameServer
-name
+metadata
-string + +Kubernetes meta/v1.ObjectMeta +
-

Name is the name of the Fleet being scaled

+Refer to the Kubernetes API documentation for the fields of the +metadata field.
-namespace
+spec
+ + +GameServerSpec + + +
+
+
+ + + - -
+container
string
-

Namespace is the namespace associated with the request (if any).

+

Container specifies which Pod container is the game server. Only required if there is more than one +container defined

-status
+ports
- -FleetStatus + +[]GameServerPort
-

The Fleet’s status values

+

Ports are the array of ports that can be exposed via the game server

-

FleetAutoscaleResponse -

-

-(Appears on: -FleetAutoscaleReview) -

-

-

FleetAutoscaleResponse defines the response of webhook autoscaler endpoint

-

- - - - + + - - + +
FieldDescription +health
+ + +Health + + +
+

Health configures health checking

+
-uid
+scheduling
-k8s.io/apimachinery/pkg/types.UID +agones.dev/agones/pkg/apis.SchedulingStrategy
-

UID is an identifier for the individual request/response. -This should be copied over from the corresponding FleetAutoscaleRequest.

+

Scheduling strategy. Defaults to “Packed”.

-scale
+template
-bool + +Kubernetes core/v1.PodTemplateSpec +
-

Set to false if no scaling should occur to the Fleet

+

Template describes the Pod that will be created for the GameServer

+
-replicas
+status
-int32 + +GameServerStatus +
-

The targeted replica count

-

FleetAutoscaleReview +

GameServerSet

-

FleetAutoscaleReview is passed to the webhook with a populated Request value, -and then returned with a populated Response.

+

GameServerSet is the data structure a set of GameServers +This matches philosophically with the relationship between +Depoyments and ReplicaSets

- - + + + + + + + + + + + + - - - - -
FieldDescriptionFieldDescription
+apiVersion
+string
+ +stable.agones.dev/v1alpha1 + +
+kind
+string +
GameServerSet
-request
+metadata
- -FleetAutoscaleRequest + +Kubernetes meta/v1.ObjectMeta
+Refer to the Kubernetes API documentation for the fields of the +metadata field.
-response
+spec
- -FleetAutoscaleResponse + +GameServerSetSpec
-
-

FleetAutoscalerPolicy -

-

-(Appears on: -FleetAutoscalerSpec) -

-

-

FleetAutoscalerPolicy describes how to scale a fleet

-

+
+
- - - + + - - + +
FieldDescription +replicas
+ +int32 + +
+

Replicas are the number of GameServers that should be in this set

+
-type
+scheduling
- -FleetAutoscalerPolicyType - +agones.dev/agones/pkg/apis.SchedulingStrategy
-

Type of autoscaling policy.

+

Scheduling strategy. Defaults to “Packed”.

-buffer
+template
- -BufferPolicy + +GameServerTemplateSpec
-(Optional) -

Buffer policy config params. Present only if FleetAutoscalerPolicyType = Buffer.

+

Template the GameServer template to apply for this GameServerSet

+
-webhook
+status
- -WebhookPolicy + +GameServerSetStatus -(Optional) -

Webhook policy config params. Present only if FleetAutoscalerPolicyType = Webhook.

-

FleetAutoscalerPolicyType -(string alias)

-

-(Appears on: -FleetAutoscalerPolicy) -

-

-

FleetAutoscalerPolicyType is the policy for autoscaling -for a given Fleet

-

-

FleetAutoscalerSpec +

FleetAllocationSpec

(Appears on: -FleetAutoscaler) +FleetAllocation)

-

FleetAutoscalerSpec is the spec for a Fleet Scaler

+

FleetAllocationSpec is the spec for a Fleet +Allocation

@@ -5949,27 +6090,28 @@

FleetAutoscalerSpec

-policy
+metadata
- -FleetAutoscalerPolicy + +MetaPatch
-

Autoscaling policy

-

FleetAutoscalerStatus +

FleetAllocationStatus

(Appears on: -FleetAutoscaler) +FleetAllocation)

-

FleetAutoscalerStatus defines the current status of a FleetAutoscaler

+

FleetAllocationStatus will contain the +GameServer that has been allocated from +a Fleet

@@ -5981,63 +6123,14 @@

FleetAutoscalerStatus

- - - - - - - - - - - - - - - - @@ -6804,88 +6897,6 @@

PortPolicy

PortPolicy is the port policy for the GameServer

-

WebhookPolicy -

-

-(Appears on: -FleetAutoscalerPolicy) -

-

-

WebhookPolicy controls the desired behavior of the webhook policy. -It contains the description of the webhook autoscaler service -used to form url which is accessible inside the cluster

-

-
-currentReplicas
- -int32 - -
-

CurrentReplicas is the current number of gameserver replicas -of the fleet managed by this autoscaler, as last seen by the autoscaler

-
-desiredReplicas
- -int32 - -
-

DesiredReplicas is the desired number of gameserver replicas -of the fleet managed by this autoscaler, as last calculated by the autoscaler

-
-lastScaleTime
+gameServer
- -Kubernetes meta/v1.Time + +GameServer
-(Optional) -

lastScaleTime is the last time the FleetAutoscaler scaled the attached fleet,

-
-ableToScale
- -bool - -
-

AbleToScale indicates that we can access the target fleet

-
-scalingLimited
- -bool - -
-

ScalingLimited indicates that the calculated scale would be above or below the range -defined by MinReplicas and MaxReplicas, and has thus been capped.

- - - - - - - - - - - - - - - - - - - - -
FieldDescription
-url
- -string - -
-(Optional) -

url gives the location of the webhook, in standard URL form -([scheme://]host:port/path). Exactly one of url or service -must be specified.

-

The host should not refer to a service running in the cluster; use -the service field instead. The host might be resolved via external -DNS in some apiservers (e.g., kube-apiserver cannot resolve -in-cluster DNS as that would be a layering violation). host may -also be an IP address.

-

Please note that using localhost or 127.0.0.1 as a host is -risky unless you take great care to run this webhook on all hosts -which run an apiserver which might need to make calls to this -webhook. Such installs are likely to be non-portable, i.e., not easy -to turn up in a new cluster.

-

The scheme must be “https”; the URL must begin with “https://”.

-

A path is optional, and if present may be any string permissible in -a URL. You may use the path to pass an arbitrary string to the -webhook, for example, a cluster identifier.

-

Attempting to use a user or basic auth e.g. “user:password@” is not -allowed. Fragments (“#…”) and query parameters (“?…”) are not -allowed, either.

-
-service
- - -Kubernetes admissionregistration/v1beta1.ServiceReference - - -
-(Optional) -

service is a reference to the service for this webhook. Either -service or url must be specified.

-

If the webhook is running within the cluster, then you should use service.

-

Port 443 will be used if it is open, otherwise it is an error.

-
-caBundle
- -[]byte - -
-

caBundle is a PEM encoded CA bundle which will be used to validate -the webhook’s server certificate. -Required.

-

Generated with gen-crd-api-reference-docs. diff --git a/site/content/en/docs/Reference/fleetautoscaler.md b/site/content/en/docs/Reference/fleetautoscaler.md index 54bffa099f..3f8f0ff789 100644 --- a/site/content/en/docs/Reference/fleetautoscaler.md +++ b/site/content/en/docs/Reference/fleetautoscaler.md @@ -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.11.0" %}} ```yaml apiVersion: "stable.agones.dev/v1alpha1" kind: FleetAutoscaler @@ -23,9 +24,27 @@ spec: minReplicas: 10 maxReplicas: 20 ``` +{{% /feature %}} +{{% feature publishversion="0.11.0" %}} +```yaml +apiVersion: "autoscaling.agones.dev/v1alpha1" +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.11.0" %}} ```yaml apiVersion: "stable.agones.dev/v1alpha1" kind: FleetAutoscaler @@ -41,10 +60,33 @@ spec: path: "/scale" caBundle: "" ``` +{{% /feature %}} + +{{% feature publishversion="0.11.0" %}} +```yaml +apiVersion: "autoscaling.agones.dev/v1alpha1" +kind: FleetAutoscaler +metadata: + name: fleet-autoscaler-example +spec: + fleetName: fleet-example + policy: + type: Webhook + webhook: + name: "fleet-autoscaler-webhook" + namespace: "default" + path: "/scale" + caBundle: "" +``` +{{% /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 `stable.agones.dev` and API +we can define a new resource using the kind `FleetAutoscaler` with the custom group +{{< feature expiryVersion="0.11.0" >}}stable.agones.dev{{< /feature >}} +{{< feature publishVersion="0.11.0" >}}autoscaling.agones.dev{{< /feature >}} +and API version `v1alpha1`. The `spec` field is the actual `FleetAutoscaler` specification and it is composed as follows: diff --git a/test/e2e/fleetautoscaler_test.go b/test/e2e/fleetautoscaler_test.go index 0dc7a10ed0..e436b18f97 100644 --- a/test/e2e/fleetautoscaler_test.go +++ b/test/e2e/fleetautoscaler_test.go @@ -20,7 +20,8 @@ import ( "testing" "time" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" + stablev1alpha1 "agones.dev/agones/pkg/apis/stable/v1alpha1" e2e "agones.dev/agones/test/e2e/framework" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" @@ -43,8 +44,8 @@ var waitForDeletion = &metav1.DeleteOptions{ func TestAutoscalerBasicFunctions(t *testing.T) { t.Parallel() - alpha1 := framework.AgonesClient.StableV1alpha1() - fleets := alpha1.Fleets(defaultNs) + stable := framework.AgonesClient.StableV1alpha1() + fleets := stable.Fleets(defaultNs) flt, err := fleets.Create(defaultFleet()) if assert.Nil(t, err) { defer fleets.Delete(flt.ObjectMeta.Name, nil) // nolint:errcheck @@ -52,7 +53,7 @@ func TestAutoscalerBasicFunctions(t *testing.T) { framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) - fleetautoscalers := alpha1.FleetAutoscalers(defaultNs) + fleetautoscalers := framework.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(defaultNs) fas, err := fleetautoscalers.Create(defaultFleetAutoscaler(flt)) if assert.Nil(t, err) { defer fleetautoscalers.Delete(fas.ObjectMeta.Name, nil) // nolint:errcheck @@ -82,10 +83,10 @@ func TestAutoscalerBasicFunctions(t *testing.T) { // do an allocation and watch the fleet scale up fa := getAllocation(flt) - fa, err = alpha1.FleetAllocations(defaultNs).Create(fa) + fa, err = stable.FleetAllocations(defaultNs).Create(fa) assert.Nil(t, err) - assert.Equal(t, v1alpha1.GameServerStateAllocated, fa.Status.GameServer.Status.State) - framework.WaitForFleetCondition(t, flt, func(fleet *v1alpha1.Fleet) bool { + assert.Equal(t, stablev1alpha1.GameServerStateAllocated, fa.Status.GameServer.Status.State) + framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool { return fleet.Status.AllocatedReplicas == 1 }) @@ -99,7 +100,7 @@ func TestAutoscalerBasicFunctions(t *testing.T) { framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(1)) // get the Status of the fleetautoscaler - fas, err = framework.AgonesClient.StableV1alpha1().FleetAutoscalers(fas.ObjectMeta.Namespace).Get(fas.Name, metav1.GetOptions{}) + fas, err = framework.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(fas.ObjectMeta.Namespace).Get(fas.Name, metav1.GetOptions{}) assert.Nil(t, err, "could not get fleetautoscaler") assert.True(t, fas.Status.AbleToScale, "Could not get AbleToScale status") @@ -119,9 +120,9 @@ func TestAutoscalerBasicFunctions(t *testing.T) { // delete the allocated GameServer and watch the fleet scale down gp := int64(1) - err = alpha1.GameServers(defaultNs).Delete(fa.Status.GameServer.ObjectMeta.Name, &metav1.DeleteOptions{GracePeriodSeconds: &gp}) + err = stable.GameServers(defaultNs).Delete(fa.Status.GameServer.ObjectMeta.Name, &metav1.DeleteOptions{GracePeriodSeconds: &gp}) assert.Nil(t, err) - framework.WaitForFleetCondition(t, flt, func(fleet *v1alpha1.Fleet) bool { + framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool { return fleet.Status.AllocatedReplicas == 0 && fleet.Status.ReadyReplicas == 1 && fleet.Status.Replicas == 1 @@ -145,7 +146,7 @@ func TestAutoscalerStressCreate(t *testing.T) { r := rand.New(rand.NewSource(1783)) - fleetautoscalers := alpha1.FleetAutoscalers(defaultNs) + fleetautoscalers := framework.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(defaultNs) for i := 0; i < 5; i++ { fas := defaultFleetAutoscaler(flt) @@ -216,13 +217,13 @@ func patchFleetAutoscaler(fas *v1alpha1.FleetAutoscaler, bufferSize intstr.IntOr WithField("patch", patch). Info("Patching fleetautoscaler") - fas, err := framework.AgonesClient.StableV1alpha1().FleetAutoscalers(defaultNs).Patch(fas.ObjectMeta.Name, types.JSONPatchType, []byte(patch)) + fas, err := framework.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(defaultNs).Patch(fas.ObjectMeta.Name, types.JSONPatchType, []byte(patch)) logrus.WithField("fleetautoscaler", fas).Info("Patched fleet autoscaler") return fas, err } // defaultFleetAutoscaler returns a default fleet autoscaler configuration for a given fleet -func defaultFleetAutoscaler(f *v1alpha1.Fleet) *v1alpha1.FleetAutoscaler { +func defaultFleetAutoscaler(f *stablev1alpha1.Fleet) *v1alpha1.FleetAutoscaler { return &v1alpha1.FleetAutoscaler{ ObjectMeta: metav1.ObjectMeta{Name: f.ObjectMeta.Name + "-autoscaler", Namespace: defaultNs}, Spec: v1alpha1.FleetAutoscalerSpec{ @@ -238,11 +239,11 @@ func defaultFleetAutoscaler(f *v1alpha1.Fleet) *v1alpha1.FleetAutoscaler { } } -func getAllocation(f *v1alpha1.Fleet) *v1alpha1.FleetAllocation { +func getAllocation(f *stablev1alpha1.Fleet) *stablev1alpha1.FleetAllocation { // get an allocation - return &v1alpha1.FleetAllocation{ + return &stablev1alpha1.FleetAllocation{ ObjectMeta: metav1.ObjectMeta{GenerateName: "allocation-", Namespace: f.ObjectMeta.Namespace}, - Spec: v1alpha1.FleetAllocationSpec{ + Spec: stablev1alpha1.FleetAllocationSpec{ FleetName: f.ObjectMeta.Name, }, } @@ -283,7 +284,7 @@ func TestAutoscalerWebhook(t *testing.T) { framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) - fleetautoscalers := alpha1.FleetAutoscalers(defaultNs) + fleetautoscalers := framework.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(defaultNs) fas := defaultFleetAutoscaler(flt) fas.Spec.Policy.Type = v1alpha1.WebhookPolicyType fas.Spec.Policy.Buffer = nil @@ -305,12 +306,12 @@ func TestAutoscalerWebhook(t *testing.T) { fa := getAllocation(flt) fa, err = alpha1.FleetAllocations(defaultNs).Create(fa) assert.Nil(t, err) - assert.Equal(t, v1alpha1.GameServerStateAllocated, fa.Status.GameServer.Status.State) - framework.WaitForFleetCondition(t, flt, func(fleet *v1alpha1.Fleet) bool { + assert.Equal(t, stablev1alpha1.GameServerStateAllocated, fa.Status.GameServer.Status.State) + framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool { return fleet.Status.AllocatedReplicas == 1 }) - framework.WaitForFleetCondition(t, flt, func(fleet *v1alpha1.Fleet) bool { + framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool { return fleet.Status.Replicas > initialReplicasCount }) @@ -494,7 +495,7 @@ func TestTlsWebhook(t *testing.T) { framework.WaitForFleetCondition(t, flt, e2e.FleetReadyCount(flt.Spec.Replicas)) - fleetautoscalers := alpha1.FleetAutoscalers(defaultNs) + fleetautoscalers := framework.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(defaultNs) fas := defaultFleetAutoscaler(flt) fas.Spec.Policy.Type = v1alpha1.WebhookPolicyType fas.Spec.Policy.Buffer = nil @@ -518,12 +519,12 @@ func TestTlsWebhook(t *testing.T) { fa := getAllocation(flt) fa, err = alpha1.FleetAllocations(defaultNs).Create(fa.DeepCopy()) assert.Nil(t, err) - assert.Equal(t, v1alpha1.GameServerStateAllocated, fa.Status.GameServer.Status.State) - framework.WaitForFleetCondition(t, flt, func(fleet *v1alpha1.Fleet) bool { + assert.Equal(t, stablev1alpha1.GameServerStateAllocated, fa.Status.GameServer.Status.State) + framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool { return fleet.Status.AllocatedReplicas == 1 }) - framework.WaitForFleetCondition(t, flt, func(fleet *v1alpha1.Fleet) bool { + framework.WaitForFleetCondition(t, flt, func(fleet *stablev1alpha1.Fleet) bool { return fleet.Status.Replicas > initialReplicasCount }) } diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index 0930748321..fc192e31b2 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -22,7 +22,8 @@ import ( "testing" "time" - "agones.dev/agones/pkg/apis/stable/v1alpha1" + autoscaling "agones.dev/agones/pkg/apis/autoscaling/v1alpha1" + stable "agones.dev/agones/pkg/apis/stable/v1alpha1" "agones.dev/agones/pkg/client/clientset/versioned" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -76,7 +77,7 @@ func New(kubeconfig string) (*Framework, error) { } // CreateGameServerAndWaitUntilReady Creates a GameServer and wait for its state to become ready. -func (f *Framework) CreateGameServerAndWaitUntilReady(ns string, gs *v1alpha1.GameServer) (*v1alpha1.GameServer, error) { +func (f *Framework) CreateGameServerAndWaitUntilReady(ns string, gs *stable.GameServer) (*stable.GameServer, error) { newGs, err := f.AgonesClient.StableV1alpha1().GameServers(ns).Create(gs) if err != nil { return nil, fmt.Errorf("creating %v GameServer instances failed (%v): %v", gs.Spec, gs.Name, err) @@ -84,7 +85,7 @@ func (f *Framework) CreateGameServerAndWaitUntilReady(ns string, gs *v1alpha1.Ga logrus.WithField("name", newGs.ObjectMeta.Name).Info("GameServer created, waiting for Ready") - readyGs, err := f.WaitForGameServerState(newGs, v1alpha1.GameServerStateReady, 5*time.Minute) + readyGs, err := f.WaitForGameServerState(newGs, stable.GameServerStateReady, 5*time.Minute) if err != nil { return nil, fmt.Errorf("waiting for %v GameServer instance readiness timed out (%v): %v", @@ -100,10 +101,10 @@ func (f *Framework) CreateGameServerAndWaitUntilReady(ns string, gs *v1alpha1.Ga } // WaitForGameServerState Waits untils the gameserver reach a given state before the timeout expires -func (f *Framework) WaitForGameServerState(gs *v1alpha1.GameServer, state v1alpha1.GameServerState, - timeout time.Duration) (*v1alpha1.GameServer, error) { +func (f *Framework) WaitForGameServerState(gs *stable.GameServer, state stable.GameServerState, + timeout time.Duration) (*stable.GameServer, error) { var pollErr error - var readyGs *v1alpha1.GameServer + var readyGs *stable.GameServer err := wait.PollImmediate(2*time.Second, timeout, func() (bool, error) { readyGs, pollErr = f.AgonesClient.StableV1alpha1().GameServers(gs.Namespace).Get(gs.Name, metav1.GetOptions{}) @@ -128,7 +129,7 @@ func (f *Framework) WaitForGameServerState(gs *v1alpha1.GameServer, state v1alph // WaitForFleetCondition waits for the Fleet to be in a specific condition or fails the test if the condition can't be met in 5 minutes. // nolint: dupl -func (f *Framework) WaitForFleetCondition(t *testing.T, flt *v1alpha1.Fleet, condition func(fleet *v1alpha1.Fleet) bool) { +func (f *Framework) WaitForFleetCondition(t *testing.T, flt *stable.Fleet, condition func(fleet *stable.Fleet) bool) { t.Helper() logrus.WithField("fleet", flt.Name).Info("waiting for fleet condition") err := wait.PollImmediate(2*time.Second, 5*time.Minute, func() (bool, error) { @@ -147,11 +148,11 @@ func (f *Framework) WaitForFleetCondition(t *testing.T, flt *v1alpha1.Fleet, con // WaitForFleetAutoScalerCondition waits for the FleetAutoscaler to be in a specific condition or fails the test if the condition can't be met in 2 minutes. // nolint: dupl -func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *v1alpha1.FleetAutoscaler, condition func(fas *v1alpha1.FleetAutoscaler) bool) { +func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *autoscaling.FleetAutoscaler, condition func(fas *autoscaling.FleetAutoscaler) bool) { t.Helper() logrus.WithField("fleetautoscaler", fas.Name).Info("waiting for fleetautoscaler condition") err := wait.PollImmediate(2*time.Second, 2*time.Minute, func() (bool, error) { - fleetautoscaler, err := f.AgonesClient.StableV1alpha1().FleetAutoscalers(fas.ObjectMeta.Namespace).Get(fas.ObjectMeta.Name, metav1.GetOptions{}) + fleetautoscaler, err := f.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(fas.ObjectMeta.Namespace).Get(fas.ObjectMeta.Name, metav1.GetOptions{}) if err != nil { return true, err } @@ -165,17 +166,17 @@ func (f *Framework) WaitForFleetAutoScalerCondition(t *testing.T, fas *v1alpha1. } // ListGameServersFromFleet lists GameServers from a particular fleet -func (f *Framework) ListGameServersFromFleet(flt *v1alpha1.Fleet) ([]v1alpha1.GameServer, error) { - var results []v1alpha1.GameServer +func (f *Framework) ListGameServersFromFleet(flt *stable.Fleet) ([]stable.GameServer, error) { + var results []stable.GameServer - opts := metav1.ListOptions{LabelSelector: labels.Set{v1alpha1.FleetNameLabel: flt.ObjectMeta.Name}.String()} + opts := metav1.ListOptions{LabelSelector: labels.Set{stable.FleetNameLabel: flt.ObjectMeta.Name}.String()} gsSetList, err := f.AgonesClient.StableV1alpha1().GameServerSets(flt.ObjectMeta.Namespace).List(opts) if err != nil { return results, err } for _, gsSet := range gsSetList.Items { - opts := metav1.ListOptions{LabelSelector: labels.Set{v1alpha1.GameServerSetGameServerLabel: gsSet.ObjectMeta.Name}.String()} + opts := metav1.ListOptions{LabelSelector: labels.Set{stable.GameServerSetGameServerLabel: gsSet.ObjectMeta.Name}.String()} gsList, err := f.AgonesClient.StableV1alpha1().GameServers(flt.ObjectMeta.Namespace).List(opts) if err != nil { return results, err @@ -188,8 +189,8 @@ func (f *Framework) ListGameServersFromFleet(flt *v1alpha1.Fleet) ([]v1alpha1.Ga } // FleetReadyCount returns the ready count in a fleet -func FleetReadyCount(amount int32) func(fleet *v1alpha1.Fleet) bool { - return func(fleet *v1alpha1.Fleet) bool { +func FleetReadyCount(amount int32) func(fleet *stable.Fleet) bool { + return func(fleet *stable.Fleet) bool { logrus.Infof("fleet %v has %v/%v ready replicas", fleet.Name, fleet.Status.ReadyReplicas, amount) return fleet.Status.ReadyReplicas == amount } @@ -197,10 +198,10 @@ func FleetReadyCount(amount int32) func(fleet *v1alpha1.Fleet) bool { // WaitForFleetGameServersCondition waits for all GameServers for a given fleet to match // a condition specified by a callback. -func (f *Framework) WaitForFleetGameServersCondition(flt *v1alpha1.Fleet, - cond func(server v1alpha1.GameServer) bool) error { +func (f *Framework) WaitForFleetGameServersCondition(flt *stable.Fleet, + cond func(server stable.GameServer) bool) error { return f.WaitForFleetGameServerListCondition(flt, - func(servers []v1alpha1.GameServer) bool { + func(servers []stable.GameServer) bool { for _, gs := range servers { if !cond(gs) { return false @@ -212,8 +213,8 @@ func (f *Framework) WaitForFleetGameServersCondition(flt *v1alpha1.Fleet, // WaitForFleetGameServerListCondition waits for the list of GameServers to match a condition // specified by a callback and the size of GameServers to match fleet's Spec.Replicas. -func (f *Framework) WaitForFleetGameServerListCondition(flt *v1alpha1.Fleet, - cond func(servers []v1alpha1.GameServer) bool) error { +func (f *Framework) WaitForFleetGameServerListCondition(flt *stable.Fleet, + cond func(servers []stable.GameServer) bool) error { return wait.Poll(2*time.Second, 5*time.Minute, func() (done bool, err error) { gsList, err := f.ListGameServersFromFleet(flt) if err != nil { @@ -239,7 +240,7 @@ func (f *Framework) NewStatsCollector(name string) *StatsCollector { func (f *Framework) CleanUp(ns string) error { logrus.Info("Cleaning up now.") defer logrus.Info("Finished cleanup.") - alpha1 := f.AgonesClient.StableV1alpha1() + stable := f.AgonesClient.StableV1alpha1() deleteOptions := &metav1.DeleteOptions{} listOptions := metav1.ListOptions{} @@ -258,28 +259,28 @@ func (f *Framework) CleanUp(ns string) error { } } - err = alpha1.Fleets(ns).DeleteCollection(deleteOptions, listOptions) + err = stable.Fleets(ns).DeleteCollection(deleteOptions, listOptions) if err != nil { return err } - err = alpha1.FleetAllocations(ns).DeleteCollection(deleteOptions, listOptions) + err = stable.FleetAllocations(ns).DeleteCollection(deleteOptions, listOptions) if err != nil { return err } - err = alpha1.FleetAutoscalers(ns).DeleteCollection(deleteOptions, listOptions) + err = f.AgonesClient.AutoscalingV1alpha1().FleetAutoscalers(ns).DeleteCollection(deleteOptions, listOptions) if err != nil { return err } - return alpha1.GameServers(ns). + return stable.GameServers(ns). DeleteCollection(deleteOptions, listOptions) } // SendGameServerUDP sends a message to a gameserver and returns its reply // assumes the first port is the port to send the message to -func SendGameServerUDP(gs *v1alpha1.GameServer, msg string) (string, error) { +func SendGameServerUDP(gs *stable.GameServer, msg string) (string, error) { address := fmt.Sprintf("%s:%d", gs.Status.Address, gs.Status.Ports[0].Port) return SendUDP(address, msg) }