New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Camron G. Levanger: Deploying and Managing Swarm with Kubernetes | Swarm Orange Summit Madrid 2019

SwarmWed, Oct 9, 2019, 12:00 AM

Camron G. Levanger: Deploying and Managing Swarm with Kubernetes Perhaps the most important aspect to realizing a permissionless and censorship-resistant network is decentralization. At Mainframe we have always tried to find new ways to make it easier not just to develop on Swarm, but also contribute back to the network. Kubernetes can make contributing nodes to the Swarm network far less daunting than it might seem at first. In this talk we will walk through setting up Kubernetes on AWS, as well as some of the finer points of getting your Swarm nodes running smooth. Logging, metrics, fault tolerance, and CI/CD will also be covered. In addition to the walk through, open source versions of infrastructure automation for your AWS resources will also be provided. About Camron Camron is a blockchain/decentralization enthusiast and advocate. Currently working as a Senior Architect at Mainframe. A professional musician, competitive marksman, and avid outdoorsman. Well versed in communications and telephony, Camron was focused for many years on high-volume systems performance, building systems capable of handling billions of transactions per day in real-time. Eventually moving into systems architectures and managing devops teams at various start up ventures, Camron brings unique real-world experience to the decentralized space.

Transcript

so my name's Cameron I work with mainframe I work out of our Salt Lake City office we try to work very closely with a swarm team and we have for quite a while now so when I first joined mainframe one of the first things that I was tasked with was making it making it a little bit easier for the developers you know we built a platform for building def so we try to make it easier to build apps and we used swarm as a back-end for that platform and when we would hire on you know JavaScript and front-end developers it would be you know fairly hard for them to kind of come up to speed and be able to run swarm and get things running us so I was tasked with not only trying to make it easier for our new developers to just be able to use swarm without you know too much ramp up time and through the process of working on that we decided that we would really like to contribute something back to swarm and we decided to do that in the form of providing a bunch of swarm nosed contributing to the network and so we we provide some some fairly beefy instances and those instances are included in the boot nodes so they're there in the codebase there in the swarm boot nodes but we also do set up very similar to what Anton just presented where we're doing containerized kubernetes to swarm deployments mm-hmm and when I saw the schedule and I saw that I was presenting after Anton and maybe presenting the exact same thing as Anton I tried to make this a little bit fluid so it won't be the same stuff so what I'm gonna focus on is just trying to walk you through and help you understand how you could also use the helm charts that Anton is built and deploys one nodes and contribute back to the network yourself if that's something you can do so we're just going to cover the tools we're using which are very very similar to to what Anton is doing we may or may not need to cover why infrastructure as code is a good thing I think everybody in here understands that we are using if we take a step back from what Anton just presented so before kubernetes comes into the picture we're using a tool called terraform I don't know if you're familiar with it it's a tool built by Hoshi Corp and it essentially allows you to automate your infrastructure so you know in the in the good old days you would have actual people racking servers and setting things up and there was not a lot of automation in the hardware space right you know cloud providers changed that a little bit and taking it a step further we're describing all of our resources just in configuration files and using terraform to spin those up so we really have almost zero you know human intervention in deploying a set of swarm notes so we'll just cover terraform help you you know learn how to set up helm and tiller in a fairly secure default manner and then installing the helm charts that are built by the swarm team here so first of all you're going to need terraform it's free the AWS CLI if you don't already have that just a command line tool that allows you to programmatically access your AWS you need cube control elm and tiller and that's it I already covered what terraform is and actually I'm going to show you a little bit what that looks like so terraform just uses a JSON like structure they're just using HCl to describe their own configuration language error form also supports JSON just natively like you can describe this in pure JSON if you really want to and we're using AWS but terraform is provider agnostic so whatever cloud provider you're using even if you're using custom in-house solution of some kind terraform will allow you to automate all of your infrastructure and you just describe it in these files if you look here depending on how familiar you are with AWS we're doing everything from setting up eks which is Amazon's managed kubernetes to describing all of the roles and the policies the auto-scaling groups everything I do absolutely nothing manual to spin up any of these form clusters terraform is really easy to learn our terraform files here are open source you can find them at the mainframe HQ github account so you could check out this repo and all of our terraform setup is in this repo as well as our own helm charts before you know Anton was finished with the the kubernetes stuff first swarm we had also built this before that was open sourced and ready I have since actually started trying to migrate over to use what Anton has provided and so we're sort of in the middle of that process we do have a few slightly different things I wouldn't recommend you actually use our helm charts in here I would recommend using Anton's but you could use this terraform stuff to spin up everything you need to deploy the helm charts that are provided by the swarm team and so you just describe all the resources you need and then it takes a while for AWS to actually like provision eks and provision auto-scaling groups and stuff so I just kicked off one I started spinning up the infrastructure I think in Paris and let's find out how close it got to being done well it failed but this is what it looks like if it doesn't fail so you'll just run terraform plan there's two main commands in terraform terraform plan which will create an execution plan and basically do a dry run so it'll spit out exactly what's going to happen what it's going to do to your AWS instances and after that you can run terraforming plot and you don't have to run plan like you can just run terraform apply it'll create the plan it'll run it and it spits out you know just all the information it tells you what it's doing like right here it's saying I'm creating your security groups and after you know ten fifteen minutes you'll actually have the infrastructure you need to use kubernetes and deploy the helm charts that are provided by the swarm team so feel free to check out that repo and use these terraform files to spin up your your resources that you need and I'm not gonna worry about who I fail and I think I may have already had things on the Paris instance so alright you need the AWS CLI most people probably already have that it's native there you need it configured it's not hard read the documentation kubernetes so we're using eks like i already mentioned you don't have to use AWS you don't have to use anything in particular you just need a kubernetes cluster somewhere eks makes it really simple takes a lot of the overhead away and then you just need cube control cube cube control is just the command-line interface that you run locally on your machine to interact with your kubernetes clusters helm which these guys covered pretty well helm it works with kubernetes and it allows you to it's a more powerful way to use kubernetes charts it allows templating it makes us see you can reuse a lot of the things you build you can think kind of like a application package manager for kubernetes so it's what makes it really simple for Anton to provide these helm charts and you can check out that repo and provide whatever values you need as inputs and just reuse that code it's just a great it's a great tool for infrastructure management the the other part of of helm is is a as a tool called tiller and tiller is the part of helm that basically manages your releases like it it manages the installations a lot of times you'll see and I think if you read through like the default documentation for helm it it kind of has you set up tiller in your kubernetes cluster I don't recommend actually running tiller inside your computer in a DS cluster for security and role based access control reasons like that what I would suggest is whatever machine you're using to run your kubernetes commands run tiller there locally in its own namespace and that'll that'll allow you to give you no different access to different secrets and it also secures that tiller server so to set up cube control for eks in the in the AWS CLI tools there is this command right here this is in our documentation or you these slides will be available but you're just going to run AWS eks update cube config and basically what that does is it creates your local cube config file and that is telling your local cube control where your cluster is and how to get access to it this command right here just automates that you don't have to monkey around with it too much that will set you up and give you access to the AWS resources you just created using terraform then you run the terraform plan which will do the dry run show you any errors you might have like I just had and then terraform apply actually runs it creates the AWS resources one more thing that I kind of automated is the config map which is just just some direct for kubernetes and AWS just telling all of your like your worker notes and everything it allows them to actually communicate on that network on that VPC so in our terraform files you'll find this config mac AWS auth directive and if you just run terraform output it will actually spit out the yam all you need for you which you can then use cube control to send up to the cluster using cube control apply and that's going to make it so everything that you have deployed it for the kubernetes resources well they'll start you can actually watch them nessus other command i've set here the git nodes watch you can actually sit and watch all the notes actually start communicating and and join and you'll know that everything is working out for you helm and tiller Anaya negated like into the deep details that's not necessarily about how to use kubernetes as much as it is how you can contribute to swarm if you're on Mac kubernetes helm exists in brew and here this is what I was talking about running a more secure tiller providing the different namespace by default tillers gonna deploy into the cube system namespace but that basically gives everyone admin access to any secrets that kubernetes is managing if you put it in its own namespace it allows you to to give individualized access to whatever secrets might be needed then since we're running this locally we're just going to tell tiller that is running in the tiller namespace so just export that put it in your batch file do it manually every time whatever you need to do and then I like to start tiller locally or on the jump box that is running cube control for us so we start it up and if we look I've got one running here somewhere this is tiller so I've got the tiller server running locally I'm sending the the logs just to standard out so I can watch things happen as I make changes as I apply changes so tillers running there just for purely for security purposes peace of mind and that's you know just my opinion then you want to helm just initializing helm and then one of the first things you'll usually want to do after you've first installed helm is just to update the repo and I don't have it in this slide but the next thing you would want to do is go and add the ether sphere helm charts so repo as well kind of covered this but don't run I really recommend not running tiller in your kubernetes cluster so if you're using the swarm provided helm charts you'll see that you need one of the commands you'll need to run as helm dependency update so when I first built our own kubernetes and and helm charts I was individually installing Yeager's so I would use a Jaeger helm chart and we were to install Jaeger and then I would install a graph on ax and so they were just kind of individualized steps I didn't include everything in the helm charts but these guys have actually added Jaeger and Griffin ax to ask dependencies to their helm char so you don't have any extra steps but you'll just check out their code run helm dependency update and it will install those other helm charts for you into that project and you'll see those when you look in your project so under your swarm here this is where any dependencies you have will show up and you'll see is it I've installed the the dependencies provided you've got your fauna in flux DB and Jager and so that's just giving your local helm the the tools it needs to deploy with kubernetes we deploy hours into you know just a different namespace we deploy everything in the namespace form but once you've run the terraform plan your resources are ready you've got the the swarm helm charts installed you've got their repo installed into helm all you have to do to run your your swarm cluster is helm install swarm cluster when you run that this is just the very beginning of what it's going to do in fact we can we can probably run this in like a live example so let's do it yeah all right so I already deleted this stuff so we're going to just do all right so we'll just run that command depending on how long the network takes we're gonna have a swarm cluster running here in just a second we'll come back to it though and then there's there's some great tube control tricks that will do all kinds of nice things for you including just SSH into any particular swarm node you deployed so I've just provided this here so once you've deployed it you can connect to a swarm node and see what you've got going on all right this will eventually finish and we'll look at it it's just having us a slow Network brawl from here and that is about it unless there are other questions so if you if you go check out our repo or follow through these slides every single step you need to take in order to to deploy an e KS cluster automatically just through automation and then use this form provided helm charts and run your own swarm cluster it's all there and when I talk to a lot of different people though they'll people get a little bit intimidated by kubernetes in particular and there is a little bit like of an initial learning curve with kubernetes and understanding what it does and how it works but once you get the hang of it and when you're using recipes like this and charts that are already built by the swarm team it really becomes you know a 20-minute project to actually deploy and run your own swarm notes with tracing and metrics which are great so I'm hoping that with Anton's work and with the tutorials and the terraform files that we've provided for you that more people will find it a lot easier to contribute back to the swarm network so we'll check back in on that deployment in just a second but if you have any questions I will try to answer them

Automatic transcript — names and jargon may be misspelled.