From Docker Swarm to Kubernetes: When the migration is worth it

Follow one API from Docker Swarm to Kubernetes to see what changes in rollouts, autoscaling, and access control, and what to test in a pilot.

An API runs on Docker Swarm with three replicas. Updates roll out gradually, and day-to-day operations go well. Then regular traffic spikes appear, new versions take longer to start, and a second team deploys its own services on the same infrastructure. This example shows what Kubernetes changes in day-to-day operations and when the extra work pays off.

When is the new version ready to handle requests?

Swarm can replace our API replicas gradually during an update. For users, what matters is when each new instance can actually respond to requests. If the API needs to load configuration or warm a cache after starting, several seconds can pass between the process starting and the API being ready.

Kubernetes can check startup, readiness, and ongoing health separately. A startup probe gives the API time to initialize. A readiness probe determines whether the Pod receives regular traffic through the Kubernetes Service. A liveness probe can trigger a restart if the container gets stuck in a failed state. This lets you time the rollout around when the new version is actually ready. The check needs to reflect what readiness means for your API.

What happens when three replicas are sometimes too few?

Three replicas are enough for our API most of the time. When many clients send requests at once in the morning, response times rise. The team could run more replicas permanently or adjust the count manually as needed. With the Horizontal Pod Autoscaler, Kubernetes can adjust the number of Pods based on metrics and within defined limits.

A load test can help identify a suitable metric. If the API slows down when CPU usage is high and additional replicas improve throughput, CPU utilization can be a good starting point. If the database is already at capacity, the extra connections from more Pods can make the problem worse. During the pilot, track response times, error rates, and database connections alongside replica counts.

How can two teams deploy on the same platform?

The second team runs a service that calls the API. Both teams need to deploy independently. Each team should be able to change only its own production resources, and one resource-intensive job should not consume all the capacity on the shared platform.

Kubernetes provides namespaces, role-based access control, and resource quotas. The platform team can define who may deploy in each namespace and how many resources workloads in it can request in total. Network Policies can also restrict which services communicate, provided the networking plugin enforces those policies. Both teams can then work independently within shared constraints.

As more applications come on board, the platform team can centralize recurring operational tasks. A database operator might manage replicas or trigger backups, depending on the implementation. The first API pilot can run without that extension.

What should the first migrated service demonstrate?

Our stateless API makes a good pilot. You can often reuse the existing container image. You will need to decide how to expose the service, supply configuration and secrets, and check startup and readiness. For this first step, the database can stay where it is, provided the API can reach it reliably from Kubernetes.

The pilot should cover three everyday scenarios:

  1. An update with a slow startup. Watch when the new version starts receiving traffic. Check the error rate during rollout and test rolling back to the previous version.
  2. A typical traffic spike. Compare response times and error rates with the existing setup. Check whether additional Pods improve throughput and how the database responds.
  3. A deployment by the application team. Confirm that the team can deploy with the intended permissions and that logs, metrics, and alerts reach the people responsible.

When the migration pays off

Swarm can still be a good fit for a small team with a few stable services. Kubernetes takes time to learn and adds ongoing work, including cluster upgrades, extensions, and troubleshooting.

The value becomes clear when multiple services share the same operational requirements. A team can develop a reliable rollout process once and reuse it across applications. Services can scale independently. New teams can deploy within a set of rules that is already in place. The first service where you can observe these improvements in everyday operations gives you a concrete way to judge whether the migration is worth it.

Sources