<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Agones – Tutorials</title>
    <link>/site/docs/tutorials/</link>
    <description>Recent content in Tutorials on Agones</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Thu, 03 Jan 2019 03:15:21 +0000</lastBuildDate>
    
	  <atom:link href="/site/docs/tutorials/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Docs: Tutorial Build and Run a Simple Gameserver (Rust)</title>
      <link>/site/docs/tutorials/simple-gameserver-rust/</link>
      <pubDate>Tue, 30 Jul 2019 07:47:45 +0000</pubDate>
      
      <guid>/site/docs/tutorials/simple-gameserver-rust/</guid>
      <description>
        
        
        

&lt;h2 id=&#34;objectives&#34;&gt;Objectives&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run a simple gameserver&lt;/li&gt;
&lt;li&gt;Understand how the simple gameserver uses the Agones Rust SDK&lt;/li&gt;
&lt;li&gt;Build a customized version of the simple gameserver&lt;/li&gt;
&lt;li&gt;Run your customized simple gameserver&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/get-started/&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Agones installed on GKE&lt;/li&gt;
&lt;li&gt;kubectl properly configured&lt;/li&gt;
&lt;li&gt;A local copy of the &lt;a href=&#34;https://github.com/googleforgames/agones/tree/master&#34;&gt;Agones repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A repository for Docker images, such as &lt;a href=&#34;https://hub.docker.com/&#34;&gt;Docker Hub&lt;/a&gt; or &lt;a href=&#34;https://cloud.google.com/container-registry/&#34;&gt;GC Container Registry&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To install on GKE, follow the install instructions (if you haven&amp;rsquo;t already) at
&lt;a href=&#34;/site/site/docs/installation/creating-cluster/gke/&#34;&gt;Setting up a Google Kubernetes Engine (GKE) cluster&lt;/a&gt;.
Also complete the &amp;ldquo;Installing Agones&amp;rdquo; instructions on the same page.&lt;/p&gt;

&lt;p&gt;While not required, you may wish to review the &lt;a href=&#34;/site/site/docs/getting-started/create-gameserver/&#34;&gt;Create a Game Server&lt;/a&gt;,
&lt;a href=&#34;/site/site/docs/getting-started/create-fleet/&#34;&gt;Create a Game Server Fleet&lt;/a&gt;, and/or &lt;a href=&#34;/site/site/docs/getting-started/edit-first-gameserver-go/&#34;&gt;Edit a Game Server&lt;/a&gt; quickstarts.&lt;/p&gt;

&lt;h3 id=&#34;1-run-the-simple-gameserver&#34;&gt;1. Run the simple gameserver&lt;/h3&gt;

&lt;p&gt;First, run the pre-built version of the simple gameserver and take note of the name that was created:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/master/examples/rust-simple/gameserver.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get gs -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The game server sets up the Agones SDK, calls &lt;code&gt;sdk.ready()&lt;/code&gt; to inform Agones that it is ready to serve traffic,
prints a message every 10 seconds, and then calls &lt;code&gt;sdk.shutdown()&lt;/code&gt; after a minute to indicate that the gameserver
is going to exit.&lt;/p&gt;

&lt;p&gt;You can follow along with the lifecycle of the gameserver by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl logs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt; rust-simple -f&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should produce output similar to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Rust Game Server has started!
Creating SDK instance
Setting a label
Starting to watch GameServer updates...
Health ping sent
Setting an annotation
Marking server as ready...
...marked Ready
Getting GameServer details...
GameServer name: rust-simple-txsc6
Running for 0 seconds
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: Scheduled
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: Scheduled
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: RequestReady
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: Ready
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 10 seconds
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: Ready
...
Shutting down after 60 seconds...
...marked for Shutdown
Running for 60 seconds
Health ping sent
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: Shutdown
GameServer Update, name: rust-simple-txsc6
GameServer Update, state: Shutdown
...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If everything goes as expected, the gameserver will exit automatically after about a minute.&lt;/p&gt;

&lt;p&gt;In some cases, the gameserver goes into an unhealthy state, in which case it will be restarted indefinitely.
If this happens, you can manually remove it by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete gs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;2-build-a-simple-gameserver&#34;&gt;2. Build a simple gameserver&lt;/h3&gt;

&lt;p&gt;Change directories to your local agones/examples/rust-simple directory. To experiment with the SDK, open up &lt;code&gt;main.rs&lt;/code&gt;
in your favorite editor and change the interval at which the gameserver calls &lt;code&gt;sdk.health()&lt;/code&gt; from 2 seconds to 20
seconds by modifying the line in the thread assigned to &lt;code&gt;let _health&lt;/code&gt; to be&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#000&#34;&gt;thread&lt;/span&gt;::&lt;span style=&#34;color:#000&#34;&gt;sleep&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;Duration&lt;/span&gt;::&lt;span style=&#34;color:#000&#34;&gt;from_secs&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#0000cf;font-weight:bold&#34;&gt;20&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;));&lt;/span&gt;&lt;span style=&#34;color:#f8f8f8;text-decoration:underline&#34;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next build a new docker image by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ &lt;span style=&#34;color:#204a87&#34;&gt;cd&lt;/span&gt; examples/rust-simple
$ &lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&amp;lt;your-repository&amp;gt; &lt;span style=&#34;color:#8f5902;font-style:italic&#34;&gt;# e.g. gcr.io/agones-images&lt;/span&gt;
$ make build-image &lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The multi-stage Dockerfile will pull down all of the dependencies needed to build the image. Note that it is normal
for this to take several minutes to complete.&lt;/p&gt;

&lt;p&gt;Once the container has been built, push it to your repository&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ docker push &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;/rust-simple-server:0.4&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;3-run-the-customized-gameserver&#34;&gt;3. Run the customized gameserver&lt;/h3&gt;

&lt;p&gt;Now it is time to deploy your newly created gameserver container into your Agones cluster.&lt;/p&gt;

&lt;p&gt;First, you need to edit &lt;code&gt;examples/rust-simple/gameserver.yaml&lt;/code&gt; to point to your new image:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;containers:
- name: rust-simple
  image: $(REPOSITORY)/rust-simple-server:0.4
  imagePullPolicy: Always
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, deploy your gameserver&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f gameserver.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get gs -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again, follow along with the lifecycle of the gameserver by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl logs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt; rust-simple -f&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should produce output similar to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Rust Game Server has started!
Creating SDK instance
Setting a label
Starting to watch GameServer updates...
Health ping sent
Setting an annotation
Marking server as ready...
...marked Ready
Getting GameServer details...
GameServer name: rust-simple-z6lz8
Running for 0 seconds
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: Scheduled
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: RequestReady
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: RequestReady
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: Ready
Running for 10 seconds
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: Ready
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: Unhealthy
Health ping sent
Running for 20 seconds
Running for 30 seconds
Health ping sent
Running for 40 seconds
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: Unhealthy
Running for 50 seconds
Health ping sent
Shutting down after 60 seconds...
...marked for Shutdown
Running for 60 seconds
Running for 70 seconds
GameServer Update, name: rust-simple-z6lz8
GameServer Update, state: Unhealthy
Health ping sent
Running for 80 seconds
Running for 90 seconds
Health ping sent
Rust Game Server finished.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;with the slower healthcheck interval, the gameserver gets automatically marked an &lt;code&gt;Unhealthy&lt;/code&gt; by Agones.&lt;/p&gt;

&lt;p&gt;To finish, clean up the gameserver by manually removing it&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete gs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
      </description>
    </item>
    
    <item>
      <title>Docs: Tutorial Build and Run a Simple Gameserver (node.js)</title>
      <link>/site/docs/tutorials/simple-gameserver-nodejs/</link>
      <pubDate>Thu, 25 Jul 2019 17:34:37 +0000</pubDate>
      
      <guid>/site/docs/tutorials/simple-gameserver-nodejs/</guid>
      <description>
        
        
        

&lt;h2 id=&#34;objectives&#34;&gt;Objectives&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run a simple gameserver&lt;/li&gt;
&lt;li&gt;Understand how the simple gameserver uses the Agones node.js SDK&lt;/li&gt;
&lt;li&gt;Build a customized version of the simple gameserver&lt;/li&gt;
&lt;li&gt;Run your customized simple gameserver&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/get-started/&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Agones installed on GKE&lt;/li&gt;
&lt;li&gt;kubectl properly configured&lt;/li&gt;
&lt;li&gt;A local copy of the &lt;a href=&#34;https://github.com/googleforgames/agones/tree/master&#34;&gt;Agones repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A repository for Docker images, such as &lt;a href=&#34;https://hub.docker.com/&#34;&gt;Docker Hub&lt;/a&gt; or &lt;a href=&#34;https://cloud.google.com/container-registry/&#34;&gt;GC Container Registry&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To install on GKE, follow the install instructions (if you haven&amp;rsquo;t already) at
&lt;a href=&#34;/site/site/docs/installation/creating-cluster/gke/&#34;&gt;Setting up a Google Kubernetes Engine (GKE) cluster&lt;/a&gt;.
Also complete the &amp;ldquo;Installing Agones&amp;rdquo; instructions on the same page.&lt;/p&gt;

&lt;p&gt;While not required, you may wish to review the &lt;a href=&#34;/site/site/docs/getting-started/create-gameserver/&#34;&gt;Create a Game Server&lt;/a&gt;,
&lt;a href=&#34;/site/site/docs/getting-started/create-fleet/&#34;&gt;Create a Game Server Fleet&lt;/a&gt;, and/or &lt;a href=&#34;/site/site/docs/getting-started/edit-first-gameserver-go/&#34;&gt;Edit a Game Server&lt;/a&gt; quickstarts.&lt;/p&gt;

&lt;h3 id=&#34;1-run-the-simple-gameserver&#34;&gt;1. Run the simple gameserver&lt;/h3&gt;

&lt;p&gt;First, run the pre-built version of the simple gameserver and take note of the name that was created:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/master/examples/nodejs-simple/gameserver.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get gs -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The game server sets up the Agones SDK, calls &lt;code&gt;sdk.ready()&lt;/code&gt; to inform Agones that it is ready to serve traffic,
prints a message every 10 seconds, and then calls &lt;code&gt;sdk.shutdown()&lt;/code&gt; after a minute to indicate that the gameserver
is going to exit.&lt;/p&gt;

&lt;p&gt;You can follow along with the lifecycle of the gameserver by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl logs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt; nodejs-simple -f&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should produce output similar to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; @ start /home/server/examples/nodejs-simple
&amp;gt; node src/index.js

node.js Game Server has started!
Setting a label
(node:20) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Setting an annotation
Marking server as ready...
...marked Ready
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: Scheduled
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: RequestReady
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: RequestReady
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: Ready
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 10 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 20 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: Ready
Running for 30 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 40 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 50 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: Ready
Running for 60 seconds!
Shutting down after 60 seconds...
...marked for Shutdown
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: Shutdown
Health ping sent
GameServer Update:
	name: nodejs-simple-9bw4g 
	state: Shutdown
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 70 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 80 seconds!
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 90 seconds!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If everything goes as expected, the gameserver will exit automatically after about a minute.&lt;/p&gt;

&lt;p&gt;In some cases, the gameserver goes into an unhealthy state, in which case it will be restarted indefinitely.
If this happens, you can manually remove it by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete gs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;2-build-a-simple-gameserver&#34;&gt;2. Build a simple gameserver&lt;/h3&gt;

&lt;p&gt;Change directories to your local agones/examples/nodejs-simple directory. To experiment with the SDK, open up
&lt;code&gt;src/index.js&lt;/code&gt; in your favorite editor and change the interval at which the gameserver calls &lt;code&gt;sdk.health()&lt;/code&gt; from
2 seconds to 20 seconds by modifying the lines in the health ping handler to be&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;setInterval(() =&amp;gt; {
	agonesSDK.health();
	console.log(&#39;Health ping sent&#39;);
}, 20000);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next build a new docker image by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ &lt;span style=&#34;color:#204a87&#34;&gt;cd&lt;/span&gt; examples/nodejs-simple
$ &lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&amp;lt;your-repository&amp;gt; &lt;span style=&#34;color:#8f5902;font-style:italic&#34;&gt;# e.g. gcr.io/agones-images&lt;/span&gt;
$ make build &lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once the container has been built, push it to your repository&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ docker push &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;/nodejs-simple-server:0.1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;3-run-the-customized-gameserver&#34;&gt;3. Run the customized gameserver&lt;/h3&gt;

&lt;p&gt;Now it is time to deploy your newly created gameserver container into your Agones cluster.&lt;/p&gt;

&lt;p&gt;First, you need to edit &lt;code&gt;examples/nodejs-simple/gameserver.yaml&lt;/code&gt; to point to your new image:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;containers:
- name: nodejs-simple
  image: $(REPOSITORY)/nodejs-simple-server:0.1
  imagePullPolicy: Always
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, deploy your gameserver&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f gameserver.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get gs -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again, follow along with the lifecycle of the gameserver by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl logs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt; nodejs-simple -f&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should produce output similar to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; @ start /home/server/examples/nodejs-simple
&amp;gt; node src/index.js

node.js Game Server has started!
Setting a label
(node:20) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Setting an annotation
Marking server as ready...
...marked Ready
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Scheduled
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Scheduled
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: RequestReady
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Ready
Running for 10 seconds!
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Unhealthy
Health ping sent
Running for 20 seconds!
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Unhealthy
Running for 30 seconds!
Health ping sent
Running for 40 seconds!
Running for 50 seconds!
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Unhealthy
Health ping sent
Shutting down after 60 seconds...
...marked for Shutdown
Running for 60 seconds!
Running for 70 seconds!
Health ping sent
Running for 80 seconds!
GameServer Update:
	name: nodejs-simple-qkpqn 
	state: Unhealthy
Running for 90 seconds!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;with the slower healthcheck interval, the gameserver gets automatically marked an &lt;code&gt;Unhealthy&lt;/code&gt; by Agones.&lt;/p&gt;

&lt;p&gt;To finish, clean up the gameserver by manually removing it&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete gs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
      </description>
    </item>
    
    <item>
      <title>Docs: Tutorial Build and Run a Simple Gameserver (C&#43;&#43;)</title>
      <link>/site/docs/tutorials/simple-gameserver-cpp/</link>
      <pubDate>Wed, 24 Jul 2019 05:52:12 +0000</pubDate>
      
      <guid>/site/docs/tutorials/simple-gameserver-cpp/</guid>
      <description>
        
        
        

&lt;h2 id=&#34;objectives&#34;&gt;Objectives&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Run a simple gameserver&lt;/li&gt;
&lt;li&gt;Understand how the simple gameserver uses the Agones C++ SDK&lt;/li&gt;
&lt;li&gt;Build a customized version of the simple gameserver&lt;/li&gt;
&lt;li&gt;Run your customized simple gameserver&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/get-started/&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Agones installed on GKE&lt;/li&gt;
&lt;li&gt;kubectl properly configured&lt;/li&gt;
&lt;li&gt;A local copy of the &lt;a href=&#34;https://github.com/googleforgames/agones/tree/master&#34;&gt;Agones repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A repository for Docker images, such as &lt;a href=&#34;https://hub.docker.com/&#34;&gt;Docker Hub&lt;/a&gt; or &lt;a href=&#34;https://cloud.google.com/container-registry/&#34;&gt;GC Container Registry&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To install on GKE, follow the install instructions (if you haven&amp;rsquo;t already) at
&lt;a href=&#34;/site/site/docs/installation/creating-cluster/gke/&#34;&gt;Setting up a Google Kubernetes Engine (GKE) cluster&lt;/a&gt;.
Also complete the &amp;ldquo;Installing Agones&amp;rdquo; instructions on the same page.&lt;/p&gt;

&lt;p&gt;While not required, you may wish to review the &lt;a href=&#34;/site/site/docs/getting-started/create-gameserver/&#34;&gt;Create a Game Server&lt;/a&gt;,
&lt;a href=&#34;/site/site/docs/getting-started/create-fleet/&#34;&gt;Create a Game Server Fleet&lt;/a&gt;, and/or &lt;a href=&#34;/site/site/docs/getting-started/edit-first-gameserver-go/&#34;&gt;Edit a Game Server&lt;/a&gt; quickstarts.&lt;/p&gt;

&lt;h3 id=&#34;1-run-the-simple-gameserver&#34;&gt;1. Run the simple gameserver&lt;/h3&gt;

&lt;p&gt;First, run the pre-built version of the simple gameserver and take note of the name that was created:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/master/examples/cpp-simple/gameserver.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get gs -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The game server sets up the Agones SDK, calls &lt;code&gt;SDK::Ready()&lt;/code&gt; to inform Agones that it is ready to serve traffic,
prints a message every 10 seconds, and then calls &lt;code&gt;SDK::Shutdown()&lt;/code&gt; after a minute to indicate that the gameserver
is going to exit.&lt;/p&gt;

&lt;p&gt;You can follow along with the lifecycle of the gameserver by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl logs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt; cpp-simple -f&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should produce output similar to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;C++ Game Server has started!
Getting the instance of the SDK!
Attempting to connect...
...handshake complete.
Setting a label
Starting to watch GameServer updates...
Health ping sent
Setting an annotation
Marking server as ready...
...marked Ready
Getting GameServer details...
GameServer name: cpp-simple-tlgzp
Running for 0 seconds !
GameServer Update:
	name: cpp-simple-tlgzp
	state: Scheduled
GameServer Update:
	name: cpp-simple-tlgzp
	state: RequestReady
GameServer Update:
	name: cpp-simple-tlgzp
	state: RequestReady
GameServer Update:
	name: cpp-simple-tlgzp
	state: Ready
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Health ping sent
Running for 10 seconds !
Health ping sent
...
GameServer Update:
	name: cpp-simple-2mtdc
	state: Ready
Shutting down after 60 seconds...
...marked for Shutdown
Running for 60 seconds !
Health ping sent
GameServer Update:
	name: cpp-simple-2mtdc
	state: Shutdown
GameServer Update:
	name: cpp-simple-2mtdc
	state: Shutdown
Health ping failed
Health ping failed
Health ping failed
Health ping failed
Running for 70 seconds !
Health ping failed
Health ping failed
Health ping failed
Health ping failed
Health ping failed
Running for 80 seconds !
Health ping failed
Health ping failed
Health ping failed
Health ping failed
Health ping failed
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If everything goes as expected, the gameserver will exit automatically after about a minute.&lt;/p&gt;

&lt;p&gt;In some cases, the gameserver goes into an unhealthy state, in which case it will be restarted indefinitely.
If this happens, you can manually remove it by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete gs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;2-run-a-fleet-of-simple-gameservers&#34;&gt;2. Run a fleet of simple gameservers&lt;/h3&gt;

&lt;p&gt;Next, run a fleet of gameservers&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f https://raw.githubusercontent.com/googleforgames/agones/master/examples/cpp-simple/fleet.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;FLEET_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get fleets -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can again inspect the output of an individual gameserver (which will look the same as above), but what is more
interesting is to watch the set of all gameservers over time. Each gameserver exits after about a minute, but a fleet
is responsible for keeping a sufficient number of gameservers in the &lt;code&gt;Ready&lt;/code&gt; state. So as each gameserver exits, it
is replaced by a new one. You can see this in action by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ watch &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#34;kubectl get gameservers&amp;#34;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should show how gameservers are constantly transitioning from &lt;code&gt;Scheduled&lt;/code&gt; to &lt;code&gt;Ready&lt;/code&gt; to &lt;code&gt;Shutdown&lt;/code&gt; before
disappearing.&lt;/p&gt;

&lt;p&gt;When you are finished watching the fleet produce new gameservers you should remove the fleet by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete fleet &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;FLEET_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;3-build-a-simple-gameserver&#34;&gt;3. Build a simple gameserver&lt;/h3&gt;

&lt;p&gt;Change directories to your local agones/examples/cpp-simple directory. To experiment with the SDK, open up &lt;code&gt;server.cc&lt;/code&gt;
in your favorite editor and change the interval at which the gameserver calls &lt;code&gt;SDK::Health&lt;/code&gt; from 2 seconds to 20
seconds by modifying the line in &lt;code&gt;DoHealth&lt;/code&gt; to be&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-c++&#34; data-lang=&#34;c++&#34;&gt;&lt;span style=&#34;color:#000&#34;&gt;std&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;this_thread&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;sleep_for&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;std&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;chrono&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;::&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;seconds&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#0000cf;font-weight:bold&#34;&gt;20&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next build a new docker image by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ &lt;span style=&#34;color:#204a87&#34;&gt;cd&lt;/span&gt; examples/cpp-simple
$ &lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&amp;lt;your-repository&amp;gt; &lt;span style=&#34;color:#8f5902;font-style:italic&#34;&gt;# e.g. gcr.io/agones-images&lt;/span&gt;
$ make build &lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The multi-stage Dockerfile will pull down all of the dependencies needed to build the image. Note that it is normal
for this to take several minutes to complete.&lt;/p&gt;

&lt;p&gt;Once the container has been built, push it to your repository&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ docker push &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;REPOSITORY&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;/cpp-simple-server:0.6&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&#34;4-run-the-customized-gameserver&#34;&gt;4. Run the customized gameserver&lt;/h3&gt;

&lt;p&gt;Now it is time to deploy your newly created gameserver container into your Agones cluster.&lt;/p&gt;

&lt;p&gt;First, you need to edit &lt;code&gt;examples/cpp-simple/gameserver.yaml&lt;/code&gt; to point to your new image:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;containers:
- name: cpp-simple
  image: $(REPOSITORY)/cpp-simple-server:0.6
  imagePullPolicy: Always # add for development
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, deploy your gameserver&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl create -f gameserver.yaml
$ &lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;$(&lt;/span&gt;kubectl get gs -o go-template --template &lt;span style=&#34;color:#4e9a06&#34;&gt;&amp;#39;{{range .items}}{{.metadata.name}}{{&amp;#34;\n&amp;#34;}}{{end}}&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again, follow along with the lifecycle of the gameserver by running&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl logs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt; cpp-simple -f&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;which should produce output similar to&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;C++ Game Server has started!
Getting the instance of the SDK!
Attempting to connect...
...handshake complete.
Setting a label
Health ping sent
Starting to watch GameServer updates...
Setting an annotation
Marking server as ready...
...marked Ready
Getting GameServer details...
GameServer name: cpp-simple-f255n
Running for 0 seconds !
GameServer Update:
	name: cpp-simple-f255n
	state: Scheduled
GameServer Update:
	name: cpp-simple-f255n
	state: Scheduled
GameServer Update:
	name: cpp-simple-f255n
	state: RequestReady
GameServer Update:
	name: cpp-simple-f255n
	state: Ready
Running for 10 seconds !
GameServer Update:
	name: cpp-simple-f255n
	state: Unhealthy
Health ping sent
Running for 20 seconds !
GameServer Update:
	name: cpp-simple-f255n
	state: Unhealthy
Running for 30 seconds !
Health ping sent
Running for 40 seconds !
Running for 50 seconds !
GameServer Update:
	name: cpp-simple-f255n
	state: Unhealthy
Health ping sent
Shutting down after 60 seconds...
...marked for Shutdown
Running for 60 seconds !
Running for 70 seconds !
Health ping sent
Running for 80 seconds !
GameServer Update:
	name: cpp-simple-f255n
	state: Unhealthy
Running for 90 seconds !
Health ping sent
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;with the slower healthcheck interval, the gameserver gets automatically marked an &lt;code&gt;Unhealthy&lt;/code&gt; by Agones.&lt;/p&gt;

&lt;p&gt;To finish, clean up the gameserver by manually removing it&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;$ kubectl delete gs &lt;span style=&#34;color:#4e9a06&#34;&gt;${&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;GAMESERVER_NAME&lt;/span&gt;&lt;span style=&#34;color:#4e9a06&#34;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
      </description>
    </item>
    
    <item>
      <title>Docs: Tutorial Create an Allocator Service</title>
      <link>/site/docs/tutorials/allocator-service-go/</link>
      <pubDate>Thu, 03 Jan 2019 03:15:34 +0000</pubDate>
      
      <guid>/site/docs/tutorials/allocator-service-go/</guid>
      <description>
        
        
        

&lt;p&gt;To do this, we will implement a &lt;a href=&#34;https://kubernetes.io/docs/concepts/services-networking/service/&#34;&gt;Service&lt;/a&gt; which allocates a
Game Server on demand by calling the Create() method of the GameServerAllocationInterface.  After creating the fleet
allocation, we will return the JSON encoded GameServerStatus of the allocated GameServer.&lt;/p&gt;

&lt;p&gt;The type of service we will be learning about could be used by a game client to connect directly to a dedicated Game Server, as part of a larger system, such as a matchmaker service, or in conjunction with a database of level transition data.  We will be using the service as a vehicle with which to execute the API calls found in our main.go file.&lt;/p&gt;

&lt;h2 id=&#34;objectives&#34;&gt;Objectives&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create a secure allocator service&lt;/li&gt;
&lt;li&gt;Deploy the service to &lt;a href=&#34;https://cloud.google.com/kubernetes-engine/&#34;&gt;GKE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Allocate a Game Server from a Fleet using the Agones API&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&#34;https://www.docker.com/get-started/&#34;&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Agones installed on GKE, running a simple-udp fleet&lt;/li&gt;
&lt;li&gt;kubectl properly configured&lt;/li&gt;
&lt;li&gt;A local copy of the 
&lt;a href=&#34;https://github.com/googleforgames/agones/blob/master/examples/allocator-service&#34; target=&#34;_blank&#34; data-proofer-ignore&gt;allocator service&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;A repository for Docker images, such as &lt;a href=&#34;https://hub.docker.com/&#34;&gt;Docker Hub&lt;/a&gt; or &lt;a href=&#34;https://cloud.google.com/container-registry/&#34;&gt;GC Container Registry&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To install on GKE, follow the install instructions (if you haven&amp;rsquo;t already) at
&lt;a href=&#34;/site/site/docs/installation/creating-cluster/gke/&#34;&gt;Setting up a Google Kubernetes Engine (GKE) cluster&lt;/a&gt;.
Also complete the &amp;ldquo;Installing Agones&amp;rdquo; instructions on the same page.&lt;/p&gt;

&lt;p&gt;While not required, you may wish to review the &lt;a href=&#34;/site/site/docs/getting-started/create-gameserver/&#34;&gt;Create a Game Server&lt;/a&gt;,
&lt;a href=&#34;/site/site/docs/getting-started/create-fleet/&#34;&gt;Create a Game Server Fleet&lt;/a&gt;, and/or &lt;a href=&#34;/site/site/docs/getting-started/edit-first-gameserver-go/&#34;&gt;Edit a Game Server&lt;/a&gt; quickstarts.&lt;/p&gt;

&lt;h3 id=&#34;1-build-and-push-the-service&#34;&gt;1. Build and Push the Service&lt;/h3&gt;

&lt;p&gt;Change directories to your local agones/examples/allocator-service directory and build a new docker image.  The multi-stage Dockerfile will pull down all the dependencies for you and build the executable.  For example, where USER is your username, REPO is your repository, and TAG is your tag:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;docker build -t [USER]/allocator-service:[TAG] .
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Push it to your repository:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;docker push [USER]/allocator-service:[TAG]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Edit allocator-service.yaml to point to your new image:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;containers:
- name: fleet-allocator
  image: [REPO]/[USER]/allocator-service:[TAG]
  imagePullPolicy: Always
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;2-create-firewall-rules&#34;&gt;2. Create Firewall Rules&lt;/h3&gt;

&lt;p&gt;Let&amp;rsquo;s making some firewall rules that will be used by kubernetes health checks and the ingress which we will create shortly.&lt;/p&gt;

&lt;p&gt;First, we will make one for the HTTPS health checks that will be sent to our service by running:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gcloud compute firewall-rules create fleet-allocator-healthcheck \
  --allow tcp \
  --source-ranges 130.211.0.0/22,35.191.0.0/16 \
  --target-tags fleet-allocator \
  --description &amp;quot;Firewall to allow health check of fleet allocator service&amp;quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Creating firewall...done.                                            
NAME                         NETWORK  DIRECTION  PRIORITY  ALLOW  DENY  DISABLED
fleet-allocator-healthcheck  default  INGRESS    1000      tcp          False
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a firewall rule for nodePort traffic on the range of ports used by Ingress services of type nodePort.  We are using nodePort because it supports TLS.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gcloud compute firewall-rules create nodeport-rule \
  --allow=tcp:30000-32767 \
  --target-tags fleet-allocator \
  --description &amp;quot;Firewall to allow nodePort traffic of fleet allocator service&amp;quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Creating firewall...done.                                            
NAME           NETWORK  DIRECTION  PRIORITY  ALLOW            DENY  DISABLED
nodeport-rule  default  INGRESS    1000      tcp:30000-32767        False
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;3-make-it-secure&#34;&gt;3. Make It Secure&lt;/h3&gt;

&lt;p&gt;Let&amp;rsquo;s keep security in mind from the beginning by creating a certificate, key and secret for the allocator service, and another set for the web server.&lt;/p&gt;

&lt;p&gt;Pick a more permanent location for the files if you like - /tmp may be purged depending on your operating system.&lt;/p&gt;

&lt;p&gt;Create a public private key pair for the allocator service:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/allocsvc.key -out  /tmp/allocsvc.crt -subj &amp;quot;/CN=my-allocator/O=my-allocator&amp;quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Generating a 2048 bit RSA private key
....................................................+++
......................+++
writing new private key to &#39;/tmp/allocsvc.key&#39;
-----
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a public private key pair that will be bound to the pod and used by the web server :&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /tmp/tls.key -out  /tmp/tls.crt -subj &amp;quot;/CN=my-allocator-w3/O=my-allocator-w3&amp;quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Generating a 2048 bit RSA private key
....................................................+++
......................+++
writing new private key to &#39;/tmp/tls.key&#39;
-----
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;4-create-kubernetes-secrets&#34;&gt;4. Create Kubernetes Secrets&lt;/h3&gt;

&lt;p&gt;The allocatorsecret will allow the service to use TLS for connections with workers.&lt;/p&gt;

&lt;p&gt;Create the &lt;a href=&#34;https://kubernetes.io/docs/concepts/configuration/secret/&#34;&gt;secret&lt;/a&gt; by running this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl create secret tls allocatorsecret --cert=/tmp/allocsvc.crt --key=/tmp/allocsvc.key
&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code&gt;secret/allocatorsecret created
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The allocatorw3secret will let data be served by the webserver over https.&lt;/p&gt;

&lt;p&gt;Create the secret by running this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl create secret tls allocatorw3secret --cert=/tmp/tls.crt --key=/tmp/tls.key
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should be something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;secret/allocatorw3secret created
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;See that the secrets exist by running:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl get secrets
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should contain the secrets:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;NAME                     TYPE                                  DATA      AGE
...
allocatorsecret          kubernetes.io/tls                     2         29s
allocatorw3secret        kubernetes.io/tls                     2         15s
...
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;5-create-the-service-account&#34;&gt;5. Create the Service Account&lt;/h3&gt;

&lt;p&gt;This service will interact with Agones via the Agones API by using a &lt;a href=&#34;https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/&#34;&gt;service account&lt;/a&gt; named fleet-allocator.  Specifically, the fleet-allocator service account is granted permissions to perform create operations against GameServerAllocation objects, and get operations against Fleet objects.&lt;/p&gt;

&lt;p&gt;Create the service account by changing directories to your local agones/examples/allocator-service directory and running this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl create -f service-account.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;role.rbac.authorization.k8s.io/fleet-allocator created
serviceaccount/fleet-allocator created
rolebinding.rbac.authorization.k8s.io/fleet-allocator created
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;6-define-and-deploy-the-service&#34;&gt;6. Define and Deploy the Service&lt;/h3&gt;

&lt;p&gt;The service definition defines a &lt;a href=&#34;https://kubernetes.io/docs/concepts/services-networking/service/#nodeport&#34;&gt;nodePort&lt;/a&gt; service which uses https, and sets up ports and names.  The deployment describes the number of replicas we would like, which account to use, which image to use, and defines a health check.&lt;/p&gt;

&lt;p&gt;Define and Deploy the service by running this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl create -f allocator-service.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;service/fleet-allocator-backend created
deployment.apps/fleet-allocator created
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;7-deploy-the-ingress-resource&#34;&gt;7. Deploy the Ingress Resource&lt;/h3&gt;

&lt;p&gt;This &lt;a href=&#34;https://kubernetes.io/docs/concepts/services-networking/ingress/&#34;&gt;Ingress&lt;/a&gt; directs traffic to the allocator service using an ephemeral IP address.  The allocator service pod needs to exist and the readiness probe should be passing health checks before the ingress is created.&lt;/p&gt;

&lt;p&gt;Deploy the Ingress with this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl apply -f allocator-ingress.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ingress.extensions/fleet-allocator-ingress created
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;8-retrieve-the-ephemeral-public-ip-address&#34;&gt;8. Retrieve the Ephemeral Public IP Address&lt;/h3&gt;

&lt;p&gt;After deployment, it will take about a minute for the IP address to be present, and up to 10 minutes before it can start returning data.&lt;/p&gt;

&lt;p&gt;Run this command to get the IP address:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl get ingress fleet-allocator-ingress
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should look something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;NAME                      HOSTS     ADDRESS          PORTS     AGE
fleet-allocator-ingress   *         35.186.225.103   80, 443   1m
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To learn more about the status of the ingress, run:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl get ingress fleet-allocator-ingress -o yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When the output shows the ingress.kubernetes.io/backends as &amp;lsquo;HEALTHY&amp;rsquo; rather than &amp;lsquo;UNHEALTHY&amp;rsquo; or &amp;lsquo;UNKOWN&amp;rsquo; it is probably ready.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/backends: &#39;{&amp;quot;k8s-be-30021--7e98a70481f48a13&amp;quot;:&amp;quot;HEALTHY&amp;quot;}&#39;
    ingress.kubernetes.io/https-forwarding-rule: k8s-fws-default-fleet-allocator-ingress--7e98a70481f48a13
    ingress.kubernetes.io/https-target-proxy: k8s-tps-default-fleet-allocator-ingress--7e98a70481f48a13
    ingress.kubernetes.io/ssl-cert: k8s-ssl-1ab99915a1f6b5f1-b2a9924cee73d20a--7e98a70481f48a13
    ingress.kubernetes.io/url-map: k8s-um-default-fleet-allocator-ingress--7e98a70481f48a13
    kubectl.kubernetes.io/last-applied-configuration: |
      {&amp;quot;apiVersion&amp;quot;:&amp;quot;extensions/v1beta1&amp;quot;,&amp;quot;kind&amp;quot;:&amp;quot;Ingress&amp;quot;,&amp;quot;metadata&amp;quot;:{&amp;quot;annotations&amp;quot;:{&amp;quot;kubernetes.io/ingress.allow-http&amp;quot;:&amp;quot;false&amp;quot;,&amp;quot;kubernetes.io/ingress.class&amp;quot;:&amp;quot;gce&amp;quot;},&amp;quot;labels&amp;quot;:{&amp;quot;app&amp;quot;:&amp;quot;fleet-allocator&amp;quot;},&amp;quot;name&amp;quot;:&amp;quot;fleet-allocator-ingress&amp;quot;,&amp;quot;namespace&amp;quot;:&amp;quot;default&amp;quot;},&amp;quot;spec&amp;quot;:{&amp;quot;backend&amp;quot;:{&amp;quot;serviceName&amp;quot;:&amp;quot;fleet-allocator-backend&amp;quot;,&amp;quot;servicePort&amp;quot;:8000},&amp;quot;tls&amp;quot;:[{&amp;quot;secretName&amp;quot;:&amp;quot;allocatorsecret&amp;quot;}]}}
    kubernetes.io/ingress.allow-http: &amp;quot;false&amp;quot;
    kubernetes.io/ingress.class: gce
  creationTimestamp: 2018-09-23T19:13:36Z
  generation: 1
  labels:
    app: fleet-allocator
  name: fleet-allocator-ingress
  namespace: default
  resourceVersion: &amp;quot;4086&amp;quot;
  selfLink: /apis/extensions/v1beta1/namespaces/default/ingresses/fleet-allocator-ingress
  uid: c5a149b3-bf64-11e8-8a6e-42010a8e013f
spec:
  backend:
    serviceName: fleet-allocator-backend
    servicePort: 8000
  tls:
  - secretName: allocatorsecret
status:
  loadBalancer:
    ingress:
    - ip: 35.186.225.103
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;9-check-game-servers&#34;&gt;9. Check Game Servers&lt;/h3&gt;

&lt;p&gt;Let&amp;rsquo;s make sure that we have one or more Game Servers in a ready state by running this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl get gs
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For a fleet of 2 replicas, you should see 2 Game Servers with a Status of Ready:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;NAME                     STATE     ADDRESS           PORT    NODE       AGE                                
simple-udp-s2snf-765bc   Ready     35.231.204.26     7260    minikube   5m
simple-udp-s2snf-vf6l8   Ready     35.196.162.169    7591    minikube   5m
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If there is no fleet, please review &lt;a href=&#34;/site/site/docs/getting-started/create-fleet/&#34;&gt;Create a Game Server Fleet&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&#34;10-allocate-a-game-server&#34;&gt;10. Allocate a Game Server&lt;/h3&gt;

&lt;p&gt;Now that the ingress has been created, let&amp;rsquo;s allocate a Game Server by passing in our user and key to the /address endpoint.  This will call the allocate() function in main.go, which will return a JSON string of the GameServerStatus of an allocated GameServer, or an error.  The service uses Basic Auth to provide some security as to who can allocate GameServer resources, and the generated key is in main.go, in the function basicAuth().  Read the comments and code in main.go for a more detailed explanation of each function and method.&lt;/p&gt;

&lt;p&gt;Allocate a Game Server by running this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -k -u v1GameClientKey:EAEC945C371B2EC361DE399C2F11E https://[the.ip.address]/address
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The output should show the JSON of the GameServerStatus, similar to this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{&amp;quot;status&amp;quot;:&amp;quot;Allocated&amp;quot;}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You may need to wait a few moments longer if the output has ssl errors like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl: (35) error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Check the Game Servers again, and notice the Allocated Status.  You should see something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;NAME                     STATUS      ADDRESS          PORT    NODE      AGE
simple-udp-s2snf-765bc   Allocated   35.231.204.26    7260    minikube   5m
simple-udp-s2snf-vf6l8   Ready       35.196.162.169   7591    minikube   5m
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Congratulations, your call to the API has allocated a Game Server from your simple-udp Fleet!&lt;/p&gt;

&lt;h3 id=&#34;11-cleanup&#34;&gt;11. Cleanup&lt;/h3&gt;

&lt;p&gt;You can delete the allocator service and associated resources with the following commands.&lt;/p&gt;

&lt;p&gt;Delete the Ingress&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl delete ingress fleet-allocator-ingress
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Delete the Service&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl delete -f allocator-service.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Delete the Service Account&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kubectl delete -f service-account.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Delete the health check and firewall rules&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gcloud compute health-checks delete fleet-allocator-healthcheck
gcloud compute firewall-rules delete fleet-allocator-healthcheck
gcloud compute health-checks delete nodeport-rule
gcloud compute firewall-rules delete nodeport-rule
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id=&#34;next-steps&#34;&gt;Next Steps&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Customize the service by changing the constants and service key in main.go&lt;/li&gt;
&lt;li&gt;Make the &lt;a href=&#34;https://cloud.google.com/kubernetes-engine/docs/tutorials/configuring-domain-name-static-ip&#34;&gt;IP Address Permanent&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create an A record that points to your permanent IP address&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;/site/site/docs/getting-started/create-fleetautoscaler/&#34;&gt;Create a Fleet Autoscaler&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
  </channel>
</rss>
