[MUSIC PLAYING]
SPEAKER 1: Joining me now is Priyanka Vergadia, a customer
engineer at Google Cloud, who's going
to show us how to develop for Kubernetes without leaving
your IDE.
Thanks, for being here.
PRIYANKA VERGADIA: Thank you, for having me.
I'm going to talk about Kubernetes and how developers
can work within the Visual Studio
environment and deploy applications into Kubernetes.
So let's jump right in.
SPEAKER 1: Great.
PRIYANKA VERGADIA: Cool.
So I have on the left hand side my terminals,
which we're going to use to do some deployments.
And then on the right here, I have a Visual Studio Code.
So we're going to start off by creating a new application.
I'll just create a "Hello World" Node.js
application, nothing fancy.
So what's happening here is we should
be able to see our application created.
Once I refresh, it is showing up my application.
I have the source files.
The front end and the back end are the different services
that are in this application.
In the front end, we have the 8080 port that's
listening to the front end.
It's talking to the back end on back end service address.
And in the back end, we have the index file
that's also talking to 8080.
So we're going to change that to 8081 so that we
don't have a port conflict.
And then at this point, if we go and start these services
and then just check where we are in our terminal,
we're at the right place in the front end folder.
And we want to do the same for our back end as well.
So I'm going to go into the right folder, which
is the "Hello World" Node.js application too.
And then so we're now in back end and front end folders.
Now, if we run NPM install, that's
going to get us all the dependencies
that it needs to run both our front end and back end
services.
And then once that is done, we need to start these services.
So our back end is running on 8081,
and our front end's running on 8080.
So we're ready to test our application.
Our back end is on 8081, and our front end is on 8080
talking to our back end.
So we have an application that's running through Visual Studio
Code.
Now at this point, if I wanted to deploy this application
into GKE, I would first need a cluster to create.
And then once the cluster is created,
then I can start deploying this application.
So let's see how we can create a cluster from within Visual
Studio Code.
I have the extension for Visual Studio
Code, called GKE extension.
And once you download that extension,
you'll start to see your projects
and your clusters in your IDE environment.
I'm going to just use one of the current projects
and create a cluster in the current project.
So my current project is pv-cube-dem.
And so we'll set that as a project ID.
And then it gives me an option to select the zones.
And then here, we're just going to say test as a cluster name.
And then there's the number of nodes
that you want to create that you can change and then
also the machine types.
We're just going to go with the standard and click Create.
Once I do that, it takes maybe three to four minutes
to actually create the cluster.
It's spinning up all these instances
in Google Cloud for you.
And if I refresh this, you should
be able to see that it's starting to bring up the test
cluster right here.
It's orange, because it's not set up yet.
So give it a few minutes, and it starts to set up.
At this point, we're going to just use for the demo purpose
a cluster that I already have created.
And we'll go through the demo using that cluster.
Now, once I have the cluster, I'm ready to deploy.
And I need a Skaffold YAML to actually deploy in the cluster.
SPEAKER 1: OK.
And for those who might not have heard
of Skaffold, what is that?
PRIYANKA VERGADIA: So Skaffold is basically
a command line tool that lets you define
your Kubernetes manifest.
It also defines the container registries.
And then for the back end, and the front,
and especially for our application here,
so if you have a large number of services
that are running in your application,
you would define your container registry addresses in there.
It would pick up from those addresses
and deploy your service in GKE.
SPEAKER 1: Great.
PRIYANKA VERGADIA: Yeah.
So let's see an example of that.
So I'm just first going to go through deployment.
I think I forgot to set the cluster,
so let's first set this cluster.
Once it is set, then we're going to deploy.
Take the deploy, and do that.
It's starting to deploy.
While it's deploying, let's look at our Skaffold YAML.
This is the YAML I was talking about where
you have the back end, and the front end,
and the gcr.io addresses, which is the container registry
address, and then the manifest for you Kubernetes.
And it seems like we have our application deployed,
so let's see the IP address.
That's the IP address of our application.
It's the one that we just created.
And we see that the application is working on port 4,000.
So our front end is talking to our back end.
Both of them now deployed on a GKE cluster.
So we did all of that from our IDE.
And yeah.
SPEAKER 1: That's fantastic.
I guess the next step that I would think of
is making changes to, let's say, our back end
without affecting our front end.
So for example, what if I want to test to make sure
that my change doesn't break anything without needing
to redeploy and rebuild.
PRIYANKA VERGADIA: That's a great point
because, in a development lifecycle,
that's the biggest hurdle.
You develop, you test, and then you want to deploy that.
But the test stage is a very critical stage,
so you would use something called TelePresence for that.
And TelePresence is, again, a command line tool
that helps you create a proxy.
So in this case, in this example, what we're going to do
is create a proxy and create and run our back end
on local machine.
And then our front end would continue
to run on our GKE cluster in production.
So we're able to test the changes to our back end,
but our front end stays intact.
SPEAKER 1: OK, great.
PRIYANKA VERGADIA: So let's see that.
Yeah.
So in this case here, so when you come out of this--
and let's see where we are--
I want to go into the application
that we just deployed, which is this.
And let's make a little bit of a change
here in our front end application
so that we can use a little bit of a--
so I just called it Version 2 for our back end.
And at this point, if I run my TelePresence command, which
is nothing but it creates a proxy,
and it's going to run it on port--
so here it is.
It's forwarding the ports now.
And if we go test our back end on our local machine,
that's going to Version 2.
And it should work the same way from our front end, as well.
So that's pretty much how it works.
SPEAKER 1: Very impressive.
So we were not only able to see you
being able to redeploy using your local IDE to GKE
using Cloud Code and Skaffold, but you were also
able to make changes locally to a single service, test it,
and then again redeploy to GKE once we're using--
PRIYANKA VERGADIA: Pretty powerful, yeah.
SPEAKER 1: Yeah, TelePresence.
OK.
Well, thank you so much again for joining us.
PRIYANKA VERGADIA: Thank you for having me.
[MUSIC PLAYING]