Jan 16, 2019 IN Game Dev Talks
Lessons learned from deploying Kubernetes at Pixel Federation
By now you surely know that we at Pixel Federation are big fans of knowledge sharing and building smarter gamedev community. That's why we organize TechForce MeetUps, special events dedicated to hardcore programmers where we and experts from Amazon Web Services, WebSupport or Avast share knowledge and discuss hot devops topics. And Kubernets is one of them. So if you are hungry for some tips, check out this presentation and read on.
Here at Pixel Federation, we currently run our infrastructure on a privately hosted OpenStack. After a while we have decided to check and see if there are any better options on how to run our workloads and deploy our code. There were two obvious choices:
- Run everything in containers on Kubernetes
- See if public clouds make sense
After a long research, we have concluded that answers for both questions is yes. So I'm happy to report that right now we are already running production on Kubernetes on Amazon AWS. I will try to answer the following questions about our deployments:
- How do we deploy Kubernetes ?
- What have we learned after running Kubernetes in production for a while aka Day Two Kubernetes Operations
- How to stay out of trouble with Kubernetes
For Kubernetes deployment we use a tool called Kops. It has an excellent AWS support, but it also works great with other public cloud providers (GCE, VMware Vsphere), too. Kops can be used as it is or it can generate Cloudformation/Terraform templates. From our own experience we use terraform and so far it has worked great.
Kubernetes is a great tool and you can run almost anything there. Here are some things what we learned:
- Make your cluster Highly Available by using multiple masters/nodes in different AZ and by using Autoscalling.
- For nodes make sure you have at least 2 nodes per AZ.
- Don't run stateful services inside Kubernetes, it's best to run DB/Redis/ElasticCache outside as managed services.
- Use ELK/EFK stack for logs gathering (it will make any troubleshooting easier).
- Deploy Prometheus/Grafana for monitoring.
- Use Kubernetes addons to extend its functionality:
Deploying applications to Kubernetes might be challenging and we learned a lot by doing it.
- Healthchecks are really important, make sure you have them in your application and that they work correctly.
- Use one processper container, use sidecar containers if necessary.
- Make sure you setup HPA (Horizontal Pod Autoscaler) and CA(Cluster Autoscaler) properly.
- Use HELM for application manifest deployment.
- Use the best deployment update method for your application.
- Kubernetes integrated deployment types
- Rolling Update
- Helm scripted
Day Two Kubernetes Operations
Running Kubernetes in production might be a challenging effort, but we have found out that
following some simple rules can really make your life easier.
It will run your servers to the ground. Default settings for scheduler is to use as many
resources as possible on your nodes. That might cause some instability and troubles with
your app so make sure you reserve some resource for the operating system. Especially RAM is
really important. Currently, we save at least 15% of ram on each node for OS use.
Make sure you configure your app deployments properly by using - PodDistributionBudget - podAntiAffinity to distribute your pods around nodes properly. Make sure that Autoscaling groups running your nodes has AWS ASG rebalance policy disabled.
Make sure you set Autoscalling group limits with some room to grow. Kubernetes can handle
the huge load but it still needs to compute resources. Be aware of AWS own limits, too.
There is nothing worse than having a spike and not been able to launch new nodes
because you reached your limit for a particular region.
Detecting any problems on kubernetes nodes as soon as possible is critical. It helps you prevent any
troubles with miss behaving applications and makes your life easier. For node problem detection we use
Make sure you define application pod limits/requests properly. It might be a pain at the beginning as you have to understand how much ram/cpu your application needs but it will help kubernetes scheduler make proper decisions.
Make sure your Health Checks work properly and that they give you right info. Worst case for
you is GREEN health check with application not able to serve customers.
Make sure you check your containers for any security issues and update them often. Running 3 year-old containers full of security issues is a really BAD practice.
- We are currently planning to deploy our first production cluster to China.
- We plan to evaluate Mesh networks istio.
- We would like to test AWS ALB ingress controller.
So this is our approach to Kubernets. What is yours? Any tips or struggles you would like to share and discuss? Then join our Facebook group called Free to Play Game Developers and feel free to invite your fellow game developers as well. :)
And by the way, we are hiring
We are always looking for skilled PHP developers so check out our open positions. And don't worry if a position with your expertise is not open at the moment. Just send us your CV. If you love making games as much as we do and if you can imagine yourself as one of us, what are you waiting for?