Deploying Bitrix in Kubernetes: Complete Guide with Cases

Deploying 1С-Bitrix in Kubernetes: Complete Guide with Case Studies 1С-Bitrix was not designed for container orchestration. Sessions in files, cache on disk, uploaded files in `upload/`, the core in `bitrix/` — all these stateful artifacts require special handling in Kubernetes. Yet the task is s

Our competencies:

Frequently Asked Questions

Deploying 1С-Bitrix in Kubernetes: Complete Guide with Case Studies

1С-Bitrix was not designed for container orchestration. Sessions in files, cache on disk, uploaded files in upload/, the core in bitrix/ — all these stateful artifacts require special handling in Kubernetes. Yet the task is solvable, and production Bitrix sites run in k8s clusters under heavy load. We have deployed Bitrix in Kubernetes for 15+ projects, and our experience shows: in 2-3 weeks you can get a fault-tolerant infrastructure with automatic scaling.

Proper containerization of Bitrix allows achieving zero downtime during deployments and easily withstand peak loads. Our clients save up to 30% on infrastructure costs, and the project pays for itself within six months. In this article, we will analyze the key problems and their solutions based on real cases.

However, many teams encounter typical mistakes: incorrect session setup leads to automatic logouts during scaling, and storing cache in files nullifies the benefits of containerization. We have collected best practices that will help you avoid these pitfalls.

Why Kubernetes for Bitrix is a Challenge?

The main problem — Bitrix stores state (sessions, cache, uploaded files) locally on disk. In Kubernetes, pods are ephemeral: data is lost when a pod is recreated. Without special settings, the user will lose the session on every request, and the cache will become useless. Additionally, the Bitrix license is tied to an IP or domain — during cloud deployment you need to ensure a stable external IP. Another complexity is handling uploaded files: in the classic scheme, all upload files are in a shared folder accessible to all web servers. Integration with 1С via CommerceML requires temporary files that must be available to all pods. Bitrix24 can also be deployed in Kubernetes, but its architecture differs — separate configuration of agents and events is required. Kubernetes documentation recommends using PersistentVolume for stateful data. We have applied this approach in 15 projects.

How We Solve the Session and Cache Problem?

Sessions. Switch session storage to Redis. In .settings.php of Bitrix, we specify:

'session' => [ 'value' => [ 'mode' => 'separated', 'handlers' => [ 'general' => [ 'type' => 'redis', 'host' => 'redis-service', 'port' => 6379, ], ], ], ], 

Cache. Change CACHE_TYPE=A to Memcached:

'cache' => [ 'value' => [ 'type' => ['memcache' => 'memcache'], 'memcache' => [ 'host' => 'memcached-service', 'port' => 11211, ], ], ], 

Files. The upload/ directory is mounted via a PersistentVolumeClaim with ReadWriteMany mode (NFS, CephFS). The code is baked into the Docker image — this speeds up deployment and simplifies version management.

How to Configure Upload File Storage?

For storing upload files, we use a PersistentVolumeClaim with ReadWriteMany access mode. We recommend an NFS server in the cluster or a cloud file storage (e.g., Yandex Object Storage via FUSE). Important: the site code should be baked into the Docker image, and the upload directory excluded from the image via .dockerignore. This ensures files are not lost when pods are recreated. In practice, for a catalog with 2 million products, upload takes 50 GB — PV handles it without issues.

Solution Performance Reliability Cost
NFS Medium High Low
CephFS High Very high Medium
Cloud storage (S3) Low-Medium High Medium

Typical Mistakes in Containerizing Bitrix

Expand typical mistakes
Mistake Consequence Solution
Sessions in files Session loss during scaling Use Redis
Cache on disk Low performance Memcached or Redis
upload in image Large image size, data loss PersistentVolume
No .dockerignore Slow build Exclude upload and bitrix

Why Should the Database Be Placed Outside the Cluster?

Although MySQL can be run in Kubernetes via StatefulSet, we strongly recommend using managed solutions (AWS RDS, Yandex Managed Service for MySQL). This simplifies backups, replication, and updates. Databases are the most critical component, and their maintenance in the cluster requires separate expertise. For example, in case of etcd failure, database recovery can take hours, while a managed solution guarantees SLA 99.95%.

Structure of Kubernetes Manifests

namespace: bitrix-prod ├── Deployment: bitrix-app (PHP-FPM + Nginx sidecar) ├── Service: bitrix-app-svc ├── Ingress: bitrix-ingress (with TLS) ├── StatefulSet: redis ├── StatefulSet: memcached ├── PersistentVolumeClaim: bitrix-upload (RWX) ├── ConfigMap: php-fpm-config ├── ConfigMap: nginx-config └── Secret: db-credentials 

Deployment for PHP-FPM with Nginx sidecar, mounting upload and configs — a standard pattern. The database (MySQL) we recommend placing in a managed solution — it is more reliable and easier to maintain.

Horizontal Scaling

After setting up Redis and Memcached, scaling is one command: kubectl scale deployment bitrix-app --replicas=5. You can add a HorizontalPodAutoscaler:

apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: bitrix-hpa spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: bitrix-app minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 

CI/CD Pipeline

We use GitLab CI/CD: Docker image build, push to registry, rolling update via kubectl. Zero downtime — pods are replaced one by one.

Timeline

Stage Content Duration
Analysis and preparation Audit of Bitrix configuration, selection of session/cache solutions 2–3 days
Dockerfile + image Build, functionality check 2–3 days
k8s manifests Deployment, Service, Ingress, PVC, ConfigMap, Secret 3–4 days
Redis/Memcached Deployment and configuration of session/cache 1–2 days
CI/CD Build and deploy pipeline 2–3 days
Testing Load tests, sticky session verification 2–3 days

Total: 2-3 weeks for a production environment. For dev/staging — faster.

What Is Included in the Work

  • Audit of current Bitrix configuration and infrastructure.
  • Development of Dockerfile and Docker Compose for local development.
  • Writing Kubernetes manifests (Deployment, Service, Ingress, PVC, Secret).
  • Configuration of Redis and Memcached for sessions and cache.
  • Integration of CI/CD (GitLab/GitHub Actions) with rolling update.
  • Load testing and optimization (up to 1000 RPS).
  • Deployment and operation documentation.
  • Training for your team (1-2 sessions).

Our Experience

We have been doing Bitrix infrastructure for over 7 years. We have deployed 15+ projects in Kubernetes, including catalogs with millions of products and high traffic. We use only stable technologies and best practices. One client — an online store with 2 million products and 50,000 unique visitors per day. After migration, downtime dropped to zero, and page load speed increased by 40%.

Order an audit of your infrastructure — we will assess readiness for containerization and propose an optimal plan. Contact us for a consultation.