Conf42 DevOps 2023 - Online

Set Up a “Production-Ready” Kubernetes Cluster in 10 Minutes

Video size:

Abstract

In this demo, we shall see how to set up a Production-Ready Kubernetes Cluster using an extendable framework built around Argo CD. With many cloud-native solutions popping up daily, it can be pretty daunting for engineers to select the right technology stack. So shall we make it easy for them?

Summary

  • Kubernetes Bootstrapper is an extendable framework to set up production grade kubernetes cluster. Project combines terraform and Argo CD to build an infrastructure automation and application delivery platform.
  • So let's head to our vs code. So you have the infrastructure directory and you have terraform. Click readme and give it a preview. It's going to spin up a Kubernetes cluster and then automatically install Argo CD. Once it's successfully done, you will have your cluster id in the terminal.
  • Argo is used to bootstrapping Kubernetes. There is a strict Gitops workflow here. Whatever is in git is going to be synchronized with your cluster. All that's remaining now is to install our observability stack.
  • Robusta is an open source Kubernetes monitoring automation platform. You also have Grafana dashboards and it also has seamless integration with slack. If anything goes wrong in your cluster, you get slack notifications.
  • Let's head back to our project. This is the end state of our architecture. It's really simple and straightforward to set up such can infrastructure. Do try it out. Give us a star. If you have some suggestions on adding different apps to it, let us know.

Transcript

This transcript was autogenerated. To make changes, submit a PR.
Hello everyone. In this video we're going to see this open source project that we built, Kubernetes Bootstrapper, an extendable framework to set up production grade kubernetes cluster. Before we head into the project, we'll just give you an overview of what is a production ready kubernetes stack. As you can see, I really like this for graphic from Cloudnative where in the center you have Kubernetes which is basically a framework, but you need all the other facets such as infrastructure, security, authentication, observability releases and deployments and development on a really high level. These are the facets that are needed to set up a production ready kubernetes cluster. But is it easy? If you look at the cloud native landscape, you really can't fit the whole landscape into a single page. There are so many applications and tools that are popping up in the cloud native world these days, so it can be quite daunting for engineers and organizations to pick and choose the right tool and to put everything together so that they work together as an integrated package in order to solve this problem. And that was like problem statement that we wanted to address with this open source framework that we're working on is how do people can quickly set up and integrate all these applications so that they can get day two operations ready, right? That's the birth of the Kubernetes bootstrapper. We've leveraged tools such as Terraform and Argo CD. For those of you who aren't aware of Terraform and Argo CD, Terraform is an open source infrastructure as code software that enables you to safely and predictably create, change and improve the infrastructure. Argo CD, on the other hand, is a Gitops continuous delivery tool for Kubernetes. It allows developers to declaratively manage the desired state of their Kubernetes applications and automatically synchronize that state with the actual state of the cluster. Terraform and Argo CD can help improve the development and deployment process for Kubernetes application by automating and standardizing the management of infrastructure and application resources, respectively. The bootstrapper project combines terraform and Argo CD to build an infrastructure automation and application delivery platform for Kubernetes. This project integrates popular open source applications. As you can see here, we have battle tested open source apps that have been integrated into this project. Being a flexible and extendable framework, it is really easy to add or disable applications into it. We've leveraged Argocd's app of app pattern to build this framework. So are you all excited? Let's head straight to the GitHub repository where I'm going to walk you through the repository, the workflow, and then we're going to get our hands dirty and spin up this bad boy. You can head to GitHub under Kubernetes KDEs bootstrapper. That's the project. So we expect minimum knowledge on Kubernetes and also familiarize yourself with tools such as terraform, because we're going to use terraform to spin up the infrastructure and then use Argo CD to spin up other components. Here's the overview of the repository. We have an Argo CD directory. We're going to keep the configurations of Argo CD that's optional. And you have the bootstrap directory where all the templates required. The bootstrap resources, which we'll go in detail, are stored docs directory for documents and other images and assets. The infrastructure directory where you have all the terraform modules to spin up your infrastructure on digitalocean. And you have the observability directory where we're going to use an open source tool called robusta to set up our observability stack. It's going to be like a three step process. First the infra and then bootstrap process, and then set up the observability stack. This is the end architecture that we aim to achieve. So let's head straight into our infrastructure directory terraform. And here you have all the terraform modules and all the instructions that you can copy, paste and modify a bit to set up this infrastructure. So what we're going to do now, we'll head to visual studio code where I've checked out this repository and we're going to perform the terraform commands, spin up this infrastructure, and then we'll come back to go ahead with the bootstrapper process and to set up the observability stack. So let's head to our vs code. So you have the infrastructure directory and you have terraform. Click readme and give it a preview. All right, I'm inside it. I'll just make sure I'm up to date. I'm right now going to head into infrastructure terraform. Okay, I'm going to perform terraform in it. I'm just going to follow along the guide. Awesome. So the bootstrapper TFRS sample file. Let's open that first. So it's the variables file here where we've defined the configurations of our infrastructure. You can change it and modify it however you deem fit. I have my own configurations here. Take a copy of this file, modify changes if need be, and then you're going to plan and then apply. Let's go back here. I already have the bootstrap TFRS file with me, so I'm just going to go ahead and copy this command. All right. Terraform throws out the entire plan for me. Pretty much what we saw in the figure. It's going to spin up a Kubernetes cluster, it's going to spin up a digitalocean container registry and then it's going to automatically install Argo CD as we saw here. Okay, I'm just going to go ahead and apply this, copy the command paste. It takes some time to set up your infrastructure. Once it's successfully done, you will have your cluster id in the terminal. So you could just update your kubecontext so that we can start accessing and observing our Kubernetes cluster. I'm using to go ahead and copy the cluster id. Going to paste it. Updated my kubecontext. So if I open canines, I should be seeing the Kubernetes cluster. Yes. Which has Argo CD installed. Awesome. So right now our infrastructure is ready and Argo CD has been installed successfully. Let's check out our next steps. All right, we are heading into the bootstrapper territory. The bootstrap process is not something new. It's been there. You could check out the documentation on how Argo CD suggests. So it's called cluster bootstrapping. So basically what this means is there is a parent app. In our case it's going to be the bootstrap and then you declare all the dependent child apps beneath it, which we will see right now. So what this means is Argo. And we ask Argo to go ahead and install the parent app. And once the parent app is installed, it goes ahead and starts installing all the child apps. The app of apps pattern can be structured in several ways and we've used helm to do so. That's why you see the helm structure in the repositories here as like any helm chart, right? We have a values file and in this values file, yaml, we set some flags that makes it easy for us to enable or disable the apps that we want. We have logging, we have observability. There is traffic, traffic is can controller and trivi is a security operator. So we can extendable or disable them here. And then if you enable them, arco picks it up and installs it. If you've disabled it, of course it won't. What you need to understand is there is a strict Gitops workflow here. What this means is ArcoCd that's installed in our Kubernetes cluster, right, is constantly looking at this repository, at the configurations, at the flags. If you want to make a change, if you want to extendable or disable the apps, you set the values in the file and you push the code to git to your branch that argo CD is looking into. Otherwise you will not have the end state reflected because you want to have all the configurations as code stored in Git. There are huge benefits for it. I don't want to go into details, but it's great for auditing. You have a clean track of who's committed what, and git being your source of truth. So whatever is in git is going to be synchronized with your cluster. So any changes you make to the values file, make sure or any file in this repository when you check out, make sure you push the changes to git so that Argo can do its magic. So I'm going to copy this and I'm assuming you have all the command line tools and clients installed that's needed. I'm going to go ahead and. All right, while it's getting installed, let's log into the argo CD UI and see what's happening. Since we installed Argo, Argo generates a default password. You can change it, let's grab it and then let's run this command. I'm just basically port forwarding it so that we can access it in localhost. There is also a section on how to configure it so that you can access Argo CdyR domain. Feel free to check that out as well. Open Argo here's your Argo UI. The default username is admin and we just generated got the password from the command. So this is the Argo UI. And here if you see you have the parent bootstrap project. So I'm clicking this and then the bootstrap project goes ahead and installs an application called Bootstrap Resources, which is going to be your ingress resource, your certificates, and you have your cert manager, it's installed. You have your metrics server, you have traffic as your ingress controller, and you have trivia operator as your runtime security operator. So you can see that the sync is okay, everything seems healthy. And all these components are now installed, which means if we head back to the git repository, right, let's head back to the bootstrapper project. All these apps here as you see, cert manager traffic, let's encrypt and your trivia runtime security app. All that's remaining now is to install our observability stack. So hope everything is clear. Up till now infrastructure automation done through terraform and then the bootstrapping process was done via CD. Now we're going to install our observability stack into Kubernetes. And now let's head to our observability stack setup using robusta robusta is an open source Kubernetes monitoring automation platform and it comes pre baked with Prometheus stack. You also have Grafana dashboards and it also has seamless integration with slack. So if anything goes wrong in your Kubernetes cluster, you get slack notifications. A huge shout out to these folks at Robusta. You need to set some things up in order to access the platform. Let's go ahead and do that. I'm going to head back to vs code and then we're going to do it from there. We're going to observe multistag readme. Right? Let's open a new session. You need to generate a configuration file once you've installed the robusta client. It's as simple as just type in robusta gen config and it takes you through an interactive session. So let's do that. Let's say yes to slack integration. Add to slack, you can configure your slack channels. I'm going to give allow and let's head back to our terminal. As it says, let's do observability no yes, asking me whether I want to install the cube prompt stack and I'm going to go ahead and say yes here. So now that's done, let's copy commands and update it. As you can see, it's now generated files called generated underscore values Yaml. So we're going to use that to install robusta. So let's do set cluster name equal to our cluster name. And while it's installing, let's head to our canines and see what's going on there. Okay, there are pods running. You have like cert manager and all other components installed. You have traffic, you have the trivia operator running, and if you check the charts it might take a while to so Argo CD chart has been installed and once I think robust has successfully installed, we'll see that in a minute. All right, as you can see, now that robusta is going ahead and installing Grafana, the Kuberom stack, Kuberom operator. So everything is being installed in the background. Once it's successfully installed, we'll be able to log in to a web UI where we can access the metrics of our Kubernetes cluster. So let's wait for that. Looks like robusta helm chart has been successfully deployed. We should be able to head to. So you have all our services here and we could monitor them. This is pretty neat. I'll leave it to you folks to explore robusta. So what's now happened is we have set up the observability stack onto our Kubernetes cluster. So this is the third step in our process. We also have the Grafana dashboards that can be accessed pretty much. So if I go into services, right, and should have let me expose it and access it now, Fana, that would be default? Would be, I think, admin and. Awesome. So you have some dashboard. So let's just click one of them. Look into August CD default. Yeah. Cool. So if we head back to our project, right? Yeah, I have my observability slack channel here. Yes. So it's configured. So if there's some warning or alerts, I'll receive the message here in this slack channel. Pretty neat. Let's head back to our project. Okay, so as you can see, we've done the infrastructure automation, we've done the bootstrapping using Argo, and we've set up the observability stack using robusta. This is the end state of our architecture, so you can see how it's really simple and straightforward to set up such can infrastructure, along with all the applications and configurations neatly packaged. So try out the bootstrapper, let us know what you think. If you have any questions, feel free to reach out to me on socials. I'm Diab and yeah, thanks. I hope you enjoyed it and we look forward to hearing your feedback. Do try it out. Give us a star, check it out. If you have some suggestions on adding different apps to it, let us know know. Thank you very much.
...

Abhimanyu Selvan

Senior Developer Advocate @ DigitalOcean

Abhimanyu Selvan's LinkedIn account Abhimanyu Selvan's twitter account



Awesome tech events for

Priority access to all content

Video hallway track

Community chat

Exclusive promotions and giveaways