Deploying a Site on Selectel: Terraform, Kubernetes, CI/CD
You've deployed a site on Selectel, but a week later it goes down due to incorrect security group configuration? Or deployment takes an hour, and rollback is a full operation? We solve these problems with automated deployment using Terraform, Kubernetes, and GitHub Actions. Rollouts take minutes, infrastructure is reliable, and it complies with 152-FZ. Once a project went down due to incorrect Object Storage configuration — images didn't load, LCP rose to 5 seconds. We rewrote the deployment with Terraform, set up CDN, and LCP dropped to 0.8 seconds. This is just one example of how automation saves business.
Our team has 5+ years of experience with Selectel infrastructure and has set up deployment for 30+ projects, from landing pages to high-load SaaS platforms. Here's how we do it.
Problems We Solve
When deploying on Selectel, we frequently encounter typical errors:
- N+1 queries when working with Object Storage — incorrect CDN configuration leads to delays. We fix this through content preloading and proper Cache-Control headers.
- Hydration mismatch in React/Next.js when using SSR — due to different server and client response times. We solve it by configuring synchronization via Edge Functions.
- Data leaks due to incorrect security group configuration. We always use minimal privileges: only 80/443 and SSH from whitelisted IPs.
Each problem is accompanied by a concrete solution we've refined on dozens of projects.
How to Organize Deployment for 152-FZ Compliance
Selectel provides certified infrastructure. We configure:
- Encryption at rest via OpenStack Barbican.
- Access logging to Object Storage via S3 Access Logs.
- Regular database backups to a separate project.
This ensures compliance without extra costs.
Why Selectel Is More Profitable Than Foreign Clouds
Selectel is 2–3 times cheaper than AWS/Azure for Russian projects when considering latency and compliance. For example, using Managed Kubernetes on Selectel reduces administration costs by 40% compared to manual deployment. Plus, data stays in Russia, which is critical for 152-FZ.
How to Set Up Deployment on Selectel from Scratch
We use a proven stack: Terraform 1.7 for infrastructure description, Ansible for configuration, GitHub Actions for CI/CD. One project — an online store on Laravel 11: we terraformed the project, set up Object Storage for media files, and Managed Kubernetes for the frontend. Deployment takes 3 minutes, rollback is 1 command.
# Creating a server via CLI
pip install python-openstackclient
export OS_AUTH_URL=https://cloud.api.selcloud.ru/identity/v3
export OS_PROJECT_ID=your_project_id
export OS_USERNAME=your_username
export OS_PASSWORD=your_password
export OS_REGION_NAME=ru-1
openstack server create \
--flavor 1014 \
--image "Ubuntu 22.04 LTS 64-bit" \
--key-name my-key \
--security-group web-sg \
myapp-prod
# Terraform for Selectel
terraform {
required_providers {
selectel = {
source = "selectel/selectel"
version = "~> 5.0"
}
openstack = {
source = "terraform-provider-openstack/openstack"
version = "~> 1.53"
}
}
}
provider "selectel" {
token = var.selectel_token
}
resource "selectel_vpc_project_v2" "myapp" {
name = "myapp-project"
theme = { color = "#4CAF50" }
}
resource "openstack_compute_instance_v2" "app" {
name = "myapp-prod"
flavor_name = "1014"
image_name = "Ubuntu 22.04 LTS 64-bit"
key_pair = openstack_compute_keypair_v2.mykey.name
security_groups = ["web-sg", "ssh-sg"]
region = "ru-1"
network {
name = "public"
}
user_data = file("cloud-init.yaml")
}
# Selectel Object Storage (Swift/S3)
aws configure
aws --endpoint-url https://s3.selcdn.ru s3 mb s3://myapp-assets
aws --endpoint-url https://s3.selcdn.ru \
s3 sync ./dist/assets s3://myapp-assets \
--acl public-read \
--cache-control "public, max-age=31536000, immutable"
# Managed Kubernetes (MKS)
selectel mks kubeconfig --cluster-id CLUSTER_ID > kubeconfig.yaml
export KUBECONFIG=./kubeconfig.yaml
kubectl apply -f k8s/
kubectl get pods -n myapp
# GitHub Actions for Selectel VPS
jobs:
deploy:
steps:
- name: Deploy
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SELECTEL_SERVER_IP }}
username: deploy
key: ${{ secrets.SSH_KEY }}
script: |
cd /var/www/myapp
git pull origin main
composer install --no-dev --optimize-autoloader
npm ci && npm run build
php artisan migrate --force
php artisan optimize
sudo systemctl reload php8.3-fpm nginx
Typical Deployment Mistakes and Their Prevention
- Ignoring security groups — leaving SSH open to all IPs. We only use whitelists.
- Incorrect CORS configuration for S3 — static files don't load on the frontend. We explicitly specify allowed origins.
- Lack of monitoring — finding out about downtime from clients. We set up alerts via SendGrid or Telegram.
These mistakes are easy to avoid if you follow our practices.
Process
- Analysis — determine requirements for load, budget, compliance.
- Design — draw architecture: VPS vs Kubernetes, S3 vs DB, CDN.
- Infrastructure — deploy project, networks, security groups with Terraform code.
- Implementation — configure application, CI/CD, monitoring (Prometheus + Grafana).
- Testing — load testing, Core Web Vitals check.
- Deployment — canary rollout with automatic rollback on errors.
What's Included in Deployment Setup
- Architecture design for your tasks.
- Writing Terraform configurations for the entire infrastructure.
- Setting up CI/CD (GitHub Actions or GitLab CI) with automatic deployment and rollback.
- Configuring Object Storage and CDN for static files.
- Integrating monitoring (Prometheus + Grafana) with alerts.
- Documentation on deployment and training for your team.
- Technical support after launch.
Comparison: VPS vs Managed Kubernetes
| Parameter | VPS | Managed Kubernetes (MKS) |
|---|---|---|
| Deployment time | 1–2 days | 3–4 days |
| Scaling | Manual (vertical) | Automatic (horizontal) |
| Cost | Low | Medium, with admin savings |
| Suitable for | Small projects | High-load and microservices |
Deployment Component Timelines
| Deployment Component | Timeline |
|---|---|
| VPS + Nginx + deploy | 1–2 days |
| Object Storage + CDN | 1 day |
| Managed Kubernetes | 3–4 days |
| CI/CD (GitHub Actions) | 1–2 days |
The cost is calculated individually per project. Request a custom deployment cost estimate — we'll select the optimal architecture. Get a consultation — we'll assess your project in one business day. Contact us to set up a deployment that won't let you down.







