Implementing Kubernetes: Best Practices For Getting It Right

21 October 2021 by Tennis Smith

Congratulations, after much pain and effort you finally have Kubernetes working. You may even have it working in production. But how do you know you've done everything right? How can you be sure your environment reflects best practices and is completely secure?

Here are just a few of the many questions to ask yourself to make sure you're covering all of your bases.

Do your applications work and play well with others?

Kubernetes assumes you can start application components in any order, which is difficult to test. In another example, you may not know what to set for application CPU and memory limits (or if you should set them at all).

It may take running the Vertical Pod Autoscaler with 'recommendation' mode enabled so you can get recommendations from the profiler. Or maybe you'd rather set values for everything via the LimitRange parameter on your namespaces. 

Is your environment hackable? 

Then, there's the biggest worry of them all: Security.

Take ServiceAccount for example, by default it is auto-mounted into the file system of all Pods. Do you want that, or would you rather disable it and provide more granular policies? Similarly, Role-Based Access Control (RBAC) rules are difficult to set up. What RBAC design philosophy should you implement? Will it work for all your users?

Can you prove your Kubernetes is implemented correctly?

Where to begin if you want to ensure your implementation is a good one? 

First you’ll need to do an analysis of all your YAML configuration files (as well as Dockerfiles). Look for things such as containers running in privileged mode or anti-affinity rules being set incorrectly (again, this is just a small sample of the possible things to consider)

Then, you’ll need to do lots of displays via kubectl to get dynamic information like node status and resource quotas. Lastly, query the logs for errors on nodes, the control plane and general auditing. 

At each of the above steps, validate your findings with known best practices. 

An easy way to assess your risks

As early adopters of Kubernetes, and maintainers of kOps, we know all the places where Kubernetes implementation can fall down. On the strength of that knowledge, we've assembled a free 1-day assessment of your Kubernetes clusters to help you determine the relative robustness of your Kubernetes implementation. 

The assessment measures and mitigates your Kubernetes risks against the checklist of priorities identified in the current CIS Kubernetes Benchmark:

  • Master Node Configuration
    • Control Plane Components & Configuration
    • ETCD Datastore
    • Worker Node Kubelet Configuration
    • RBAC Policies
    • Pod Security
    • Default Network Policies
    • General Cluster Policies

After a single-day audit of your clusters carried out by one of our expert architects, you'll receive a PDF of the results along with actionable insights on how to harden your security posture.

By working together, we can ensure you have the best possible Kubernetes configuration.

Share this article

About the author

Picture of Tennis Smith

Tennis Smith

Technical Marketing Architect

Tennis has spent over 40 years in the business. Starting from a stint in the US Air Force he has worked in various capacities ranging from equipment installation, software QA, application development and DevOps. During his 30 years in Silicon Valley, he worked at numerous companies including Apple, Cisco, and Visa International. On the personal side, he has been married for 25 years, is an enthusiastic martial artist, and spends entirely too much money on his cats.

Related articles