Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GameServerAlocation as API Extension #682

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
9 changes: 5 additions & 4 deletions build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ RUN mkdir /tmp/hugo && \
mv /tmp/hugo/hugo /usr/local/bin/ && \
rm -r /tmp/hugo

RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - && \
RUN curl -sL https://deb.nodesource.com/setup_11.x | bash - && \
apt-get install -y nodejs

# install API reference docs generator
Expand All @@ -98,14 +98,15 @@ RUN echo "export PATH=/usr/local/go/bin:/go/bin/:\$PATH" >> /root/.bashrc
# make nano the editor
RUN echo "export EDITOR=nano" >> /root/.bashrc

# update CMake
RUN wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0-Linux-x86_64.sh && mkdir /opt/cmake && \
sh ./cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/opt/cmake && export PATH=$PATH:/opt/cmake/bin

# install terraform
RUN wget -nv https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_386.zip && unzip ./terraform_0.11.13_linux_386.zip && mv terraform /usr/local/bin/

# code generation scripts
COPY *.sh /root/
RUN chmod +x /root/*.sh

RUN wget https://github.com/Kitware/CMake/releases/download/v3.14.0/cmake-3.14.0-Linux-x86_64.sh && mkdir /opt/cmake && \
sh ./cmake-3.14.0-Linux-x86_64.sh --skip-license --prefix=/opt/cmake && export PATH=$PATH:/opt/cmake/bin

WORKDIR /go
7 changes: 6 additions & 1 deletion build/build-image/gen-crd-client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -x

# not sure why the modules break things, but they do.
export GO111MODULE=off
rm -r $GOPATH/src/agones.dev/agones/pkg/client
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 stable:v1alpha1 \
agones.dev/agones/pkg/apis "allocation:v1alpha1 stable:v1alpha1" \
--go-header-file=/go/src/agones.dev/agones/build/boilerplate.go.txt
8 changes: 3 additions & 5 deletions cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ func main() {
// https server and the items that share the Mux for routing
httpsServer := https.NewServer(ctlConf.CertFile, ctlConf.KeyFile)
wh := webhooks.NewWebHook(httpsServer.Mux)
// will register openapi endpoint, which is currently not used
// but gets the code ready for usage in a later PR.
_ = apiserver.NewAPIServer(httpsServer.Mux)
api := apiserver.NewAPIServer(httpsServer.Mux)

agonesInformerFactory := externalversions.NewSharedInformerFactory(agonesClient, defaultResync)
kubeInformerFactory := informers.NewSharedInformerFactory(kubeClient, defaultResync)
Expand Down Expand Up @@ -201,8 +199,8 @@ func main() {
fleetController := fleets.NewController(wh, health, kubeClient, extClient, agonesClient, agonesInformerFactory)
faController := fleetallocation.NewController(wh, allocationMutex,
kubeClient, extClient, agonesClient, agonesInformerFactory)
gasController := gameserverallocations.NewController(wh, health, gsCounter, topNGSForAllocation,
kubeClient, extClient, agonesClient, agonesInformerFactory)
gasController := gameserverallocations.NewController(api, health, gsCounter, topNGSForAllocation,
markmandel marked this conversation as resolved.
Show resolved Hide resolved
kubeClient, agonesClient, agonesInformerFactory)
fasController := fleetautoscalers.NewController(wh, health,
kubeClient, extClient, agonesClient, agonesInformerFactory)

Expand Down
6 changes: 1 addition & 5 deletions examples/gameserverallocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
# multiple Fleets, or a self managed group of GameServers.
#

apiVersion: "stable.agones.dev/v1alpha1"
apiVersion: "allocation.agones.dev/v1alpha1"
kind: GameServerAllocation
metadata:
# We recommend using the following to generate a unique name when creating Allocations
# This will need to be created with `kubectl create` if using the command line tooling
generateName: simple-udp-
spec:
# GameServer selector from which to choose GameServers from.
# GameServers still have the hard requirement to be `Ready` to be allocated from
Expand Down
9 changes: 4 additions & 5 deletions examples/simple-udp/gameserverallocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#
# A GameServerAllocation against a Fleet named 'simple-udp'
# (GameServerAllocation is currently experimental, and likely to change in upcoming releases)
#

apiVersion: "stable.agones.dev/v1alpha1"
apiVersion: "allocation.agones.dev/v1alpha1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

general question - is allocation the only thing that will be in this API going forward? Perhaps we need a broader name to indicate "services that external consumers are going to call".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a really interesting question. Groups are pretty broad, and we could definitely expand this - and anything that is "external" would likely need to be managed by multiple pods to ensure HA (as discussed above). Which would give us an internal delineation - anything under this group needs to be managed by multiple pods, anything in the stable group, is managed by the controller (which self heals).

Maybe external.agones.dev ?

It also begets a question of is "stable" the right name for the original group. I'm starting to wonder if core.agones.dev would have been better? Or something else?

Definitely open to suggestions here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at #703 - I'm feeling like allocation is actually the right choice here for the group name.

kind: GameServerAllocation
metadata:
# We recommend using the following to generate a unique name when creating Allocations
# This will need to be created with `kubectl create` if using the command line tooling
generateName: simple-udp-
spec:
# GameServer selector from which to choose GameServers from.
# GameServers still have the hard requirement to be `Ready` to be allocated from
Expand Down
6 changes: 1 addition & 5 deletions examples/xonotic/gameserverallocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@

# (GameServerAllocation is currently experimental, and likely to change in upcoming releases)

apiVersion: "stable.agones.dev/v1alpha1"
apiVersion: "allocation.agones.dev/v1alpha1"
kind: GameServerAllocation
metadata:
# We recommend using the following to generate a unique name when creating Allocations
# This will need to be created with `kubectl create` if using the command line tooling
generateName: xonotic-
spec:
# GameServer selector from which to choose GameServers from.
# GameServers still have the hard requirement to be `Ready` to be allocated from
Expand Down
1 change: 0 additions & 1 deletion install/helm/agones/scripts/delete_agones_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ for ns in $namespaces; do
kubectl -n $ns delete gameserversets --all
kubectl -n $ns delete gameservers --all
kubectl -n $ns delete fleetallocations --all
kubectl -n $ns delete gameserverallocations --all

# Since we don't have the nifty kubectl wait yet, hack one in the meantime
for p in $pods; do
Expand Down
36 changes: 0 additions & 36 deletions install/helm/agones/templates/crds/_selector.yaml

This file was deleted.

81 changes: 0 additions & 81 deletions install/helm/agones/templates/crds/gameserverallocation.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,44 @@
{{- $altName1 := printf "agones-controller-service.%s" .Release.Namespace }}
{{- $altName2 := printf "agones-controller-service.%s.svc" .Release.Namespace }}
{{- $cert := genSignedCert $cn nil (list $altName1 $altName2) 3650 $ca }}
---
{{- if .Values.agones.registerApiService }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you don't want that?

also perhaps "registerAllocationApiService" ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GCP Marketplace usually requires a different install step, so there are switches to turn various pieces off if people need to break the glass and copy things into their own install process.

@bbf to confirm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the rename comment - we have registerWebhooks for all our webhooks - I don't think we need to be that granular. If there ever end up being more APIServices, they could also go here.

apiVersion: apiregistration.k8s.io/v1beta1
kind: APIService
metadata:
name: v1alpha1.allocation.agones.dev
labels:
component: controller
app: {{ template "agones.name" . }}
chart: {{ template "agones.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
group: allocation.agones.dev
groupPriorityMinimum: 1000
versionPriority: 15
service:
name: agones-controller-service
namespace: {{ .Release.Namespace }}
{{- if .Values.agones.controller.generateTLS }}
caBundle: {{ b64enc $ca.Cert }}
{{- else }}
caBundle: {{ .Files.Get "certs/server.crt" | b64enc }}
{{- end }}
version: v1alpha1
{{- end}}
{{- if .Values.agones.registerWebhooks }}
---
apiVersion: admissionregistration.k8s.io/v1beta1
kind: ValidatingWebhookConfiguration
metadata:
name: agones-validation-webhook
labels:
component: controller
app: {{ template "agones.name" . }}
chart: {{ template "agones.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
webhooks:
- name: validations.stable.agones.dev
failurePolicy: Fail
Expand Down Expand Up @@ -55,7 +87,6 @@ webhooks:
- "gameserversets"
- "fleetallocations"
- "fleetautoscalers"
- "gameserverallocations"
apiVersions:
- "v1alpha1"
operations:
Expand Down Expand Up @@ -91,7 +122,6 @@ webhooks:
- "gameservers"
- "fleets"
- "fleetallocations"
- "gameserverallocations"
apiVersions:
- "v1alpha1"
operations:
Expand Down
2 changes: 1 addition & 1 deletion install/helm/agones/templates/hooks/sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ metadata:
"helm.sh/hook-delete-policy": before-hook-creation
rules:
- apiGroups: ["stable.agones.dev"]
resources: ["fleets", "fleetallocations", "fleetautoscalers", "gameservers", "gameserversets", "gameserverallocations"]
resources: ["fleets", "fleetallocations", "fleetautoscalers", "gameservers", "gameserversets"]
verbs: ["delete", "list" ]
- apiGroups: [""]
resources: ["pods"]
Expand Down
33 changes: 30 additions & 3 deletions install/helm/agones/templates/serviceaccounts/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ rules:
- apiGroups: ["stable.agones.dev"]
resources: ["fleets/status"]
verbs: ["update"]
- apiGroups: ["stable.agones.dev"]
resources: ["gameserverallocations"]
verbs: ["list", "watch", "delete"]

---
apiVersion: rbac.authorization.k8s.io/v1
Expand All @@ -87,4 +84,34 @@ roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Values.agones.serviceaccount.controller }}
---
#
# RBACs for APIService
#
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Values.agones.serviceaccount.controller }}:system:auth-delegator
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:auth-delegator
subjects:
- kind: ServiceAccount
name: apiserver
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Values.agones.serviceaccount.controller }}-auth-reader
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
name: apiserver
namespace: {{ .Release.Namespace }}
{{- end }}
1 change: 1 addition & 0 deletions install/helm/agones/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ agones:
rbacEnabled: true
registerServiceAccounts: true
registerWebhooks: true
registerApiService: true
crds:
install: true
cleanupOnDelete: true
Expand Down
Loading