Kubernetes Best Practices — Season One
Kubernetes is complicated, and is getting more complicated each day. If you are getting started with Kubernetes or if you have been running it in production for a while, its hard to keep up with the rapid pace of development that’s going on. It’s even harder when you have a team of people building on Kubernetes, as you have to make sure each person is up-to-date and productive.
While there is a ton of content out there on the “Hello World” experience, using Kubernetes is a lot more involved that running a Deployment and exposing it with a Service. Kubernetes itself provides a blank slate where you can basically do whatever you want, but it can be really hard to know where to start!
With that in mind, I began working on a talk titled “Kubernetes Best Practices” (Here are the slides and video) based on questions and feedback I received from talking to everyday people out in the wild. This talk was so popular that I decided to deep dive into the individual topics. I ended up with seven episodes for this initial run (which is quite appropriate), and I really think they can help you and your team quickly ramp up on Kubernetes.
So here are all seven episodes for your viewing pleasure! I’m working on the next batch of videos right now, and would love your feedback on what you want to see. Leave a comment or send me a message on Twitter with your suggestions!
Season One Episodes
How and why to build small containers
Before you can use Kubernetes, you gotta build some containers. Docker makes it super easy to build containers, but this also means it is easy to build inefficient and insecure containers as well. Building smaller containers can be an easy way to get more from you Kubernetes cluster without a lot of work.
Organizing with Namespaces
Once you go beyond “hello world,” you will probably run into organizational issues when trying to manage your microservices running on Kubernetes. This gets even worse when your team(s) grow and you need more visibility and control. Namespaces provide a powerful way to manage resources in Kubernetes, and provide the foundation for policies and management.
Health checks with readiness and liveness probes
Health checks are required to create robust and reliable services. While Kubernetes has default built in health checks, they can be insufficient for many apps. Readiness and Liveness probes give you the power to easily customize these health checks for your applications.
Resource requests and limits
Memory leaks, infinite loops, bad actors, over-provisioning, oh my! Kubernetes gives you a powerful platform to run your services, but if you don’t define rules around resources, eventually you are going to be in for a bad time. Thankfully, Kubernetes gives you a lot of control over resources and how they are used.
Terminating with grace
Pods and Containers in Kubernetes need to deal with termination gracefully. Kubernetes can decide to terminate a perfectly healthy Pod for a variety for reasons, and shutting down cleanly is key to providing your users with a good experience.
Mapping external services
Chances are you have services that live outside your Kubernetes cluster. Some of them may be 3rd party services, and others might be services that your team or company run. Regardless, living in the hybrid world brings its complications. Kubernetes gives you the power to map these external services to make them look and feel like native Kubernetes services, making it easier to bridge the gap between worlds.
Upgrading your clusters with zero downtime
One of the most important things you need to do is keep your cluster up to date. Using managed services like GKE can make this a lot easier, but there are still methods you can use to make the upgrade process smoother.
Thanks to all the folks that made this possible, from people who reviewed the content to the video and blog editing teams who made this series a reality!