⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies

Friday, November 7, 2025

Deploying an ASP.NET Core 3.0 Web API on Kubernetes

 How to add Kubernetes files to describe your web API deployment using Visual Studio Code How to deploy your containerized ASP.NET Core Web API to Kubernetes 

0:00

welcome today I'll show you how to

0:03

deploy an SPL net cord 3-0 Web API on

0:06

kubernetes you will learn how to enable

0:09

a local kubernetes cluster in your box

0:11

how to generate cornetist files to

0:14

describe your asp.net core web api

0:16

deployment using visual studio code and

0:18

how to deploy your container eyes web

0:21

api to coordinate this to follow this

0:24

video step-by-step you will need a few

0:27

things first the hello a spinet core

0:30

docker image created in my previous

0:32

video continue rising a nice field net

0:34

cord to 0 web api

0:35

if you had not seen it already please go

0:38

through the steps on that one and then

0:40

come back second docker which we will

0:43

use to manage docker images in the dead

0:45

box and which also includes its

0:47

standalone kubernetes cluster where we

0:50

will be deploying the image third pieces

0:53

to the code which we will use to

0:55

generate and edit the require cornetist

0:57

files you could of course use any other

0:59

code editor that works best for you but

1:01

you might miss the code generation piece

1:03

and finally postman which is handy to

1:07

query our Web API once deployed on

1:09

coordinators again you're welcome to use

1:12

a browser instead for this if you prefer

1:14

or any other tool that better suits your

1:16

needs the first thing that you want to

1:19

do is make sure that dr. desktop is

1:21

running and that you can do very easily

1:24

by apena opening up the tray our icons

1:27

here and just looking at the docker

1:30

desktop icon you should say dr. Desktop

1:32

is running if that's the case then

1:34

Dugger is up and running now we're going

1:37

to open the project that we created in

1:40

the previous video where we have all the

1:42

files for this Web API that we're

1:44

working with and I just opened already a

1:47

terminal here and this terminal we're

1:49

just going to query for the creaminess

1:50

to make sure that we already have the

1:51

image that we'll be working with

1:53

so we'll do docker images and here Elise

1:59

hello a spinet core v1 is is there now

2:06

next step is to enable a do Canaries

2:10

cluster in our docker desktop

2:12

installation

2:14

to do that we're going to open a d'etre

2:17

icon right click on the docker icon

2:20

click settings go to the coordinators

2:23

tab here and then click on enable

2:26

kinetise apply click install and this

2:33

may take a while but this is going to

2:35

pretty much a download a bunch of

2:37

documents a for kubernetes into your box

2:40

and enable a very simple one node

2:44

cluster in the box that you can use to

2:48

start exercising all the canaries

2:50

functionality

2:54

when installation is complete we can go

2:58

ahead and close this and you should be

3:00

able to see that both docker and

3:02

coronaries are running in the box then

3:06

we'll just close this dialog here and

3:10

what you want to do now is making a make

3:12

sure that your communities a context is

3:16

it matches the docker desktop a cluster

3:19

that you have new box so to do that

3:21

there's a couple of ways one way is to

3:23

again open the tray icon right-click in

3:27

the kubernetes section here you should

3:30

see dr. desktop already selected there

3:35

and the other way is by using the cube

3:38

CTL tool so this tool comes installed

3:41

with a docker desktop so you should be

3:45

able to do cube CTL config get context

3:53

and that should bring up the docker

3:56

desktop context that we already saw in

3:59

the tray icon for some reason it will

4:01

display more than one dog or desktop

4:03

like this docker for desktop other one

4:05

here but it doesn't really matter the

4:07

one that we care about is already

4:08

pre-selected and it just for a little

4:11

bit of context is this khones context is

4:13

your logical grouping of your cluster

4:15

and a bunch of other related settings

4:17

and so they will change depending on

4:20

which cluster you're working wait so you

4:22

want to make sure that you're set in the

4:25

right cluster now if for any reason a

4:29

cube CTL the cube CTL tool is not found

4:32

in your box you just you may want to

4:34

just go ahead and in this case closed

4:36

wheels business to the code and reopen

4:38

it because it should be available in

4:40

your pad in your machine pad and if

4:43

you're using a just a common line you

4:45

may want to close it open it again and

4:47

kill steal should be there now in middle

4:49

to the code it's time to start creating

4:52

Java files to describe a do coordinating

4:55

artifacts that we're going to be using

4:56

to do that one thing that I can

4:59

recommend is to install the kubernetes

5:01

business to your call extension which

5:04

can generate this stuff for us so if you

5:07

have not done it already

5:08

go to the extensions hub look for quia

5:13

natus and the first result here should

5:16

be the extension that you want to

5:17

install so you just go ahead and install

5:19

it will take a few seconds and this will

5:22

enable a degeneration of a cone a DS

5:25

double files we close this now one thing

5:28

related to this and let me just clear up

5:31

is is that the communities

5:34

extension by default will also install

5:36

these other jumbled extension but as of

5:41

the the time when I'm recording this

5:44

video the younger the latest version of

5:46

this channel extension has a bug that

5:48

prevents the kubernetes extension from

5:51

being able to generate the gamma files

5:53

so to avoid that what you want to do is

5:55

make sure that you go back to version 0

5:58

for one of the devil extension and to do

6:01

that what you can do is just click in

6:03

the gear icon here he stole another

6:05

version and then you will pick the

6:07

version 0 for 1 and that will pretty

6:11

much fix the issue you may want to use

6:12

close and reopen business to the code if

6:14

you need it but then things should work

6:17

as expected and of course eventually the

6:19

Java extension will be fix it and you

6:20

will not need to do this additional step

6:23

now let's go to back to our files view

6:28

now what we want to do is add a new file

6:31

here that we're going to call deployment

6:35

that channel and this is these we're

6:40

going to use to describe the deployment

6:42

of our container into kubernetes and to

6:45

fill this file quickly we're going to

6:47

just type here deploy like I said this

6:51

is taking advantage of that kinetic

6:52

extension 4 vs code which pops up this

6:54

menu window here which we can click and

6:56

that initially is scaffold the template

7:01

for the kubernetes deployment so the

7:03

deployment is pretty much a static

7:05

description of what we want to obtain or

7:08

deploy into the coordinators cluster so

7:12

here first thing we're going to do is

7:14

provide a name for this deployment this

7:16

is how you identify the deployment let's

7:19

call it hello is the net

7:22

core deployment next into the we go into

7:28

the selector labels section and so what

7:32

happens here is that you have today you

7:34

have to describe a week Grenada spots

7:37

are going to be targeted a by this

7:40

deployment okay so the pots are really

7:44

the living beings or and the minimal

7:47

unit of deployment into coronaries and a

7:51

those are the ones are going to be going

7:54

to be created or destroyed over time in

7:57

the cluster according to what you have

7:59

defined it in the in the deployment

8:00

definition so the deployment is a static

8:05

view of what you want to obtain the the

8:07

pods are the living kind of the living

8:09

entities that actually enable your

8:13

deployment in grapes so first thing

8:16

we're going to give a a label for our

8:19

pots we're going to call it a call them

8:23

hello a spinet call pod okay so this is

8:28

the kind of the label that we will

8:30

assign to all our pots and we're going

8:32

to say is that our deployment shoot a

8:35

match the label hello a spinet call pot

8:38

that make sure that this equipment just

8:40

manages all those pots now coming down

8:45

we need to describe which is the

8:47

container containers that we want

8:48

including this in the in the pot we just

8:51

have one container we will name it here

8:54

just as hello asp net or container and

9:02

this is this kind of an identifier for

9:04

this container but now we have to divide

9:07

the actual image that needs to get

9:10

deployed there so this will match

9:11

exactly the image that we that we

9:15

created earlier okay so if you remember

9:18

if you just do in the terminal docker

9:21

images so that image could be and of

9:25

course there's a few more images here by

9:27

the way let me expand this a little bit

9:28

explain this

9:32

you can see yes we have the hello is

9:35

Bennett called image here and we have

9:37

the dotnet SDK and a spinet image here

9:41

but we also have a bunch of other images

9:42

these are the images that were

9:45

downloaded when we enabled the

9:47

coronaries cluster in the box and these

9:49

are the images that pretty much bring

9:51

coordinators into the box now we really

9:54

care about

9:55

hello a spinet call right now so that

9:57

same image we're going to use so let me

10:01

put it here and importantly we have to

10:05

specify the tag so in this case as you

10:09

remember tag is big one to load y usted

10:13

okay so that's a machine needs to get

10:16

deployed into this pot now keep keep

10:19

going down we have a couple of settings

10:22

here what we call the resource limit so

10:25

this makes sure to assign a few research

10:30

I mean machine resources to your

10:33

communities a containers so that they

10:35

don't try to take over more resources

10:38

than than what they should use right to

10:41

not take resources that some other

10:43

containers may want to or may need to

10:45

use so the two ones we have here is a

10:48

the memory and the CPU so in the case of

10:51

memory and by default we are getting 128

10:53

megabytes which is kind of similar to

10:57

megabytes and the other one here is a

11:02

500 a milli CPU which is kind of

11:07

equivalent to 0.5 CPU which just means

11:12

house of you basically so we're saying

11:15

that at a given time each container that

11:18

it has been up by this pot I mean each

11:22

container a that is part of any pot of

11:28

hello a spinet core pot will have 100 at

11:32

much 128 maybe right and a house of you

11:38

that that's a limit that they have

11:41

and finally we have to specify a deport

11:44

that the container is exposing okay then

11:50

and that's going to become the way to

11:52

get into the processes inside the pot

11:54

and in our case yours as well we created

11:56

the docker image that container port is

11:58

going to be hey okay now I'm going to

12:03

save this file and it's time to apply

12:08

these coordinates file so the command W

12:10

for this is cube CTL apply - F and then

12:17

we give the name of the file the

12:19

plumbing Channel

12:20

so hit enter and create so what this

12:25

does it is these create a deployment in

12:27

queries and spins of the creation of the

12:30

pots so if you do use ETL get deployment

12:35

you see we have our deployment here q

12:40

CTA hello eight-minute core deployment

12:42

and if we do cube CTO get pot we should

12:48

have one hello a spinet core deployment

12:52

and some some random grid this is the

12:55

pot and this is saying that a one of the

12:58

one containers in this pot are ready

13:03

which is good

13:04

status is running so everything is good

13:06

about this container the container is is

13:08

good to good to go and we can confirm

13:10

that it's really a alive let's say by

13:14

saying kill CTL logs and we will provide

13:19

the name of the pot and you can see it's

13:25

ringing of expected console output right

13:29

here now even when the container is

13:33

running inside the khones cluster this

13:36

is not enough for us to be able to query

13:39

the Web API that's inside that container

13:42

we need to bringing one more eco net is

13:45

a artifact or object that we call the

13:48

service so the service is a kind of a

13:50

logical grouping

13:52

of objects that allows you to that

13:55

allows a coordinators objects to

13:59

interact with each other and plus in

14:01

this case this is a we're going to

14:03

create what we call a load balancer

14:04

service which allows us to assign a

14:08

public IP as a public IP to a or DNS

14:14

name and to our to our pots right so

14:18

this is without this you will not be

14:20

able to reach the containers they are

14:23

pretty much alive in there but there's

14:25

no way to access them so to do this what

14:27

we're going to do is just again add a

14:29

new file we're going to call it a

14:32

service the channel and just as we did

14:36

before we're just going to type service

14:38

here if you like this and here so we

14:44

have folded the template for the service

14:46

and we're just going to start filling

14:48

the the values here so the first thing

14:52

some name for the service we'll call it

14:53

hello SP Nate core service so that's the

14:59

name service and then just as we did in

15:04

the other template would intensify a

15:05

which are going to be the parts that are

15:09

going to be targeted by this service

15:11

right so if you think of a load balancer

15:13

so it says okay so whenever this service

15:16

is reached this service will try to get

15:19

in touch with as many pots as are

15:20

available of some specific label so

15:25

going back to the pots the poor

15:27

definition here we know that the pot

15:30

label is hello a spinet core pot so

15:34

going back to service we will use that

15:36

as a selector in the service so it

15:40

doesn't matter how many pots we have

15:41

which we could have we will just have

15:43

one right now but we could have

15:44

multiples so the service will load

15:47

balance between all the pots that are

15:50

using this stack here and now this is

15:54

the external port that people will use

15:57

to query a a to query the service and

16:00

then target pour is that port that we

16:02

have specified on the deployment channel

16:05

which is internal

16:06

a container port so you'll have to go a

16:11

navigate to port 8080 and that will be

16:14

routed into port 80 on the pots that are

16:17

being targeted by the service finally we

16:21

had to add one little piece here which

16:23

is the type and because there's a few

16:28

types of services like you could have

16:30

services that just interact with each

16:32

other within the cluster without

16:34

exposing anything to the outside world

16:35

but in our case what we want to use is a

16:37

load balancer which instructs Canaries

16:42

to allow public access to the pots that

16:47

are behind the service okay so now going

16:53

back to the terminal

16:53

we're going to apply this service

16:55

channel there so let's say give CTL

16:58

apply service channel and the service

17:05

got created so if we say now you say QC

17:07

feel get services here is and we have

17:13

our new hello a spinet core service of

17:15

type load balancer and it has it does

17:20

have a glossary P this is kind of an

17:21

internal IP within the coordinators

17:23

cluster but more importantly for us its

17:26

external IP which is how we can access

17:28

it from the outside now of course since

17:30

the closer is just running in our box

17:32

there's no really a public IP involved

17:34

is just localhost

17:36

so now let's test it out let's see if we

17:40

can actually reach these clusters so

17:42

we'll go to go we're now going to go to

17:43

postman I'll create a new request and

17:47

here I'm going to a query for HTTP

17:54

localhost and then we said this country

17:57

port 8080 and then the alcohol with API

18:01

route which is weather for gas if I'm

18:07

not wrong so let's hit send and here it

18:13

is with

18:17

results from our coal toda Web API which

18:20

is now hosted in in cornetist if this

18:25

video was useful please consider hitting

18:27

the like button don't forget to hit

18:29

subscribe and another vacation bill to

18:31

know right away when I polish new videos

18:32

also please leave your comment below

18:35

with any talks about this video thanks

18:37

for watching see you next time

18:39

[Music]

 

No comments:

Post a Comment