Ray Tsang on Tools and Best Practices for Kubernetes Adoption
Ray Tsang, developer advocate at Google, spoke last week at SpringOne Platform 2019 Conference about the tools and best practices developers can use in Kubernetes adoption in their organizations.
Containerization and adopting container platforms like Kubernetes has been a challenge for application developers. Building container images involves Dockerfiles, which are cumbersome and error-prone when creating and maintaining them in the long run. Also, IDE tools’ support for developing and maintaining container based applications has been poor. This typically slows down the entire software development cycle.
The Spring Cloud Kubernetes project provides common interfaces that consume Kubernetes native services. The main objective of the project is to help with the integration of Spring Cloud and Spring Boot applications running inside Kubernetes.
Tsang talked about TestContainers, which is a Java library that supports JUnit tests with disposable instances of common databases, Selenium web browsers, or other servers that can run in a Docker container. TestContainers make it easier to run tests in the data access layer, application integration tests and the UI tests. You can test most of the components in your container based application locally on the laptop.
He also talked about the importance of understanding the memory usage in Java applications to avoid OOMKilled situations. Tools like Cloud Foundry Java Build Pack Memory Calculator can be used to calculate a holistic JVM memory configuration to ensure the applications perform well without exceeding the container’s memory limit and being recycled.
Tsang mentioned the container best practices presentation where he discussed the best practices on how to create and manage the Docker containers. A tip included not running the container as the root user, and it was explained how to make sure the images don’t take too much space, and thow to avoid the containers from running out of space. Most of the images run as root, but the developers should change this setting to restrict the privileges.
Other tools that can help with Kubernetes adoption include Jib and Skaffold for fast image build and development cycle turnaround time.
Jib builds optimized Docker and Open Container Initiative (OCI) images for Java applications without a Docker daemon. It creates Dockerfile automatically and works even if you don’t have Docker installed locally. Jib is available as a plugin for Maven and Gradle and also as a Java library.
Skaffold is a command line tool that facilitates continuous development for Kubernetes applications. It can be used for all the workflow steps in building, pushing and deploying the application. Skaffold also provides building blocks and customizations for a CI/CD pipeline.
Tsang also discussed other best practices for configuring Java applications to run inside of Kubernetes, such as health checks, zero downtime deployment, externalizing configurations, and logging.