Skip to content

Commit 726af15

Browse files
committed
GameServer Controller that only defined the CRD on startup
This implementation just builds the basic foundation of the controller for this Custom Resource Definition. It will check and see if the CRD has been defined, and it not, create it in the Kubernetes cluster it resides in, and wait until it reached an Established state. Then it just blocks until it gets told to terminate via a process signal.
1 parent 8f86eee commit 726af15

42 files changed

Lines changed: 2368 additions & 23 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2017 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
.*
16+
!.gitignore
17+
*.iml
18+
bin

‎Gopkg.lock‎

Lines changed: 243 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Gopkg.toml‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2017 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
[[constraint]]
16+
name = "github.com/pkg/errors"
17+
version = "0.8.0"
18+
19+
[[constraint]]
20+
name = "github.com/sirupsen/logrus"
21+
version = "1.0.3"
22+
23+
[[constraint]]
24+
name = "k8s.io/client-go"
25+
version = "5.0.1"
26+
27+
[[constraint]]
28+
name = "k8s.io/apiextensions-apiserver"
29+
branch = "release-1.8"
30+
31+
[[constraint]]
32+
name = "k8s.io/apimachinery"
33+
branch = "release-1.8"
34+
35+
[[constraint]]
36+
name = "github.com/stretchr/testify"
37+
version = "1.1.4"

‎build/Makefile‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,48 @@ VERSION = 0.1
2828
TAG = $(NAME):$(VERSION)
2929
CLUSTER_NAME = test-cluster
3030
KUBECONFIG = $(build_path)/.kube
31+
REPOSITORY = gcr.io/agon-images
3132

3233
# Directory that this Makefile is in.
3334
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
3435
build_path := $(dir $(mkfile_path))
3536
agon_path := $(realpath $(build_path)/..)
3637

37-
mount_path = /go/src/github.com/agonio/agon
38+
agon_package = github.com/agonio/agon
39+
mount_path = /go/src/$(agon_package)
3840
common_mounts = -v $(build_path)/.config/gcloud:/root/.config/gcloud \
3941
-v $(KUBECONFIG):/root/.kube \
4042
-v $(agon_path):$(mount_path)
4143

44+
gameserver_tag = $(REPOSITORY)/gameserver-controller:$(VERSION)
45+
4246
# _____ _
4347
# |_ _|_ _ _ __ __ _ ___| |_ ___
4448
# | |/ _` | '__/ _` |/ _ \ __/ __|
4549
# | | (_| | | | (_| | __/ |_\__ \
4650
# |_|\__,_|_| \__, |\___|\__|___/
4751
# |___/
4852

53+
# Run all tests
54+
test: ensure-image
55+
docker run --rm $(common_mounts) --entrypoint=go $(TAG) test -race $(agon_package)/...
56+
57+
# Build a static binary for the gameserver operator
58+
# CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
59+
build-controller-gameserver-binary: ensure-image
60+
docker run --rm -e "CGO_ENABLED=0" $(common_mounts) --entrypoint=go $(TAG) build \
61+
-o $(mount_path)/controllers/gameserver/bin/gameserver -a -installsuffix cgo $(agon_package)/controllers/gameserver
62+
63+
# Build the image for the gameserver controller
64+
build-controller-gameserver-image: ensure-image build-controller-gameserver-binary
65+
docker build $(agon_path)/controllers/gameserver --tag=$(gameserver_tag)
66+
67+
# Generate the CRD client
68+
gen-client: ensure-image
69+
docker run --rm \
70+
$(common_mounts) \
71+
--entrypoint="/root/gen-client.sh" $(TAG)
72+
4973
# Run a bash shell with the developer tools in it. (Creates the image if it doesn't exist)
5074
# Can use ARGS for extra arguments.
5175
shell: ensure-image
@@ -55,6 +79,10 @@ shell: ensure-image
5579
$(ARGS) \
5680
--entrypoint=bash $(TAG) -l
5781

82+
# run a container with godoc
83+
godoc:
84+
docker run -p 8888:8888 --rm $(common_mounts) --entrypoint=godoc $(TAG) -http=":8888" -index=true
85+
5886
.PHONY: build-image
5987

6088
# Creates the build docker image

‎build/README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,27 @@ tasks you may wish to accomplish.
88

99
## Make Targets
1010

11+
## Development Targets
12+
13+
Targets for developing with the build image
14+
15+
### `make build-gameserver-image`
16+
Compile the gameserver controller and then build the docker image
17+
18+
### `make test`
19+
Run all tests
20+
21+
### `make gen-client`
22+
Generate the Custom Resource Definition client(s)
23+
1124
### `make shell`
1225
Run a bash shell with the developer tools ad source code in it.
1326
Also creates the image if it doesn't exist
1427

28+
## Build Image Targets
29+
30+
Targets for building the build image
31+
1532
### `make clean-config`
1633
Cleans the kubernetes and gcloud configurations
1734

0 commit comments

Comments
 (0)