>> Okay, hey everyone
and welcome to my talk. My name is James Trott.
I am a Principal Engineering Lead Microsoft
and previously pride for my current role.
I built some of the large enterprise services in Azure,
and I'm now talking to people about
how U.S. game developers can
gain the benefits of years of
enterprise or indeed from
some of Microsoft's biggest customers,
and leverage them in your own game development projects.
And there's a dinosaur attacking the booth apparently.
So, I'm here to talk
to you about Containers clusters in the Cloud,
specifically for gaming applications.
If anybody's worked with Dr.
Containers before, then this is absolutely for you.
If you have not, then I will take
you through what that means.
When you think about gaming and you
think about online gaming
you of course think about servers.
And one of the things that we get asked
a lot about at Microsoft is,
"Hey, how do I take those online instances of my game?
Make them available in Azure easily?"
I'm not a big online guy.
I'm not a big Cloud developer.
I've been focused on making
the most fun experiences for my customers,
for my gamers as possible.
So, I wanted to put something together
and just show you guys how easy it
is to get started with this technology in Azure.
So, that is the penultimate slide.
For there are very few left.
This all starts with Docker.
So, Docker is a Container technology not owned by
Microsoft and it is used to wrap run times,
and execute them, Containerized
over a Hypervisor on a VM.
So, when we talk about what is a Container,
I just use the darker guidance
and as you can see here you
can place applications such as Tomcat, Java, Debian,
PHP, MySQL or your own gaming workloads,
and you can put them above
the Kernel of the underlying OS.
The cool thing about that is, each Container
is individually isolated,
and as such is
protected from all of the other Containers
running on that infrastructure.
It also means that it works on my machine
it is no longer a problem that you need to solve.
If it works on your machine,
It's using the same Kernel.
If all of your dependencies are inside of
the Container and as such, it's all available to you.
This is the difference between Containers and
Virtual machines in the Cloud.
So, as you can see on the right there, you've got the VM,
it's running its app, it sits on
a Hypervisor over infrastructure.
On the left, that same Container is just running
the app and your dependencies, nothing else.
That's why It will always work on
your machine and always work on our machines too.
The dependencies are right there,
side by side, next to your app and everything else.
The Docker, the Host OS,
the infrastructure that it runs on,
outside of the Container being consumed from inside.
So, I'm just going to open up
a couple of steps here and then we're going to get
straight into how easy it is to deploy this stuff.
All of the information I'm going to share with you
is available at docs.microsoft.com.
As you can see here, we have documentation across
the entire Microsoft product range available there.
Everything I'm going to talk about has a tutorial
and a guide inside of docs.microsoft.com.
So, first we're going to talk
about Azure Container instances.
Container instances are a way to get started
quickly using Containers inside of Azure.
You can spin them up very quickly, very easily.
Then, we're going to move on to
talking about a fully manage
Kubernetes Cluster inside of Azure on AKS
or Azure Container Services which is
a fully managed compute cluster that you can
scale to meet the demand of your player base.
First, we're going to talk about what we're going to do.
We're going to deploy some Minecraft.
Minecraft is a game of the Microsoft acquired Mojang,
the developer of it, a couple of years ago.
It's one of the most popular games in the world right
now and I want you to think
about deploying Minecraft servers.
What if, you want it to deploy multiple, what if,
you were in charge of that Minecraft project.
What if, you want to make hundreds of servers available
for players to play on
in a safe close potentially protected,
password protected for private environment
and how you might turn that into a business model,
renting out multiple servers.
It's a business model today for
an awful lot of companies.
So, this is Docker hub available at dockhub.com
and you are able to
select images from a library of your dependencies.
There are a couple of games in there,
Database servers, anything you can think of,
that other people have taken
in Containerized made available
inside of Azure or any other Cloud of your choice.
Docker is a Cloud agnostic.
It's a technology out there.
Originally from the Open source and Linux communities,
that allows this wrapping
of apps and dependencies and so,
the images that are available here are put
together by other people and contributed.
This is the one of
the premier image from
Minecraft servers from a guy called Itzg.
And if we take a look at the Docker file,
you can see what's going on in here.
So, straight into the code. We'll take a look.
This is from the Alpine Linux image right here.
Calls out the Maintainer and
then it runs a whole bunch of
commands here that puts it together, Installs MC status,
which some Minecraft modification,
does a Healthcheck, and then I have
the bunch of groups and security things.
The underlying image actually installs a bunch of
dependencies for Minecraft and it
has the option to pull in Mods.
So, it has a very rich
project on "Get help" that you can go check
out that allows you to customize
your Minecraft server installs.
So, this is the image we're going to use.
We're going to use this to deploy
a Minecraft server inside of
Azure and we're going to do the whole thing here live.
So, the other thing I get asked is, how I do it?
Well, this is the Azure Portal,
and many of you may be familiar with the Azure Portal.
Typically, I prefer to do this with the Azure CLI 2.0.
It's completely possible here
inside of the actual portal to deploy services,
deploy Containers, deploy clusters.
I prefer to do it to Command line,
many developers prefer to do exactly the same thing.
However, today,
we're going to try something a little different.
What we're going to do is, we're going to try and do this
in the Command line inside your web browser.
Just to prove that I'm not cheating,
that is a copy of Microsoft Edge and I
just click the button going to request
me at Cloud Shell Window.
This is a full Linux Patch Terminal
running inside of your web browser on Azure.
So, once it's connected, it's going
to request a session for me.
And hopefully it's going to spin up
a live Command prompt connected to my Azure portal.
So there it is. James@Azure. So, we're
just going to get a few things set up here.
We just need a few little environment variables set.
So, we're going to do a resource group name
"equals GDC-live".
We're gonna do Region.
We're going to pick our Azure Region.
I'm going to deploy these into East US.
Now, we're going to pick the name
of our Container instance.
So, we'll do "instance_name" and
we will use "gdc-instance".
Then, we'll do the name for our cluster that I'm
going to show you how to do.
E.g. "gdc-mc" from Minecraft
and then when we do
the deployment inside of Carbonetties,
we're gonna need a deployment name.
So, I'm just gonna call at
"gdc-minecraft". All right and we're all good to go.
So, when we think about this,
the first thing I want to talk
about is deploying a Container
as an instance and Azure Container Instances,
one instance of a Container that you specify.
This is your getting started scenario
and if you just want one server for
Dev test purposes or perhaps you
just want to spin something up
yourself to kick the tires.
I really recommend trying an Azure Container Instance,
it's super straightforward to get started with.
So, we're going to try and do one live here.
So, the Azure can be automatically
deployed inside of the Azure Cloud Shell
and is used using the Command AZ.
So, if I type AZ, I can see all of the services inside of
Azure that are available to me through the Command line.
What I'm going to do now is,
I'm going to use the AZ Container.
AZ Container takes Azure Container instances.
I'm going to create one.I'm going to specify a name,
and we specified earlier that our name was going
to be "$ instance_name".
We're gonna do, Oh, I missed a step.
So, we're gonna have to do
"AZ group create-- location=$region".
This is going to create us a resource group inside of
Azure " -- name=$ RG_name".
Fingers crossed. Provisioning state equal
succeeded successfully created a resource group
inside of Azure and if you don't believe me,
when I click the little "Refresh" button here.
That's, okay.
So, I just come into here and type gdc in my filters,
gdc-live, which was the name
that we specified at the beginning.
So, we'll go back to my dashboard here
get straight back to what we were doing.
As I mentioned before, we're gonna do
az Container create.
We specified the name already so name
equals dollar INSTANCE under score NAME.
We need to specify the resource group that we
want to deploy to.
I already stuck that into a variable so
it's already there and available for me,
so RG underscore NAME.
That'll do there. Then we need to specify the image.
The cool thing about the image tag in Azure Containers,
Container Instances and Container Services is that,
it will automatically check Docker hub
for the image as long as you name it correctly.
So, itzg slash minecraft dash
server is the name of our image.
Now we need to tell it that we're
going to want an IP address,
so we need an IP address
and because I want to be
able to connect to my Minecraft server,
I'd like it to be public.
I need to specify a port which for Minecraft is 25565.
And I need to tell the instance
how many CPUs I want with dash dash CPU.
So, I've used equals 25565 dash dash CPU space two.
Then I need to specify one environment variable
that is essential for Minecraft which is, so,
environment dash variables space EULA equals TRUE.
This tells Minecraft that I accept
their end user license agreement
and I am able to deploy this Container.
So it's a little lengthy there but
that one Command when I execute
it hopefully passes the perimeter test,
so, fingers crossed once more.
Provisioning state is now creating.
Now if I go back into
Resource groups where we've taken a look before.
I type gdc-live which is the name of
my resource group and I go into here.
We hopefully see, gdc dash instance.
So if I go into gdc dash instance
you can see live and the Azure Portal working side by
side with that Cloud Shell hosted inside the web browser.
So, we're still inside the web browser here.
This is just Microsoft Edge.
We haven't left and we haven't needed
any other tool on the web browser.
I could do this on a tablet,
I could do it on
any device with a compatible web browser.
We can see the IP address is already here and ready.
And I tend to find that the game devs
especially are very cynical of this particular demo.
So, I just like to have Minecraft here waiting.
So we're just going to call this ACI MC
put in the server address not twice.
So, done. Hopefully, the little bars
on the right are going to turn green for me,
telling me that my server is available.
There it is. And just in case you are still cynical.
Any way, that I have not deployed
a real live Minecraft server with
the IP address to that resource group we will log in.
And they're live as a Minecraft server
capable of running 30 players with
two CPUs live in the Cloud from
a Cloud Shell inside your web browser.
Thank you sir, I appreciate that.
So, that's super useful for your dev test scenarios.
You're able to create and spin up that server.
Right there, you saw how long it took me.
We've been in this like five minutes.
We're in it together,
we're going to get through it, it's fine.
So I'm going to jump straight back out to my web browser.
What about your scale scenarios?
That's where we start talking about clusters.
Maybe I want a cluster of multiple VMs
running multiple Minecraft servers.
You can actually run a couple of Minecraft servers
just on a very low-powered VM,
got two CPUs, 16,
32 gigs of ram will run a healthy number
of Minecraft servers. So, you can spin them up.
So, what I'm going to show you how to do now
is create a cluster of
VMs controlled and managed by
Azure Container Services AKS inside of Azure.
I'm going to show you how to deploy to that.
I'm going to show you how to
scale it and I'm going to show you how to
configure it to scale itself based on utilization.
I'm going to doodle from
a Cloud Shell inside of a web browser.
So, bear with me,
sometimes it goes a little wrong but I've prepared,
I've got backup on my backups,
I think we're going to be good.
So, we've already got our resource group
and our variables so I'm going to do az aks.
Note that I'm not typing az Container,
az Containers is for Azure Container Instances,
az aks is specifically for Azure Container Services.
So, I'm going to create just like last time it's
a very similar syntax and we try to
make sure that it's fluid and all the same.
I'm going to use a name and if you remember my name is
cluster underscore name the dollar
is a variable I stored it in the beginning.
So, for those of you that came late they're all stored,
I'm not cheating, I promise.
The gentleman in the front row can tell you,
I typed it all.
So there's our cluster name.
We're going to do our resource group
which you'll remember from before.
We're going to dollar resource.
Sorry, RG underscore NAME,
that was my researchGroup name.
This is a cool little flag that I cast
supports dash dash generate dash SSH dash keys.
How many of you have deployed VMs before?
Especially Linux VMs and then had hold
the whole dash with getting the key
setting your certificates and matching them up.
If you put dash dash generate dash SSH keys into
the aks Command line and you do not
have an SSH key already available,
it will create one for you.
Put the public keys into your dot slash RSA folder.
Then it will configure your cluster to use that key.
If you already have an RSA key
it will use that one by default.
I'm in the Azure Cloud Shell so I don't have SSH key.
So it's going to generate that
for me and the Cloud Shell's are really cool.
It generates a disc live on blob storage,
a storage account inside of Azure subscription
uses that blob storage as persistent storage.
So, if I close this Shell window
and then I come back the same
as SSH key is still there and I can
still connect to all the services I created for it.
Hosted, backed up and globally available live in
the Cloud, from my web browser.
You can graph it down.
You can email it to yourself you can access
the blob storage disk and download the actual file.
You cannot SSH into the Cloud terminal but you can access
blob storage using either the blob storage
SDK or you can access it directly.
You can access it through the web browser
or you can send it to yourself.
You can SSFTP it. You can
send it to a VM so you can SSH into
a VM box from the Cloud Shell you just
SSH from the Cloud into your box
and then you can put it into there.
You can use this blob storage is available like
a file store so you can just go grab stuff out of it.
So, the key is completely accessible.
What I would recommend doing is
sending your key into Azure and then consuming that.
You have your Keychain and
you UVKey whatever you want to do.
I would just use the same key and then just
have different ones for different infrastructure levels.
You know your dev keys your test
keys your deployment keys.
Then lastly, I'm going to use
this dash dash no dash wait.
So, one of the things
that takes a little time is standing
up a bunch of infrastructure.
We have a very short time here
today with you at GDC and I want to give you
as much value as possible so I'm not
going to make you wait for the cluster to stand up.
Dash dash no dash wait says,
"Don't wait for any long running operations
to complete before you give me the Shell back."
So, I'm just going to run it like that.
I've got the name, I've got the resource group,
I've got the keys I got
no wait. I'm going to run it, we're good.
So any second now
it's going to come back and it's going give me
that JSON result and it's always a JSON result.
So, these batch commands can be executed remotely.
So, because there's no way it
doesn't give me the JSON result.
I forgot that, my bad, I'm sorry.
But if we go back to my research group,
gdc-live and then I refresh this. There's gdc-mc.
That is a live Kubernetes cluster,
running, spinning out with a bunch of nodes.
Now one of the things I just want to note for
you guys is that when you do this
when you go out to research groups.
When I do this. Oh, excuse me.
When I refresh this list, eventually,
there's going to be a second resource group
called gdc-live in there.
And you can see this with this one that I created
earlier this was super handy called gdc-pre.
So, the live one is live and the pre-made
is pre. We're all open here.
So, with gdc-pre,
which I have this handy Ubuntu Shell running in Windows.
So, this is pure Windows,
this box is a pure Windows box.
This is the Ubuntu Windows subsystem
for Linux running inside of Windows.
I already have a cluster here called gdc-pre.
So, while were waiting to deploy I can show you
some neat things about Kubernetes.
One of the things you can do is,
you'll notice that the az Command line
is running inside of here.
Like, so, and I already
have all of those same services
that I had in my Cloud Shell.
Now if you do az aks install dash cli,
it's going to think for a little bit.
Oh, sorry, sudo az aks install dash cli.
A little password here,
don't say it out loud like I did last week.
Just joking, I would never do that.
This will download the Kubernetes client.
It's called kubecontrol or kubectl,
downloads will make it available.
So, now as soon as I type here to kubectl.
There it is now, I already cheated.
Pre already has a minecraft server running on it,
so I do kubectl get nodes.
There are three already running in gdc-pre.
There's already three AKS nodes running if I do kube.
That's the number VMs running underneath.
So, those are individual VMs,
two VMs in this case running,
AKS and they're ready to receive pod loads.
If I do kubectl get pods, no resources found.
This is where we want to be.
So, it's a three-node cluster,
ready for me to do something with it.
So, what we're gonna do is we're
going to deploy Minecraft to this thing.
So kubectl is already connected
because I got the client and just for
those that wish to know in order
to setup kubectl to connect to my cluster.
It seems like it's a little magic
right now it's automatically connected.
I just need to do a quick command line
az aks get dash credentials
dash dash name equals dollar cluster dash name.
Sorry, that's cluster underscore name.
Then, dash dash, I've lost my place.
Oh, there we go dash dash resource group, stupid.
Dash group equals dollar RG underscore NAME.
That's okay I already ran it
because you can already get connected.
So, this is just for your reference.
I don't actually need to run it the typo is good.
Otherwise, I'd have gone back and done it.
So, that's how it's connected.
What that does is automatically downloads
the credentials for that and connect
kubectl to it using
your RSA key. So now we're hooked up ready to go.
So, quickly we're gonna do you,
kubectl run Minecraft, gdc dash, no.
That's right, yes. We're going
to run an operation that we're going to
call dollar DEPLOYMENT underscore NAME.
That's good.
We're going to do --imageitzg/minecraft--port.
Everybody remember the port from Minecraft?
25565. And then--env for
those environment variables that were essential
last time, =EULA =TRUE.
And we're good.
Gdc-minecraft is created.
I'm now going to do kubectl get pods.
Pods are the individual running.
Oh no, the Internet is no longer pulling my image.
Let's just double check this.
It's okay, error between keyboard and laptop,
keyboard and chair. Of course.
So, we're just going to quickly edit my
deployment name because now it's errored.
It's using my variables so I'm
going to do DEPLOYMENT_NAME=gdc-minecraft2.
Bingo. Kubectl get pods.
ContainerCreating there on the second line.
Meanwhile while I'm doing this,
just going to quickly clean up after myself.
Do kubectl delete pod, pod deleted.
Get pods.
Containers are creating across the board.
So, we wait until one is created.
So this one here is running. The last step for this.
You may remember, I had specified
an IP address when I created an Azure Containers instance.
So, what we have to do here is expose the service.
It's just exposing it on the edge
of the resources that we created.
So, we just do a quick kubectl
expose deployment and I
believe we called our instance this
time gdc-minecraft2--name=minecraft-service.
That seems fine.
And then the type
is really important. So, I want to call this out.
I'm going to use type=load balancer.
That will load balance between my services
so every player that connects will just get a server.
It will just go around, and it'll connect each one.
There's another option called node ports,
which exposes each one of
the different external port and
the external service port.
We then run this up. Services exposed.
We do kubectl get services.
It's already running, and you can see
here external IP pending.
That is waiting for an IP address
from Azure just like it was in the portal.
It's requested a public IP,
and it's ready for one to provision.
Now, hopefully, this is going to work super quick for us.
One of the things we can do is kubectl
get services--watch.
That's going to run it, and it's just going to sit there,
and when that IP address comes in,
it's going to give me that new line, and say,
hey, your IP address is totally available. Not right now.
I'm running close to time,
so I'm going to get about 30 seconds.
If it doesn't come up, we're
going to move to a different one and I'm just
going to show you how to manage
your deployments when they're live.
Doesn't look like it's going to give it up.
One of the things we can do briefly
is just quickly check the portal,
so we go into gdc-pre where
I was working, my pre-made cluster.
And we can close
my Cloud Shell because it's all going
to be there for me when I get back.
Which are the resources in node pools?
Oh, that's interesting. It's in a failed state.
I guess we'll go back in and check that later.
In case of emergencies,
I have one more resource group backed up with
a cluster called gdc-mc-test.
And if you remember before we were
talking about kubectl get-credentials.
Sorry, az aks get-credentials.
Yup.--name=gdc-mc-test--resource-group=$RG_NAME.
This is all inside the same resource group.
It's not gdc-pre. We just got out of that.
It's gdc-dry from my dry run.
Merged context kubectl get nodes.
You see it's a five-node cluster.
kubectl get pods. There is a Minecraft server.
The Minecraft server is there, it's running.
If I check kubectl get service,
there you go. External IP.
I'm not going to log into
this one but I am going to show you that it
works because we've had to switch to the backup,
but it's a real Minecraft server, it's really running.
It's really running inside of that five-node cluster.
See? One like Minecraft server, zero players.
So two last things that we're going to do.
What about if I wanted more on
my game dev and my server is full, it's launch day.
Everybody's been in that scenario.
Super popular game and they don't have enough capacity.
What would I do in this scenario?
I might type a lot of code, I might have to provision
new hardware. Not in AKS.
What I have to do here is
just gokubectl scale--replicas.
So, let's say I want three servers,
=3 deploymentsslash gdc.
What was the good name inside of here,
-mine craft, gdc-minecraft scaled,
and if you don't believe me kubectl get pods.
We'll show you that there are now
three Minecraft servers running instead of
one and they are load-balanced on my
load balancing in the cluster.
And for one last trick.
If I didn't want to care about this
anymore, what I might say,
if I knew the CPU usage of my particular application,
I might say kubectl autscale
deployment gdc-minecraft--cpu-percent=90,
90 percent CPU scale,--min=3--max=5.
Run. Of course, What it's going to
want from me is this thing.
One second. Kubectl get deployments.
It's probably named a
different thing on this cluster and that's
my mistake. No, that's correct.
The problem is that this one is already configured to
autoscale because this is my dry run,
it's already completed that.
There is one last thing we can possibly do
here that will allow us to do this,
which is to run up our Cloud Shell one more time.
Ask kubectl what is in there.
It should still be connected.
We're live on the web browser,
five-node cluster, 3 pods running.
And then hopefully I did not autoscale this one earlier.
You saw me to describe it so all we're going
to do here is kubectl autoscale.
Oh, we have to get the deployments.
If this doesn't work
we're gonna have to do it another day.
But. We're going to
do deployment gdc-minecraft--cpu-
percent=90--min=1--max=3.
In fact, let's do 10.
All right.
We can play spot the typo.
>> Get.
>> What's that?
>> Kubectl get.
>> There we go.
Now, it already exists.
I'm fortunate that first. What's that?
>> How do you edit the autoscale policy?
>> This was going to be, it's get hpa.
So, I could actually delete
that if you wanted to so I get.
That code HPA is Horizontal
Pod Autoscalers so you can just do
kubectl delete hpa gdc-minecraft.
Since you asked. Delete it and run it again.
And that's how quick it actually
takes autoscale if you don't have
a high horizontal pod autoscaler available.
Thank you very much for coming to my talk.
That's how easy it is to deploy
containers clusters in the cloud
for gaming live in your web browser in a Bash Shell.
Thank you very much.
We'll be running this until tomorrow.
If you're into Containers,
please hang on for Brian Peak.
He's one of my colleagues from
Microsoft in Redmond, focuses on gaming,
who is going to be talking about developing
your game specifically for using
Azure Container instances and Azure functions
as part of your game. Thanks very much everybody.
Không có nhận xét nào:
Đăng nhận xét