[MUSIC PLAYING]
SPEAKER: We're going to take a look at how Cloud Code makes it
easy to develop for Kubernetes.
To develop for Kubernetes, you need
to set up Kubernetes configuration for your project,
find how to efficiently iterate on your code on Kubernetes,
and learn how to perform common development tasks
on Kubernetes, like debugging.
But it can be challenging to master
all the necessary config, slow and error-prone to perform
the repetitive tasks of building, pushing and deploying
images, and difficult to set up debugging against a Kubernetes
cluster.
That's why we built Cloud Code.
Cloud Code is a set of development tools
for Google Cloud that includes IDE extensions
for Visual Studio Code, and JetBrains IDEs,
such as intelliJ.
Cloud Code helps you author Kubernetes
config with completions, linting, inline documentation,
and code snippets.
It automates the process of running and updating
your code on Kubernetes and so much more,
that we don't have time to talk about it all today.
To get started with Cloud Code, download it
from your favorite IDE's extension marketplace.
Let's take a look at Cloud Code for VS CODE in action.
We'll get started by using Cloud Code to create a new Kubernetes
Project.
Cloud Code also works with your existing applications, as well.
First, select the Cloud Code menu from the task bar
and select New Application.
Next, choose the language and template you want to use.
I'll choose Node js hello world.
Finally, name your project and hit Enter to create it.
Now that our project has been created,
let's take a look at a Kubernetes config.
Expand Kubernetes' manifest and select helloservice.yaml.
Since this is a starter application,
the yaml's already here for us.
But if it wasn't, you could use Control-Space to view
the available snippets for Kubernetes config files
to create your own from scratch.
Here, let's just see how Cloud Code helps
add a new property to the spec.
I can return to the next line and use Control-Space again
to see completions for possible properties.
External traffic policy looks interesting.
Let's take a look at that.
Cloud Code offers inline documentation
here and on hover for all these Kubernetes types.
After accepting external traffic policy,
let's try setting it to none.
Looks like I didn't read the documentation well enough.
Cloud Code's linting is telling me
I need to use cluster or local.
Let's use cluster.
Now that we've seen how Cloud Code helps manager Kubernetes
in yaml, let's see how it helps you deploy to Kubernetes.
First, we need a cluster to deploy to.
Let's move over to the Cloud Code view.
I went ahead and created a Google Kubernetes engine
cluster from Cloud Code earlier, by clicking this button.
But you can add any Kubernetes cluster, including local ones,
such as Docker or MiniKube.
To deploy, we select Cloud Code from the task bar
again, and select Run on Kubernetes.
I'll confirm the cluster I want to deploy to,
confirm a default image registry for my Google Cloud project.
And Cloud Code begins the deployment.
It looks like the deployment has completed successfully.
So let's take a look by Command clicking the IP address shown
in the output window.
When we return to Cloud Code, we see that watch mode is on.
That means I can make a code change
and it will automatically be redeployed.
Let's give that a try.
I'll expand the source folder, select app.js,
and change hello world to hello devs, and save the file.
We can see that Cloud Code is automatically
redeploying the service.
And we can return to the web browser,
refresh, and see the updated page.
Let's see what it looks like to debug a Kubernetes
app with Cloud Code.
I'll go to the Run and debug view.
Select debug on Kubernetes and click the Play button.
We see in the output, that the debugger is attached.
So let's set a breakpoint in the app.js file
and reload the page.
The breakpoint hit, and we can see all the utility
that we expect with the debugger,
even with code running on a Kubernetes cluster.
You just learned how Cloud Code lets
you focus on writing code like you always have,
and spend less time learning an endless set of new tools
and technology just to be productive on Kubernetes.
[MUSIC PLAYING]