>> Hi!
I'm Donovan with another episode of Azure Friday.
I'm here with Rome, and we're going to learn about using
Java in Kubernetes. Welcome to the show, Rome.
>> Thank you.
>> So, what do you do here at Microsoft?
>> I'm an Engineering Manager in
Visual Studio team and our team
actually works on all kinds of
tools to support Java development.
>> Okay, is that specifically for
Visual Studio Code or anything?
>> Yes.
>> Oh got it.
>> Yes, it's on Visual Studio Code.
>> Perfect. Visual Studio Code has quickly become
my favorite tool I use every single day.
I use it for not only Java but
Power Shield,.NET, Node, everything.
>> That's the point. We call this developers
like Polyglot [inaudible] developers.
I work with every language and every kind
of projects with Virtual Studio Code.
>> Yes the extension library that makes it
so easy-to-use because whatever I need,
it's in the, it has an extension for it already.
That has to be true for the Java world as well.
>> Yeah exactly. Today, I'm going to show you what we can
do with Java and
also Kubernetes inside Virtual Studio Code.
>> Cool.
>> Let me show you the portfolio we have.
If you search Java inside
the marketplace for Virtual Studio Code
you actually get a bunch of them.
Were actually pack them for you,
if you start with the job extension pack.
You have the language support.
This is from Red Hat and will also
contribute to that project and then we
contribute Debugger for Java
and also the Java test run there for JUnit.
>> Oh perfect.
>> And also Maven. This is all
you need for Java development.
>> Got you.
>> But today we'll work with
containers for microservices.
We also use the Docker Extension from
Microsoft and also the Kubernetes ones.
This is all the extensions we need today.
>> Got you.
>> And you can check it yourself later.
>> I know I've done some Java especially
I do alot for demos and things like that.
The most popular framework I've seen is Spring.
The other extension for spring as well?
>> Yes, exactly. Our friend,
people actually published several extensions
to support Spring Boot development.
>> Got you.
>> It's the Spring Boot Extension Pack.
We actually contribution the Spring
Initializr for, to this package.
>> Okay.
>> You can start with, if you are using Spring Boot.
You can start with this one.
>> Perfect. So shall we, what are we going to do today.
Are we going to take an application
and develop it locally and move it to the Cloud?
>> Yeah exactly. Today, I'm
going to show you this example.
We have this, we published this sample project on GitHub.
>> Okay.
>> You can download or clone it from there from there.
This is a very simple Spring Boot application.
It has a web interface of a to-do list.
>> Okay.
>> And it talks to Cosmos DB in
the back-end and it maintains that to-do list.
>> Perfect.
>> That's the application.
>> Okay.
>> I already cloned it myself.
So let's jump into the application.
Okay. This is a very typical Java application,
the Spring Boot application at the same time.
It has the model and the controller and
also the data persistence layer
that talks to the Document DB.
>> Got it. We already have
APIs and SDKs that we can install in
Java to allow us to access
all that stuff inside of Azure?
>> Yeah exactly. Actually, you use the Maven archetype or
Spring Initializr to scaffold your project.
>> Okay, got it.
>> In your Studio Code.
>> All right. Perfect.
>> Yes. And so next.
If you just wanna run it locally.
Just like other Java applications you can just hit F5.
>> Okay.
>> Everything is all set.
>> But when I do that, it's not
running in a container at that point, right?
It's just running locally off of my machine.
>> Yeah exactly. It's actually launches the JVM.
>> Okay.
>> You have to launch your program.
>> Right, it's just fine and you're
doing quick development.
>> Yeah exactly.
>> But if I'm going to be deployed in that container,
chances are I want to develop and
tested in a container two to make sure
that the image that I build
is going to be the image that is going to be deployed.
So how would I take the F5 experience you just gave
me and actually make it Dockerize so it's accurate.
>> Yeah exactly. With the help of the Docker Extension,
we already have a Docker file inside the repository.
You can just right click on it.
And then click "View Image".
>> Got it. Okay, so when you build an image though,
you have to have a Docker Infrastructure on your machine.
So it looks like you're on a Mac.
So you have Docker for Mac
on your machine and that's where
the image is actually being built?
>> Yeah exactly.
>> And this would be the same if I were
on Windows I would just install
Docker for windows on my machine
and the same experience would happen?
>> Yeah exactly.
>> Okay, perfect.
>> Okay so the images view,
you can check it inside the Docker Explorer.
The images here.
And the next thing we need to take
this image and run it inside the Kubernetes.
>> Okay.
>> This is where the Kubernetes plug-in can kick in.
>> Okay.
>> So there is one problem we need to
solve before we can run it inside Kubernetes.
Because as I said,
before this application talk to Document DB,
we need to provide the credentials to access that DB.
>> Got you.
>> Typically, you can do it inside
Azure portal to provision
the Document DB instance and copy paste everything here.
>> Okay.
>> But today, I'm going to use something even
cooler that the service catalog of Kubernetes.
>> Oh, okay. So you can store secrets and stuff, right?
>> Yes, exactly.
That command line two is a service cat.
And then you can list all the classes of Azure offerings.
Today, we're using the Cosmos DB and
also for cloud services
you actually care about the plans,
right? So we can.Okay.
>> Okay.
>> Here we have one plan of DocumentDB.
The next thing is we can directly provision
this instance of DocumentDB within the command line.
>> Okay. So right
now you don't have a document DB in Azure,
you are provisioning it right now or?
>> Yes, exactly.
>> Oh okay. Got it. I got it.
>> So this is how we provision
this DocumentDB instance, just hit enter.
It's actually returns immediately but
actually it's still provisioning.
We can check the status here.
You see it's provisioning.
I already have another one provisioned.
Let's just use that one for the demo, okay.
>> Okay. Great. But we see how
easy it is right from inside
a Visual Studio Code to be
able to provision a new Cosmos DB.
>> Yes, exactly.
>> And what you're saying is that you've
previously already done this and we're just
going to do that when it continue the demo?
All right, perfect.
>> The next thing is to expose
that to a Kubernetes Pod's,
right, to expose the service.
So we do that using the bind command.
So what it does is that it exposes
the credentials as Kubernetes secrets.
>> Okay.
This cat tool that you're using.
Where was that installed?
Was that installed through the Kubernetes extension?
>> No it actually, you actually need to install that.
It's still a Kubernetes incubator project.
You need to install that from that page.
>> Okay. Got it. Okay good.
Then I'll have this and
it works with making sure that the
information that I'm collecting
for the connectivity information,
that connection string for my Cosmos DB is then
going to be stored safely inside the Kubernetes.
>> Yes, exactly.
>> Okay, got it.
>> Yeah. By leveraging
the Kubernetes secrets infrastructure.
>> Okay. Got it.
>> This is the secret we just bind,
by running the bind command.
You can actually see the primary key here and URI here.
This is all the information.
And the next we need to map
this information to the system,
to the environment variables here.
So we do that using the deploy, the manifest files.
>> Got it.
>> This is how we map it.
We reference it from the secret and
map the entries to the environment variable we need.
>> Okay, got it.
>> Okay.
>> Yeah. So next thing is we need to run
the Kubernetes command that
comes with the Kubernetes extension.
If you want to create this,
the deployment you just run the Kubernetes.
You see, you actually see a bunch of
Kubernetes started commands here.
We run the created one.
The deployment is actually
created with the help of Explorer.
The Explorer actually visualize everything.
>> Okay.
>> So you can see here that the deployment is here.
>> And I see right now it looks like
Kubernetes is connected to Minikube.
>> Yes.
>> Which is a development instance
that you have running on your machine.
>> Exactly.
>> And that's because of
your kubeconfig and it's configured with that.
>> Yeah.
>> So if I wanted to go to AKS or different cluster,
I would simply change that
and all these same commands would work?
>> Yes exactly. It will still work.
>> Perfect. Okay, got it.
>> So this is the deployment we have.
We actually rolled out two pods.
You can actually check them there.
This is the pods we have.
And you can actually see the logs.
Let's check the logs to see
how our application is running.
Okay. This is the Spring application we're running.
It's starting. The next thing is we need to
expose that to for external access.
>> Okay.
>> We do that through using the service.
Okay, let's create that service also.
Okay, it is created.
The last thing we need to do is to run
the Minikube command to access that service.
Let's check the name of the service.
Refresh it a bit.
Okay, this is the service.
It will launch service, oh sorry.
Because this is expected,
because the Spring Boot application
is actually starting, right?
>> Exactly.
>> It's not finished. Okay, it's started.
Okay. This is all live.
It's actually talking to the DocumentDB on Azure.
>> Okay. Let's just add something to it.
Azure, okay, add this time.
Okay and check that.
We just, we just did it recording.
>> Exactly.
>> Okay. Awesome and to,
now because it's inside of an image.
I could then publish just to a registry
and then from that registry
pull it down to my actual print [inaudible].
>> Yes, exactly. With the help of
Docker Extension you actually can push this image
Docker Hub or you can have
a like ACR provided by Azure. You can use that too.
>> ACR is Azure Container Registry for
those who don't know are crazy acronyms and things.
>> Yeah.
>> Perfect.
So that's your own private registry where you can store
your images and then pulled it into any host
that you get including Kubernetes.
This is awesome, awesome stuff.
Again, every time I use Visual Studio Code,
it just blows my mind how I
don't have to leave it to get anything done, right?
>> I'm a fan. I'm a fan.
>> Me too. And what's also I like about, your own a Mac.
I'm on Windows machine, I also have
Linux boxes and code is the same everywhere.
I feel completely comfortable,
no matter what platform I'm actually using.
>> Yeah exactly.
>> So if someone wanted to learn more about this.
Where would they go to learn more about
using Java with Visual Studio Code?
>> Okay. We actually have this page
on the website of Visual Studio Code.
You can remember this URL.
I would always encourage
developers to start with this page.
We have a tutorial here.
Here you can work with a Spring Boot and
also Serverless and Debugging
all kinds of information is here.
>> Awesome. Thank you so much.
That's incredible stuff.
We're learning all about using Java
and Kubernetes here on Azure Friday.