all systems operational +48 697 610 212
Technical · [2026-02-06]

Migrating 60 Apps from Apache to Kubernetes: a Case Study from Wrocław

How we migrated 60 applications from Apache2 and Docker to Kubernetes RKE2 with GitOps (ArgoCD), Helm Chart, and Sealed Secrets. A deployment case study.

KUBERNETES · ARGOCD · GITOPS · HELM · RKE2 · DEVOPS · CI-CD

Sixty applications, half on Docker and half on Apache2, across three environments, with no two deployments done the same way. That was the starting point of one of our projects in Wroclaw, Poland. We moved these applications to Kubernetes RKE2 with ArgoCD, a single Helm Chart and Sealed Secrets, and deployments now go through a GitLab pipeline.

Initial state

The environment ran in an on-premise data center with virtualization. The infrastructure grew without a plan: each new app got a new Apache vhost with config copied from the previous project.

ElementInitial state
Applications~60 (separate frontend + backend containers)
TechnologiesPHP (backend), Node.js (frontend)
Runtime~50% Docker, ~50% Apache2
DatabasesOn shared VMs
DeploymentsMix of manual and semi-automated
RollbackSSH + restoring files from backup

The apps worked. The problem was that every deployment looked different and a rollback meant manual work on the server. A new team member needed weeks to learn the environment. One bad production deploy could take up the team’s Friday afternoon.

What caused the most trouble:

  1. deploying to DEV looked different than deploying to PROD,
  2. there was no change history, so nobody could answer “who deployed this?”,
  3. reverting changes required SSH access and restoring files by hand,
  4. configuration was scattered across Apache vhosts, .env files and variables in different places,
  5. environments were not separated, and DEV could affect RC.

Project goals

The client wanted:

  • a Kubernetes cluster as a stable, scalable platform for the apps,
  • help moving the apps from Apache2 to containers,
  • optimized Dockerfiles: smaller images, faster builds, fewer layers,
  • a GitLab CI/CD pipeline from code to production,
  • one-click deployments and rollbacks that don’t require manual work.

What we did

Step 1: RKE2, a separate cluster for each environment

We chose RKE2, a lightweight, CNCF-certified Kubernetes distribution from Rancher with a built-in CIS hardening profile. Each environment got its own cluster.

┌─────────────┐  ┌─────────────┐  ┌─────────────┐
│   RKE2 DEV  │  │   RKE2 RC   │  │  RKE2 PROD  │
│             │  │             │  │             │
│  3 nodes    │  │  3 nodes    │  │  5 nodes    │
│  dev apps   │  │  rc apps    │  │  prod apps  │
└─────────────┘  └─────────────┘  └─────────────┘

We also considered a single cluster split into namespaces:

ApproachProsCons
NamespacesCheaper, simplerShared resources, blast radius
Separate clustersFull isolation, independent upgradesHigher infra cost

We chose isolation. A failure on DEV doesn’t touch production, and a Kubernetes upgrade on RC puts nothing on PROD at risk. Each environment has its own lifecycle.

We picked RKE2 over kubeadm or k3s because the project required CIS hardening out of the box, and RKE2 provides it by default. Rancher’s stable update channel also means the cluster won’t be left on an outdated version.

Step 2: the network layer with MetalLB and NGINX Ingress Controller

The client’s data center had no cloud load balancer, and the services had to be exposed externally. We used MetalLB in L2 mode and NGINX Ingress Controller.

┌─────────────────────────────────────────────────┐
│                   On-prem DC                     │
│                                                  │
│  ┌──────────┐    ┌───────────────────────────┐   │
│  │ MetalLB  │───►│  NGINX Ingress Controller  │  │
│  │ (VIP L2) │    │  (HTTP/HTTPS routing)      │  │
│  └──────────┘    └─────────┬─────────────────┘   │
│                            │                     │
│              ┌─────────────┼─────────────┐       │
│              ▼             ▼             ▼       │
│         ┌────────┐   ┌────────┐   ┌────────┐    │
│         │ app1   │   │ app2   │   │ app3   │    │
│         │frontend│   │backend │   │frontend│    │
│         └────────┘   └────────┘   └────────┘    │
│                                                  │
└─────────────────────────────────────────────────┘

MetalLB assigns IP addresses from a pool defined in its configuration. In a bare-metal environment, this is the only way to get type: LoadBalancer without a cloud provider:

apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
  name: default-pool
  namespace: metallb-system
spec:
  addresses:
    - 10.0.10.100-10.0.10.120
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
  name: default
  namespace: metallb-system

NGINX Ingress Controller receives a VIP from MetalLB and routes HTTP/HTTPS traffic to the right services based on Ingress rules:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: app1-frontend
  annotations:
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/proxy-body-size: "50m"
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - app1.client.pl
      secretName: app1-tls
  rules:
    - host: app1.client.pl
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: app1-frontend
                port:
                  number: 80
          - path: /api
            pathType: Prefix
            backend:
              service:
                name: app1-backend
                port:
                  number: 9000

We chose L2 mode over BGP because the access switches in the client’s network didn’t support BGP. L2 works right away: all you need is a pool of free IPs in the same network segment. For clusters with a dozen or so nodes, that is enough.

Step 3: containerizing the applications

The frontend and backend of each app are separate containers. Each has its own Dockerfile, image and Kubernetes deployment, so they can be scaled, deployed and rolled back independently.

Half the apps were already in Docker, but their Dockerfiles had typical problems:

# ❌ A typical Dockerfile we found (PHP backend)
FROM php:8.1-apache
COPY . /var/www/html/
RUN apt-get update && apt-get install -y \
    git curl zip unzip libpng-dev libonig-dev \
    libxml2-dev libzip-dev nodejs npm
RUN composer install
RUN npm install && npm run build
EXPOSE 80

What was wrong with it:

  • frontend and backend in one image, so they couldn’t be scaled separately,
  • one large image (~1.2 GB) with build tools in production,
  • no multi-stage build,
  • no .dockerignore, so node_modules and .git ended up in the image,
  • apt-get install without --no-install-recommends, so unneeded packages ended up in the image.

After splitting into separate containers and optimizing:

# ✅ Backend (PHP-FPM): separate container
FROM composer:2 AS deps
WORKDIR /build
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --prefer-dist
COPY . .
RUN composer dump-autoload --optimize

FROM php:8.1-fpm-alpine
RUN apk add --no-cache libpng libxml2 libzip oniguruma
COPY --from=deps /build /var/www/html
USER www-data
EXPOSE 9000
# ✅ Frontend (Node.js): separate container
FROM node:20-alpine AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
MetricBefore (monolithic)After (separate containers)
Image size~1.2 GB (single)~150 MB backend + ~30 MB frontend
Independent scalingImpossibleYes, frontend and backend separately
Independent deploymentsImpossibleYes, deploying the backend doesn’t restart the frontend
Build time (cached)~6 min~30 sec (backend) + ~20 sec (frontend)
Build tools in prodgit, npm, composernone

Step 4: GitOps with ArgoCD

Instead of imperative deployments (kubectl apply, bash scripts), we implemented a declarative approach with ArgoCD. The Git repository is the single source of truth for infrastructure state, and nobody changes anything in the cluster by hand. ArgoCD continuously compares the desired state (Git) with the actual state (cluster) and automatically syncs the differences.

ArgoCD repository structure:

argocd-repo/
├── base/                    # Shared Helm Chart configuration
│   ├── Chart.yaml
│   ├── values.yaml          # Default values
│   └── templates/
│       ├── deployment.yaml
│       ├── service.yaml
│       ├── ingress.yaml
│       ├── hpa.yaml
│       └── sealed-secret.yaml
│
└── overlays/
    ├── dev/
    │   ├── app1/
    │   │   └── values.yaml  # image.tag, replicas, resources
    │   ├── app2/
    │   │   └── values.yaml
    │   └── ...
    ├── rc/
    │   ├── app1/
    │   │   └── values.yaml
    │   ├── app2/
    │   │   └── values.yaml
    │   └── ...
    └── prod/
        ├── app1/
        │   └── values.yaml  # Production tags, HPA, higher limits
        ├── app2/
        │   └── values.yaml
        └── ...

Each app has a separate values.yaml with overridden values on each environment. The shared base lives in base/, the differences in overlays/. This is the overlay for PROD:

# overlays/prod/app1/values.yaml
image:
  repository: registry.client.local/app1
  tag: "a1b2c3d"  # Commit SHA, replaced by CI

replicaCount: 3

resources:
  requests:
    cpu: 200m
    memory: 256Mi
  limits:
    cpu: 500m
    memory: 512Mi

hpa:
  enabled: true
  minReplicas: 3
  maxReplicas: 10
  targetCPU: 70

ingress:
  host: app1.client.pl
  tls: true

Step 5: a universal Helm Chart

Instead of maintaining 60 separate charts, we built one universal Helm Chart for all applications. It lets you configure:

ComponentConfigurable
Deploymentreplicas, strategy, resources, probes, env, volumes
Servicetype, ports
Ingresshost, path, TLS, annotations
HPAmin/max replicas, targetCPU/Memory
Sealed Secretencrypted secrets per environment
ConfigMapapplication configuration
PDBPod Disruption Budget

The frontend and backend are separate deployments, but both use the same chart. The runtime type is set by a single switch:

# Backend (PHP-FPM)
runtime: php
phpFpm:
  enabled: true

# Frontend (Node.js + nginx)
runtime: node
nginx:
  enabled: true

# Frontend (static build served by nginx)
runtime: static
nginx:
  enabled: true

One chart serves ~60 applications (separate frontend + backend containers) without duplicating configuration.

Step 6: Sealed Secrets for secrets in Git

With GitOps, passwords and keys also have to go into the repository, without leaking. We used Sealed Secrets by Bitnami:

┌──────────────┐    kubeseal     ┌──────────────────┐
│  Secret.yaml │ ──────────────► │ SealedSecret.yaml │ ──► Git repo
│  (plaintext) │    encrypt      │   (encrypted)     │
└──────────────┘                 └──────────────────┘
                                          │
                                          ▼
                                 ┌──────────────────┐
                                 │  Sealed Secrets   │
                                 │  Controller (K8s) │
                                 │  decrypt → Secret │
                                 └──────────────────┘

The flow:

  1. A developer creates a Secret with sensitive data.
  2. kubeseal encrypts it with the controller’s public key.
  3. The encrypted SealedSecret goes to Git.
  4. The controller in the cluster decrypts it and creates a regular Secret.

A Sealed Secret is encrypted per namespace and per cluster. If someone copies it to another namespace, the controller will refuse to decrypt it.

Step 7: CI/CD pipeline in GitLab

Each application has a GitLab CI pipeline that builds the image, tests it, pushes it to the registry and deploys it:

stages:
  - build
  - test
  - push
  - deploy

build:
  stage: build
  script:
    - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA .

test:
  stage: test
  script:
    - docker run $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA ./run-tests.sh

push:
  stage: push
  script:
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA

deploy:
  stage: deploy
  script:
    - >
      sed -i "s|tag:.*|tag: \"${CI_COMMIT_SHA}\"|"
      argocd-repo/overlays/${TARGET_ENV}/${APP_NAME}/values.yaml
    - cd argocd-repo
    - git add . && git commit -m "deploy ${APP_NAME} ${CI_COMMIT_SHA}"
    - git push
  rules:
    - if: $CI_COMMIT_BRANCH == "dev"
      variables:
        TARGET_ENV: dev
    - if: $CI_COMMIT_BRANCH == "master"
      variables:
        TARGET_ENV: rc
    - if: $CI_COMMIT_TAG
      variables:
        TARGET_ENV: prod

Environment mapping:

Git eventEnvironmentAutomatic?
Push to devDEVYes
Push to masterRCYes
New tagPRODYes

Every image is tagged with the commit SHA instead of latest or v1.2.3, so you always know what code is running on a given environment:

# What commit is on PROD?
$ grep "tag:" overlays/prod/app1/values.yaml
  tag: "a1b2c3d4e5f6"

$ git log --oneline a1b2c3d4e5f6
a1b2c3d fix: resolve payment gateway timeout

Step 8: the databases stayed on VMs

We deliberately left the databases on their existing shared VMs. The common “K8s is for stateless” claim is a myth, but a database on Kubernetes needs a proven operator, and deploying one takes time and expertise the client didn’t need to build right now. The database VMs worked, with backup, monitoring and failover in place. The migration risk was high, and the benefit in this project was marginal.

Applications in Kubernetes connect to the databases over the internal network, through an ExternalName Service or a direct endpoint.

What a deployment looks like after the migration

Developer pushes to dev branch
         │
         ▼
┌─────────────────┐
│  GitLab CI/CD   │
│  build → test   │
│  push → deploy  │
└────────┬────────┘
         │ Replaces tag in values.yaml
         ▼
┌─────────────────┐
│  ArgoCD repo    │
│  (Git commit)   │
└────────┬────────┘
         │ ArgoCD detects drift
         ▼
┌─────────────────┐
│  ArgoCD sync    │
│  (K8s apply)    │
└────────┬────────┘
         │ Rolling update
         ▼
┌─────────────────┐
│  New version    │
│  running on DEV │
└─────────────────┘

To roll back, you revert the commit in the ArgoCD repo. ArgoCD detects the change and restores the previous version. There’s no SSH login, and the full history stays in Git.

Result

AspectBeforeAfter
Deployment time15–45 min (manual)~5 min (automated)
RollbackSSH + backup (30+ min)Git revert (~2 min)
Change historyNoneComplete (Git log)
RepeatabilityLow100%, same process on every environment
New team member onboardingWeeksDays, the entire stack is in code
Environment separationPartialFull, separate clusters
New applicationConfigure server from scratchNew overlay + values.yaml

Is every one of your apps deployed differently, and does a rollback mean SSH and a backup? Let’s talk about your case.

Want the same in your setup?

Get in touch. The first consultation is free.

Free consultation →