Download Free Audio of Now, we'd want to deploy currency-conversion-servi... - Woord

Read Aloud the Text Content

This audio was created by Woord's Text to Speech service by content creators from all around the world.


Text Content or SSML code:

Now, we'd want to deploy currency-conversion-service and the currency-exchange-service to Kubernetes. What is the thing that we need to do? The first thing that we need to do is to build containers and push them out to the Docker registry. And one of the things that you would need to do over here is change the in28min in here to whatever your Docker ID is. You need to make this change in two places; one is in the currency-conversion-service/pom.xml and in the currency-exchange- service/pom.xml. Once you make those changes, you can go ahead and build the containers. So, the way we would build the containers is very simple, right? So, Run as Maven build, spring-boot: Oops! Let me get that right. build-image oops space -DskipTests, so, that's the command. Let me copy this so that I can run it on the other one and click Run and on the currency-exchange-service also, Run As Maven build and the goals. Now, I'd say Run again. So, the creation of the containers would happen in the background and in the meanwhile, what you would need to do is to go ahead and create your Docker Hub ID. So, if you don't have a Docker Hub ID, what I would recommend you to do is to go to hub.docker. com and register for an ID in here. Creating the account should be pretty simple. Enter the details in here and you should receive a email in your email box. Once you click the link in there, your account should be activated and whatever Docker ID which you create in here is what you need to enter in the pom.xml instead of in28min. So, you need to replace the in28min in here with that. And once you, and once you are all set with that, you can go in here and type in docker login. So, what we are doing in here is logging into the Docker. You can see that for me, it says Docker authenticating with existing credentials. If you don't have existing credentials, it would ask you for username and password. Make sure that you enter the Docker ID and the password that you have created in here, and then you'd be able to use your Docker account to push the container images that we are creating in here to the Docker Hub. Let's see if the images are built. The currency-conversion-service is in progress and same is the case with currency-exchange-service. So, let's wait for these to complete building. The currency-conversion-service is now built. I'll copy the Docker image of it and let's see if the other one is done, currency-exchange-service. Yep, that's done too. So, let's start with the currency-exchange-service. So, I'll copy the image ID for it and I'll go in to the same window where I have done docker login and I would say docker push and paste it in. So, in28min/mmv2-currency-exchange-service: 0.0.11-SNAPSHOT. Let's push this out to the Docker hub. You can see that the push is in progress. You can see that certain layers are already existing, so they'll be reused. All the new information, the new layers would be pushed out. So, it's in progress and it should be done very soon. It's pushing about 50 MB, so I don't think it should take more than 10, 15 seconds more. So, let's wait for that to complete. OK, this is pushed. That's awesome. OK, Cool. The docker push is now successful. So, I'm going to my Docker Hub path, so hub.docker.com/u/ my ID which is in28min, and once I go there, you can see that something is updated a few seconds ago and I go in there, mmv2-currency-exchange-service. You'd see a few tags. So, let's go to the tags. It's taking a little while to load and it loads up. So, this was what we created for Docker and this is what we are creating for Kubernetes. So, 0.0.11-SNAPSHOT is present in here for currency-exchange-service. Let's do the same thing for the currency-conversion-service as well. You can copy the image name from the logs. I'll directly type it in and say docker push and the push of this should take much faster. So, lot of reuse is there between this and the previous one. So, I guess the thing should go faster. So, it's pushing. Cool! It's already pushed. It took less than half the time that the initial push for currency-exchange took because most of the layers already exist. And the push is completed and let's now again go back to docker r/in28min and you should see currency-conversion-service in here. So, mmv2-currency-conversion-service, that looks cool and if you go to the tags, 0.0.11-SNAPSHOT. So, these look good. What we will be doing in the next few steps is playing around with these containers and deploying them to Kubernetes. I'll see you in the next step. 209 Welcome back. In the previous step, we created the container image for our Currency Exchange service. Let's try and deploy it right now. So, I'll copy the container image that we have created and pushed and let's go into our command prompt. I've already connected with the Google Cloud and I have already established connection with the Kubernetes cluster as well. And if I type in kubectl --version. Oops, it should be kubectl version. I can see the client version and the server version, so that's cool. Now, I would go ahead and say kubectl. We'd want to make a deployment. So, create deployment currency-exchange and --image is equal to the image that we have copied just now. So, in28min/mmv2-currency-exchange-service:0.0.11-SNAPSHOT. So, let's go ahead and create the deployment. In addition to the deployment, we would want to create a service as well. We'd want to expose it to the outside world. So, what we need to do is to say, expose deployment currency-exchange. The type of the deployment is load balancer, so --type=Load Balancer and we need to specify the port as well. So, the port on which we want to run Currency Exchang is 8000. Oops! There is a small change that I need to make in here. It should be t with a small t. So, --type=LoadBalancer --port=8000. Let's see if we get this right. So, let's see if these services launch up fine. So, kubectl get svc. So, the service is of type load balancer, the external IP is still pending. So, let's wait for it to get assigned. As you can see in here, I used a shortcut. So, svc is a shortcut for kubectl get service. So, instead of doing service or services, I can do a svc. And similarly with pods, instead of doing get pods, you can do a get po and similarly, instead of doing kubectl get replicaset, you can do a kubectl get rs. So, these are all the shortcuts you can use, but as long as you are new to Kubernetes, I would recommend you to use the full forms. So, use kubectl get replicaset, get pods, get services until you get completely familiar with them. Once you're familiar with them, then using shortcuts is awesome. And let's do a kubectl get all to see the status of everything that we have created. So, you can see the replica sets, pods, you can see the services, and I can see that the external IP is assigned. So, let's pick up this external IP. Now, I'd want to launch up Cloud Shell. If you are on Mac or Linux, then you can actually do the curl from your local machine itself. However, for people who are on Windows, they can launch up Cloud Shell so that they can get access to the terminal and they can launch commands from there. So, let's launch it up from here. So, I'll go into a full screen mode by clicking this and it would open it up in the new tab. I don't really want this, so I'll close this and use the one from the new window. Let's do a clear and this is where we can do a curl. Where do we need to do the curl to? So, this is the IP address, external IP which we got and I'll replace localhost in the currency-exchange URL with the external IP and curl to that. Let's see if this succeeds. Cool! I'm getting a response back, that looks awesome. So, I'm able to curl this. Now, what I would recommend you to do is to pause the video in here and try deploying the other one, the Currency Conversion as an exercise. Now, the commands to deploy Currency Conversion should be very, very similar. Right. So, all that I need to do is to say create deployment and go in here and I would need to change currency-exchange to currency-conversion and the image also we have created with the same tag. So, I just need to change exchange to conversion. So, make sure that you get this right. Typos can be costly in here. So, make sure that you get it absolutely right. The next thing I would need to do is to expose it out. So, expose deployment currency- conversion --type=LoadBalancer --port is equal to, this is one thing you should be careful about. We always expose our Currency Conversion on port 8100. So, let's go ahead and do that. Now, let's see the status. kubectl get service. What's happening with the service? The external IP is still pending. So, let's do a kubectl get service --watch. Let's wait for the external IP to be assigned. OK, the external IP is in here. So, it's 34.67.33.185 and let's go into the urls.txt and pick up the URL currency-conversion-feign one and replace localhost with this and fire a request. Let's do a curl to this. Awesome. I'm able to get the response back. There are a few interesting things that you would see in the response. There is a specific string that is being returned in the response and you can see v11 in the response as well. So, everything looks hunky dory. Now, there might be a couple of questions in your mind. Now, let's go back to our CurrencyConversionProxy. CurrencyConversion, oops, actually it's CurrencyExchangeProxy. Let's open that up, CurrencyExchangeProxy.