And here we can get started
with creating a cluster
because, keep in mind, the cluster is what we need
to create on our own.
The things that run on the cluster,
the pods and the containers, that's managed by Kubernetes.
But the infrastructure, the network,
all of that needs to be created by us,
though the EKS service will actually make that a breeze.
Now, it all starts with giving that cluster a name,
and I will simply name it kub-dep-demo
for Kubernetes Deployment Demo,
but, of course, this name is up to you.
Now, once you chose a name, click Next step.
And here on this page, you can now configure
some general things about your cluster.
For example, the Kubernetes version,
for me at the moment, the latest version I can pick is 1.17,
so that's the version I will go with.
And the next thing you need to pick here
is the Cluster Service Role.
Now, to understand this, you have to understand
how AWS, and actually most cloud providers, works.
AWS is powerful, and you got a bunch of services here.
And these services can also work together.
For example, EKS, behind the scenes,
will create some EC2 instances.
EC2 is that service
which allows you to launch these virtual instances,
these remote computers in the end,
and EKS will use that service under the hood.
The idea with EKS
just is that you don't have to do this on your own,
but that instead, it's managed for you.
And in order to allow EKS
to create other resources on your behalf,
you need to give it appropriate permissions.
And you do that with another AWS service
which allows you to manage permissions, the IAM service,
which stands for Identity and Access Management.
Here, you can configure various roles
which you then can assign to users or other services,
in the end controlling what these users and services can do.
And here, we wanna create a role for the EKS service,
giving that service certain permissions
to do something on our behalf.
That's the idea here.
So therefore, here on the IAM Console,
which I opened in a new tab, you wanna create a new role.
And here, make sure AWS service is selected.
Scroll down to EKS.
You can also, of course, simply search for that on the page.
Click on EKS and then choose EKS Cluster.
This will gie you a predefined role,
which is predefined for EKS
to give EKS all the permissions it needs.
Simply click Next Permissions with that selected
and confirm this page without any changes.
You can add tags here,
which are not important though, so we will just continue.
Review this and give this a name.
And I will name it eksClusterRole.
But this name is totally up to you.
You just need to give some name to your role.
Once you chose a name, click Create role,
and this will now create such a role.
Now, you see I already got a bunch of roles.
Of course, you probably have less roles than that,
but you now got this very important EKS role.
With that created,
go back to the EKS cluster configuration page here.
And on Select role, click that refresh icon
and then select the role you just created.
Now, with that, you can leave all the other defaults
and click on Next.
As a next step, we now need to set up or configure
the network for this cluster.
So the network to which all these nodes,
the remote machines, will be added.
And, of course, this network needs to be created
such that to some extent, it is accessible from outside,
so from the world wide web,
and to some extent it's only accessible from inside
so that protected network
internal communication is possible,
but at the same time, it's possible to send requests
from the outside world into that cluster.
Now, to create such a network,
you could use this VPC Console,
but actually click on Services here at the top
and search for cloud formation
and open this in a new tab.
You can close the IAM tab by the way.
CloudFormation is a service
which allows you to easily create things with other services
based on certain templates.
Simply click on Create stack here, leave all the defaults.
And then here, you need to paste in a certain URL,
which you find on the attached page.
Attached to this lecture, you find a link to this page,
and here you will find this URL.
Copy that URL
and paste that here into this box,
and then click Next.
And this simply contains a template
for the network which you wanna create.
So click Next, leave all these parameters,
just give this stack a name, for example, eksVpc,
and click Next.
You can add tags, but you don't need to.
You can leave all the other defaults here as they are.
You don't need to fill anything out here, and click Next.
And then at the end here, click Create stack.
And this will now create such a VPC network for you,
which can take a short while.
But actually even before this finish,
you can close this page, it will continue nonetheless,
and then go to your Cluster page again,
click this refresh icon,
and now select the newly created VPC here
with that name you assigned.
Leave all the other defaults here as they are.
And for Cluster endpoint access, choose Public and private
because we wanna create a cluster which is both able
to handle incoming requests from the outside world
as well as have protected traffic inside of the cluster.
So, node-to-node or pods-to-pods traffic
should be inside of the cluster
and not go out of the cluster back into it.
And at the same time, of course,
we want to have certain endpoints
which should be reachable from outside.
So let's go for Public and private here, and click Next.
You don't need to enable anything here,
but if you want extra logging, you can, of course, do that.
Click Next again, and now review all your settings,
and if you're happy, click Create.
And this will now create such EKS cluster,
so a Kubernetes Cluster with help of EKS.
And for the moment,
it will set up the network and all these things.
As a next step, we're going to add nodes.
We're going to add the remote machines
on which the Kubernetes software is installed, so to say,
and on which we then, of course, all can run our pods.
So let's wait for this cluster creation to finish,
which can take a couple of minutes actually.
Now, actually, whilst this is still creating,
we can already work on something else
and keep that running in the background.
Remember that kubectl command? Of course, you do.
We use it all the time
to, in the end, send commands to our cluster.
And at the moment, we're doing this with minikube.
When I run kubectl apply,
and I wanna apply a certain configuration,
this command is sent to the minikube cluster.
Now, soon, we wanna send this to our EKS cluster instead.
And you might wonder anyways,
how does kubectl know that we wanna talk to minikube?
Well, the cost- of a certain file,
which you find in your User folder,
both on macOS as well as Windows.
In your User folder on both operating systems,
you will find a .kube folder.
And make sure you're able to see hidden folders and files.
Otherwise, this folder might not show up.
So you have this .kube folder,
and in there, you'll have a config file.
You can open this with any text editor,
on Windows with Notepad, for example.
And this is a configuration file
which will be used by the kubectl command.
And at the moment, it holds information
which allows kubectl to connect to the minikube cluster
which runs in a virtual machine.
Now, that was nice up to this point, that is what we needed,
but, of course, now that will change.
Now, we wanna change this file
such that it's able to talk to our EKS cluster
once that is set up.
So therefore, I would recommend
that you just copy this file for the moment and save a copy,
maybe named config.minikube,
so that you can always easily go back
if you wanna talk to minikube again,
because now we're going to override the original config file
with a config file that allows us to communicate with EKS.
Now, to override it, the easiest way of doing that
is to use a certain tool which AWS offers,
the AWS Command Line Interface.
And you can simply search for AWS CLI to find that tool.
Now, that's a tool which allows you to run commands
from inside the command line on your local machine
against your AWS account.
For that, you need to download and install it,
and there's a Windows installer available,
and a MacOS installer, and an installer for Linux.
And I will, of course, use the MacOS installer,
but you should, of course, use the one
appropriate for your operating system.
And it's a straightforward installer
which gets downloaded here
through which you can simply walk
by confirming all the defaults.
And in the end, this will then set up
this command line interface tool on your machine.
So make sure you install that tool on your machine.
And once it is installed on your local machine,
you will be able to use that.
Now, actually, in order to be able to use that,
we need to go back to AWS
and then click on your account name
in the top-right corner
and go to My Security Credentials, open that in a new tab,
and here go to Access Keys.
This is an access key which you will need,
if with the AWS CLI, in order to be able to run commands
against this AWS account.
So create a new access key here
and download the key file this gives you.
Save it anywhere and make sure you don't lose it.
You can create a new one
and delete the existing one if you do,
but it's better to not lose it in the first place.
Now this file which you got there,
that's a file you can open with any text editor,
for example, also with Visual Studio Code,
by simply dragging and dropping it into that file.
And here, you'll find an AccessKeyId and an AWSSecretKey,
and we will need both
because now you should run aws configure
to connect the AWS CLI, which we installed,
to your account, your AWS account,
so that it's able to successfully run commands
in that account.
So just run aws configure,
and then enter your Access Key ID here
and hit Enter.
Enter your AWS Secret Key thereafter,
copy and paste it from that CSV file which you downloaded,
enter it here and hit Enter.
Enter your default region name, which could be us-east-1.
This concept of region is a key concept in AWS.
You can select a region up here in the right corner.
And services are available in different regions.
And, for example, here I set up my EKS cluster in the Ohio,
the us-east-2 region,
and therefore, actually, that is the region
I am going to pick here.
Hit Enter, and you don't need to enter anything here
for the fourth option, and hit Enter again.
Now, the AWS CLI is configured
such that it can talk to your AWS account
and do things for you.
And we need that because we need to run one specific command
for which we need this cluster to be active though.
So make sure you wait until it is active
and until it is done being created.
Once that is the case, once your cluster is up and running,
use the AWS CLI
and enter aws, whitespace, eks
to do something with the EKS service, --region,
and now ensure you pick the region you have here
in the top-right corner for your running cluster,
so in my case, us-east-2,
and enter this here.
Make sure you have no typo.
And then run the update-kubeconfig command,
and then --name, and then your cluster name,
so in my case, that's kub-dep-demo,
the cluster name you chose earlier.
And what this will do
is it will update this kube config file here
with all the data it needs for kubectl
to talk to your AWS cluster instead of minikube.
So hit Enter after you save
your original minikube configuration file.
And if you would now inspect this config file again
with a text editor, you would notice
that there's a lot of AWS-specific data in there.
And indeed now, if you run kubectl get pods,
this will do the same as it did before,
but it will actually talk to your AWS cluster
and not to the minikube cluster.
Indeed, you can now run minikube delete,
and it deletes that minikube cluster
and you would still be able to run kubectl get pods,
because this now executes
in your AWS-managed EKS cluster,
and that's, of course, great and an important step.