ACR and AKS Demo

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
14 hours 28 minutes
Difficulty
Intermediate
CEU/CPE
15
Video Transcription
00:00
>> Hello, Cybrarians.
00:00
Welcome to Lesson 5.6 of Module 5 of this course
00:00
titled AZ-301: Microsoft Azure Architect Design.
00:00
Here are the different tasks that
00:00
we'll complete in this demo.
00:00
We'll start by creating an Azure Container Registry.
00:00
After which we'll push a container image
00:00
that exist on a local machine into the registry.
00:00
We'll then create an Azure Kubernetes Service cluster.
00:00
We'll connect to the cluster using Kubectl,
00:00
however you pronounce that.
00:00
We'll deploy a container image that's
00:00
hosted in ACR into our AKS nodes.
00:00
We'll scale the pods in the AKS cluster,
00:00
and then we'll scale the AKS cluster nodes.
00:00
Let's get into this.
00:00
The first task that I'll be showing you is
00:00
the creation of an Azure Container Registry instance.
00:00
Actually before going ahead to create the instance,
00:00
I'll give you a quick review of what I currently
00:00
have setup in my test or demo environment.
00:00
In my demo environment,
00:00
I currently have a Linux machine that has
00:00
the following applications installed
00:00
: It has Git installed,
00:00
and if you're not familiar with how to install Git,
00:00
I'm using Ubuntu Linux AD command
00:00
that you can use to install Git,
00:00
and that you can use to verify if it's installed.
00:00
I have Docker installed on this Ubuntu machine.
00:00
I have Azure CLI installed,
00:00
and that's the command also to
00:00
install and verify the installation.
00:00
Finally, I have the kubectl installed,
00:00
and that's the command to install and verify that also.
00:00
What I'll be showing you in this very
00:00
first task is that I'll be
00:00
creating an Azure Container Registry instance.
00:00
Let's go to my Linux machine
00:00
where I'll show you how to do this.
00:00
I'm currently in my Linux machine here.
00:00
I'm not logged into Azure via Azure CLI,
00:00
so I needs to do that first of all.
00:00
I'll do az login.
00:00
It's going to give me a URL to go
00:00
to and put in the code to authenticate.
00:00
I'll copy the URL,
00:00
and I'll bring up a browser.
00:00
I'll go to the URL,
00:00
and I'll put in the code.
00:00
Because I'm already logged into
00:00
the Azure portal via the browser,
00:00
I can simply select
00:00
my current authenticated user
00:00
and that automatically authenticates me.
00:00
If I go back to the command line,
00:00
I should be authenticated now.
00:00
Excellent. Here are the commands that I'll
00:00
be using the complete this very First task.
00:00
First, I will be creating resource group
00:00
using az group create command.
00:00
I will be creating an Azure Container Registry
00:00
using az acr create command,
00:00
and then I will be logging into the registry.
00:00
Let's go ahead and run this three sets of commands.
00:00
That's done the first one,
00:00
and the second command,
00:00
and then finally the last command.
00:00
I can see here it says login succeeded.
00:00
That does not take long to create.
00:00
I think we're on the right track.
00:00
Let's move ahead to the next task.
00:00
In the next task, I will show you how to push
00:00
a container image into the Azure Container Registry.
00:00
Here's a visual representation
00:00
of what I'll be showing you.
00:00
Currently on my machine,
00:00
I have this image called Azure-vote-front image.
00:00
I'm going to be using the Docker push command to
00:00
push this image into the Azure Container Registry.
00:00
The first thing I need to do is I need to type the image.
00:00
But let's go ahead and do that first of all.
00:00
Back to the instructions that I'm following,
00:00
the first thing I need to do is I need to tag my image.
00:00
What I'll do is if I go back to my Linux machine,
00:00
let's clear the screen,
00:00
and if I do Docker images,
00:00
and you can see the image that I want to push.
00:00
You can see that it's currently as just the latest tag.
00:00
I need to tag it,
00:00
and I need to add information
00:00
about my Azure Container Registry in front of that.
00:00
Let's copy that command,
00:00
and let's go run it.
00:00
Having run that, let's verify again.
00:00
Now I can see my tagged image over here.
00:00
So just creates a copy and then tags it.
00:00
The next thing that I'll do is, I'll be pushing
00:00
the image into the registry.
00:00
For you to do this, make sure you're logged into
00:00
your Azure subscription using
00:00
the az login command, which have done earlier.
00:00
Let go ahead quiet and copy that command.
00:00
Let's paste that there,
00:00
and let's run that.
00:00
We can see that it's doing a few things.
00:00
So that's completed now.
00:00
Let's go ahead and verify if
00:00
the image now exist in the registry.
00:00
Again, I'll clear the screen,
00:00
and I'll paste that command.
00:00
If I run that, I can see that
00:00
my image now exist in the Azure Container Registry.
00:00
If I want to see information about
00:00
the tag and the version,
00:00
I can go ahead and use
00:00
these commands to see the tags for the specific image.
00:00
I can see that that's version 1.
00:00
In the next task, I'll show you how to create
00:00
an Azure Kubernetes Service cluster using AZ CLI.
00:00
To do this, it's actually
00:00
a simple command that I'll be using to do this.
00:00
Just that command will create the cluster.
00:00
I'm using the az aks create command,
00:00
specifying the resource group,
00:00
the name of the cluster that I want to create,
00:00
how many nodes do I want to exist in the cluster,
00:00
I'm specifying to automatically generate a SSH key,
00:00
and also I want to give this cluster permission to
00:00
my Azure Container Registry instance
00:00
because the cluster needs
00:00
to be able to pull images down from that registry.
00:00
I'll show you the permission that is
00:00
going to automatically set
00:00
up because of this parameter that I'm attaching.
00:00
Let's go ahead and copy and run this command.
00:00
It's currently creating our Azure AKS cluster.
00:00
Now I'll take a few minutes to complete,
00:00
so I'll go ahead and pause the recording.
00:00
After it's completed successfully,
00:00
I'll resume the recording,
00:00
and then we can go to the rest of the tasks.
00:00
The deployment of the AKS cluster completed successfully.
00:00
What I'll do is I'll go to
00:00
the Azure portal to show you a few things that happened.
00:00
If I go under Resource groups,
00:00
the resource group that I created
00:00
for the cluster is the resource group here.
00:00
If I quiet and click on that,
00:00
you can see that I have my Kubernetes Service
00:00
and I also have my Container Registry here.
00:00
If I click on the "Kubernetes Service"
00:00
and if I go on the Node pool,
00:00
you can see that I have a single node pool,
00:00
which is Linux-based,
00:00
and I have node count of two,
00:00
and you can see the size that I specified.
00:00
Also if I go to
00:00
my Container Registry that I created earlier,
00:00
if I go under
00:00
the Access control and I go under Role assignments,
00:00
you'll notice that it automatically given
00:00
permissions to my AKS cluster
00:00
for this Container Registry.
00:00
It's giving it the role to be able to pull images
00:00
directly from this registry. That's good.
00:00
Here's a visual representation of what I just did.
00:00
I just create a Kubernetes cluster
00:00
with two working nodes in it.
00:00
In next task, what I'll be doing is I'll be
00:00
connecting to my AKS cluster using kubectl,
00:00
which is a Kubernetes 2 that we
00:00
can use for managing Kubernetes clusters.
00:00
If kubectl is not currently
00:00
installed on your Linux machine,
00:00
you can install it in this command here.
00:00
I already have it installed,
00:00
but there's no harm in running it again.
00:00
Let's go ahead and run that.
00:00
Let's clear the screen again,
00:00
and I'll go ahead and paste that, and I'll run that.
00:00
That's executed successfully.
00:00
I just need to ensure that I have
00:00
this path in my search path.
00:00
>> Now I need to connect my aks cluster using kubectl,
00:00
and to do that I'll use
00:00
the az aks get credentials command.
00:00
I'll specify the name of
00:00
my resource group and the name of my aks cluster.
00:00
Let's go ahead and run that,
00:00
and let's go ahead and execute that.
00:00
You can see that it's currently
00:00
created a kube config file.
00:00
That's looking good. Let's go ahead and
00:00
verify some information about our cluster.
00:00
I want kubectl get node.
00:00
If I run that,
00:00
>> I can see the two nodes that I have in my cluster.
00:00
>> I run that same command but with
00:00
cluster info and it's giving me information on
00:00
about my cluster. That looks good.
00:00
It looks as if I'm connected successfully to
00:00
my aks cluster using kubectl.
00:00
By the way, I'm using kubectl
00:00
and kube cuttle interchangeably.
00:00
Here's a visual representation of what I just did.
00:00
I just connected to
00:00
my Kubernetes cluster using kube cuttle, called kubectl.
00:00
The next thing that I'll be showing
00:00
you is the deployment of
00:00
a container image from
00:00
our Azure Container Registry to aks.
00:00
Here's a visual representation
00:00
of what I'll be showing you.
00:00
Now, I'll be doing this deployment using
00:00
something called a Kubernetes manifest file.
00:00
This exists locally on my machine.
00:00
I'm connected to my Kubernetes cluster using kube cuttle.
00:00
I'll be providing the Kubernetes manifest file,
00:00
which contains information about
00:00
the container image to use and we're to grab it from,
00:00
and I'll be providing that to my Kubernetes cluster,
00:00
which would then go to
00:00
my registry and grab the necessary image,
00:00
and then deploys it on
00:00
my worker nodes within the cluster.
00:00
Let's go ahead and do this.
00:00
Here I am on a Linux machine.
00:00
If I do vim and I have my Kubernetes manifest file,
00:00
if I go ahead and open that file.
00:00
If I scroll down a bit and just to look
00:00
at some information contained
00:00
in these Kubernetes manifest file,
00:00
the main thing that I want to modify here is I want to
00:00
modify the location that
00:00
it's going to be pulling the image from.
00:00
Rather than pulling the image from Docker Hub,
00:00
what I want to do is I wanted to pull the image
00:00
directly from my private Azure Container Registry.
00:00
I need to put the prefix there of
00:00
my container registry login server name.
00:00
I can get the login server name by going to
00:00
my Container Registry, going under overview.
00:00
I have the login server there.
00:00
Let's copy that and let's paste that there.
00:00
If I go ahead and save this Kubernetes manifest file,
00:00
then I'll go ahead and deploy the manifest file.
00:00
Once I provide this to my Kubernetes cluster,
00:00
it's going to grab
00:00
the necessary image and then it's going to
00:00
deploy the images as container pods within the cluster.
00:00
Looks as if nothing happened because that was very quick.
00:00
It's just saying it's created certain services.
00:00
Let's go ahead and verify.
00:00
What I can do is I can use this command line
00:00
kubectl get service to
00:00
watch for this service because the service,
00:00
the way I've described it,
00:00
needs to have a public IP address
00:00
so I can reach it so I can
00:00
monitor when all the necessary resources are provisioned,
00:00
including the public IP address.
00:00
If I go ahead and run that,
00:00
you can see that it's currently pending.
00:00
I'll just go ahead and pause
00:00
the recording and wait for this to complete.
00:00
Once I have an external IP,
00:00
we can verify it and we can get to
00:00
these Azure vote front-end service
00:00
directly from the Internet.
00:00
As you can see here, I have my external IP address.
00:00
Let's go ahead and copy that.
00:00
You can see I can get to the service.
00:00
Excellent, this is looking good.
00:00
The next thing that I'll be showing you is
00:00
the scaling of the pods in the aks cluster.
00:00
To verify the current deployments that I have,
00:00
I can use this command to verify
00:00
that, kubectl get deployment.
00:00
To verify the pods that are deployed,
00:00
I can use kubectl get pods.
00:00
Let's go ahead and run both. Let's copy that.
00:00
Let's go to our Linux machine and let's paste that.
00:00
I can say I have two deployments,
00:00
the Azure vote back-end and the front-end.
00:00
The front end is what I'm mainly concerned about.
00:00
If I do kubectl get pods,
00:00
I can see that I have
00:00
a pod deployed for each of the services,
00:00
one font and one for the back-end.
00:00
What I want to do is I want to scale
00:00
this front-end to be five pods instead of one.
00:00
To do that, I'll be using this command
00:00
here, kubectl scale replicas.
00:00
I can specify the number of replicas that I want.
00:00
In this case, I'll actually scale it to four, not five.
00:00
I'll specify the name of
00:00
the deployment that I want to scale.
00:00
Let's go ahead and copy that.
00:00
If I paste that.
00:00
It said it's scaled.
00:00
Let's verify by using our kubectl get pods.
00:00
You can see that it's currently
00:00
creating more containers for this service.
00:00
I have the front end,
00:00
I now have four instances of that.
00:00
In the final task,
00:00
what I'll be showing you is how to scale
00:00
the aks cluster nodes.
00:00
The visual representation of what I'll
00:00
be showing you will
00:00
be using Azure CLI in this case,
00:00
to add an extra worker node to my Kubernetes cluster.
00:00
That may be something that I want to do if I'm getting
00:00
resource allocation issues due
00:00
to the amount of
00:00
workloads that my cluster is currently handling.
00:00
Let's go ahead and see how to do that.
00:00
Here are the commands that I need to do.
00:00
I can use kubectl get nodes
00:00
to get the current number of nodes that I have.
00:00
But then I will needs to use the az aks scale command,
00:00
specify my resource group name and my aks cluster name,
00:00
and the number of node counts that I want.
00:00
I'll copy that command.
00:00
Go to my Linux machine.
00:00
Let's clear the screen again and I will
00:00
use kubectl get nodes.
00:00
I can say I currently have two nodes.
00:00
Let's run that command to make them three.
00:00
That will take a little while
00:00
to complete because it's going
00:00
to spin up an extra node for us.
00:00
Once it's completed, I'll go ahead and
00:00
use the kubectl get
00:00
node command to verify that now have three nodes.
00:00
That looks to have completed successfully now.
00:00
Let's clear the screen and let's run the command again.
00:00
Now you can see that I have
00:00
>> three nodes in this cluster.
00:00
>> That brings me to the end of this demonstration.
00:00
I hope you found it useful.
00:00
Thanks very much for watching,
00:00
and I'll see you in the next lesson.
Up Next