DevOps Interview Challenge - Run Redis on Kubernetes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi there that's your favorite divorcement of Vladimir here with another exciting interview challenge this time about radius this one comes straight from one of my Menses and for those of you who are unaware when I'm not busy doing my full-time job and not recording these videos for you I spent my time helping others to level up and Technologies like Cloud containers Automation and other sorts of nerdy style so if you're ready to join the pranks of elite and take your devops career to the new level go to my website that you see on your screen it's your devopsmanship.com fill out the form and learn how can I support you during your devops journey but first let's get down to business with this radius challenge so here is the task we need to create a web application that displays the message saying this is the visitor number X where X is a counter that is starting radius and incremented on each page PC we also need to create this SD Pipeline and architecture diagram but for this video I will exclusively focus on step 1. to run this application I will use the lightweight version of kubernetes called miniq it will create a virtual kubernetes cluster that runs directly on your laptop you can launch a mini Cube cluster just using one single common that's minicube start ideal option for the local development or if you're just getting started with kubernetes we will see our virtual Quest let's first create already deployment we can use the capacity GL create deployment column for that also we will use Google exposed to create a cluster IP service group serial exposed by default creates a service of type cluster ID this means the service will be available only from within kubernetes cluster so what we can do is use crib still portfolwork so we can establish connections from our laptop from our local cctl is running directly to within the cluster to Cluster IP services once we have port forward running we can use ready CLI to connect to localhost and in this request will be redirected to the deployment that is running within our kubernetes cluster now let me demonstrate to you how ready this works the radius is an in-memory key values in simple words it's database we can put a value to this database using this set command for example set my key that's the name of the key that will store the information and hello world that's a value that we will store and when we run get we can obtain the value that we previously stored also there is a concept of counter the encounter is created using the inker moment and every time we run in curves that stands for increment counter is increased by one and we can use get to obtain value of the counter as well let's open the code editor and create a simple web application that uses radius counter to count the number of visitors for this purpose I will use Python my favorite programming language first I will import the radius module and establish the connection to the radius cluster that I created previously then I'll create a class that will handle our incoming get requests manage get request it will send us a 200 Response Code implement the counter and send us the text response that contains the counter value it will listen on localhost on Port 88. let's close our radius prompt and instead run python script that we created when we open our local address on port 8080 we will see the web page when we update the page we can see the counter get incremented however for some reason for each refresh the counter is incremented two times that happens because on each browser request Chrome is making two actual get requests one is to obtain the document itself and another is to obtain the vicon.ico the favicon.co is a small thumbnail that you see in the corner of your browser tab to fix this we will add one more addition to our python call we will increment the counter only when Chrome is connecting to the document itself not to Fab icon let's restart our web application and now increments the counter correct way we can also check the counter using the radius CLI and obtain it using the get command next let's localize the application so we can run it into kubernetes as well our Docker file is extremely simple as usual it will use Python 3 as a base image it will install radius libraries using pip and it will copy main pi and run it during the container startup also small modification in our python script instead of localhost we will use the name of kubernetes servers for our radius cluster that is redis let's stop the execution of the web app locally and build the container there is one more trick we will run this eval command so we can build a Docker image directly within minicube so we don't have to push it to some public registry or configure registry authentication on the mini Cube cluster after the docker build is completed we don't need to push this image anywhere we can immediately start using it within mini Cube however there is one more thing that we need to change by default kubernetes is trying to always pull the image from the remote register this is causing the image pullback of error that you see on the screen to fix that we need to edit our deployment and change the image for Polish so if no present or never is set and it will reuse a local image that we previously create once the container is running we can expose it the same way we did for Reddit deployment and use port forward to connect it from our local machine when we check it from our web browser it is giving out the same counter if we stop or forwarding the service will no longer be available we can also for example delete our counter directly from redis and the next time we open our web page the number of the visits will be reset that's it for this video If you enjoyed it please support my effort by giving a like and subscribing thank you for watching and good luck
Info
Channel: Your DevOps Mentor
Views: 4,886
Rating: undefined out of 5
Keywords:
Id: DhD_0iLJw6c
Channel Id: undefined
Length: 6min 9sec (369 seconds)
Published: Mon Jan 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.