General

From On-Premise to Cloud: A Guide to Hybrid Virtualisation with Kubernetes and Container Orchestration

Marta Teknoloji•August 21, 2025•7 min read

Publication Date: 21 August 2025

Category: Virtualisation, Kubernetes, Container, Docker, Cloud Migration

Reading Time: 12 minutes

Why Now? The Virtualisation 3.0 Era

VMware’s acquisition by Broadcom and the 300% increase in licence prices have pushed organisations in Türkiye towards alternative virtualisation solutions. Kubernetes and container technologies offer 65% lower resource usage and 80% faster deployment times compared with traditional VMs. This guide covers step-by-step Kubernetes cluster setup and a production-ready configuration.

Part 1: Core Concepts and Architecture

Container vs Virtual Machine: A Technical Comparison

# Resource Usage Comparison
Virtual_Machine:
  overhead: 1-2 GB RAM per VM
  boot_time: 30-60 seconds
  disk_usage: 10-20 GB per instance
  density: 10-15 VMs per host

Container:
  overhead: 50-100 MB RAM
  boot_time: 1-2 seconds  
  disk_usage: 100-500 MB per instance
  density: 100-500 containers per host

Kubernetes Components: Master and Worker Nodes

graph TB
    subgraph "Master Node (Control Plane)"
        API
        ETCD
        SCH
        CM
    end
    
    subgraph "Worker Node 1"
        KUB1
        KP1
        CR1
        POD1
    end
    
    subgraph "Worker Node 2"
        KUB2
        KP2
        CR2
        POD2
    end
    
    API --> KUB1
    API --> KUB2

Part 2: Production Kubernetes Cluster Setup

Step 1: System Requirements and Preparation

#!/bin/bash
# Minimum system requirements
# Master Node: 2 CPU, 4GB RAM, 20GB Disk
# Worker Node: 2 CPU, 8GB RAM, 40GB Disk

# Installation on Ubuntu 22.04 LTS
# To be run on all nodes

# System update
sudo apt update && sudo apt upgrade -y

# Disable swap (Kubernetes requirement)
sudo swapoff -a
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab

# Load kernel modules
cat <

Step 2: Installing the Container Runtime (containerd)

# containerd installation
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common

# Add the Docker repository
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb  https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install containerd
sudo apt update
sudo apt install -y containerd.io

# containerd configuration
sudo mkdir -p /etc/containerd
sudo containerd config default | sudo tee /etc/containerd/config.toml

# Set SystemdCgroup = true (important!)
sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml

sudo systemctl restart containerd
sudo systemctl enable containerd

Step 3: Installing the Kubernetes Components

# Add the Kubernetes repository
sudo apt-get install -y apt-transport-https ca-certificates curl
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg
echo "deb  https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list

# Install kubeadm, kubelet, kubectl
sudo apt-get update
sudo apt-get install -y kubelet=1.28.2-00 kubeadm=1.28.2-00 kubectl=1.28.2-00
sudo apt-mark hold kubelet kubeadm kubectl

Step 4: Initialising the Master Node

# To be run on the master node
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 \
  --control-plane-endpoint=master.k8s.local \
  --apiserver-advertise-address=192.168.1.100

# kubectl configuration
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

# Install the network plugin (Flannel)
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Step 5: Adding Worker Nodes

# Get the token from the master node
kubeadm token create --print-join-command

# To be run on the worker nodes (command obtained from the master)
sudo kubeadm join master.k8s.local:6443 --token abcdef.0123456789abcdef \
    --discovery-token-ca-cert-hash sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef

Part 3: Production-Ready Configurations

High Availability (HA) Setup

# haproxy.cfg - Load Balancer configuration
global
    maxconn 4096
    
defaults
    mode tcp
    timeout connect 5000ms
    timeout client 50000ms
    timeout server 50000ms
    
frontend kubernetes-api
    bind *:6443
    default_backend kubernetes-masters

backend kubernetes-masters
    balance roundrobin
    server master1 192.168.1.100:6443 check
    server master2 192.168.1.101:6443 check
    server master3 192.168.1.102:6443 check

Storage Configuration: Persistent Volumes

# local-storage-class.yaml
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

---
# nfs-persistent-volume.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv-data
spec:
  capacity:
    storage: 100Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.1.50
    path: "/mnt/k8s-data"
  storageClassName: nfs-storage

Monitoring Stack: Prometheus + Grafana

# Installing the Prometheus Stack with Helm
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

# Create the values.yaml file
cat < prometheus-values.yaml
prometheus:
  prometheusSpec:
    retention: 30d
    storageSpec:
      volumeClaimTemplate:
        spec:
          accessModes: ["ReadWriteOnce"]
          resources:
            requests:
              storage: 50Gi
              
grafana:
  adminPassword: "SecurePassword123!"
  persistence:
    enabled: true
    size: 10Gi
    
alertmanager:
  config:
    global:
      smtp_smarthost: 'smtp.gmail.com:587'
      smtp_from: 'alerts@company.com'
    receivers:
    - name: 'email-notifications'
      email_configs:
      - to: 'devops-team@company.com'
EOF

# Installation
helm install monitoring prometheus-community/kube-prometheus-stack \
  --namespace monitoring --create-namespace \
  -f prometheus-values.yaml

Part 4: Application Deployment Best Practices

Multi-Stage Dockerfile Example

# Multi-stage build for Java application
FROM maven:3.8-openjdk-17 AS builder
WORKDIR /app
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src ./src
RUN mvn clean package -DskipTests

FROM openjdk:17-jdk-alpine
RUN addgroup -g 1001 -S appuser && adduser -u 1001 -S appuser -G appuser
WORKDIR /app
COPY --from=builder /app/target/*.jar app.jar
USER appuser
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

Kubernetes Deployment Manifest

# application-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: java-app
  labels:
    app: java-app
spec:
  replicas: 3
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  selector:
    matchLabels:
      app: java-app
  template:
    metadata:
      labels:
        app: java-app
    spec:
      containers:
      - name: app
        image: registry.company.com/java-app:v1.2.3
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "256Mi"
            cpu: "250m"
          limits:
            memory: "512Mi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
          initialDelaySeconds: 30
          periodSeconds: 10
        readinessProbe:
          httpGet:
            path: /ready
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 5
        env:
        - name: SPRING_PROFILES_ACTIVE
          value: "production"
        - name: DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: db-secret
              key: password

Horizontal Pod Autoscaler (HPA)

# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: java-app-hpa
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: java-app
  minReplicas: 3
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 80

Part 5: Network Policies and Security

Calico Network Policy Example

# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: backend-netpol
spec:
  podSelector:
    matchLabels:
      tier: backend
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - podSelector:
        matchLabels:
          tier: frontend
    ports:
    - protocol: TCP
      port: 8080
  egress:
  - to:
    - podSelector:
        matchLabels:
          tier: database
    ports:
    - protocol: TCP
      port: 5432

Pod Security Standards

# pod-security-policy.yaml
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
  name: restricted
spec:
  privileged: false
  allowPrivilegeEscalation: false
  requiredDropCapabilities:
    - ALL
  volumes:
    - 'configMap'
    - 'emptyDir'
    - 'projected'
    - 'secret'
    - 'downwardAPI'
    - 'persistentVolumeClaim'
  runAsUser:
    rule: 'MustRunAsNonRoot'
  seLinux:
    rule: 'RunAsAny'
  fsGroup:
    rule: 'RunAsAny'

Part 6: CI/CD Pipeline Integration

GitLab CI/CD Pipeline

# .gitlab-ci.yml
stages:
  - build
  - test
  - deploy

variables:
  DOCKER_REGISTRY: registry.company.com
  APP_NAME: java-app
  NAMESPACE: production

build:
  stage: build
  script:
    - docker build -t $DOCKER_REGISTRY/$APP_NAME:$CI_COMMIT_SHA .
    - docker push $DOCKER_REGISTRY/$APP_NAME:$CI_COMMIT_SHA
    - docker tag $DOCKER_REGISTRY/$APP_NAME:$CI_COMMIT_SHA $DOCKER_REGISTRY/$APP_NAME:latest
    - docker push $DOCKER_REGISTRY/$APP_NAME:latest

test:
  stage: test
  script:
    - docker run --rm $DOCKER_REGISTRY/$APP_NAME:$CI_COMMIT_SHA ./mvnw test

deploy:
  stage: deploy
  script:
    - kubectl set image deployment/$APP_NAME $APP_NAME=$DOCKER_REGISTRY/$APP_NAME:$CI_COMMIT_SHA -n $NAMESPACE
    - kubectl rollout status deployment/$APP_NAME -n $NAMESPACE
  only:
    - main

Part 7: Troubleshooting and Debugging

Common Problems and Their Solutions

# Check why pods are not starting
kubectl describe pod 
kubectl logs  --previous

# Node resource usage
kubectl top nodes
kubectl top pods --all-namespaces

# Network connectivity test
kubectl run tmp-shell --rm -i --tty --image nicolaka/netshoot -- /bin/bash

# DNS troubleshooting
kubectl exec -it  -- nslookup kubernetes.default

# etcd backup
ETCDCTL_API=3 etcdctl snapshot save backup.db \
  --endpoints=https://127.0.0.1:2379 \
  --cacert=/etc/etcd/ca.crt \
  --cert=/etc/etcd/server.crt \
  --key=/etc/etcd/server.key

Part 8: Cost Optimisation

Resource Quotas and Limit Ranges

# resource-quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: compute-quota
  namespace: production
spec:
  hard:
    requests.cpu: "100"
    requests.memory: 200Gi
    limits.cpu: "200"
    limits.memory: 400Gi
    persistentvolumeclaims: "10"
    services.loadbalancers: "2"

Using Spot Instances (Cloud Providers)

# spot-instance-nodepool.yaml
apiVersion: v1
kind: Node
metadata:
  labels:
    node.kubernetes.io/instance-type: spot
    kubernetes.io/arch: amd64
spec:
  taints:
  - key: "spot-instance"
    value: "true"
    effect: "NoSchedule"

Performance Comparison: Traditional VM vs Kubernetes

Metric Traditional VM Kubernetes Improvement

|--------|---------------|------------|----------|

Deployment Time 30-45 minutes 2-5 minutes 93% Resource Overhead 20-30% 5-10% 66% Autoscaling Manual/Script Automatic ∞ Rollback Time 1-2 hours 30 seconds 99% Infrastructure Cost $10,000/month $3,500/month 65%

Conclusion and Recommendations

Although migrating to Kubernetes may look complex at first glance, with proper planning and a phased transition it can deliver ROI within 6 months. Recommendations for organisations in Türkiye:

1. Pilot Project: Start with a non-critical application

2. Training: Kubernetes certification (CKA/CKAD) for the DevOps team

3. Hybrid Approach: Use VMs and containers together

4. Managed Services: Consider EKS, GKE or AKS in the initial phase

5. Local Expertise: Work with local Kubernetes consultants

Resources

  • Kubernetes Official Documentation v1.28
  • CNCF Cloud Native Landscape 2025
  • "Production Kubernetes" O'Reilly Media
  • Red Hat OpenShift Best Practices
  • VMware Tanzu Migration Guide

  • Keywords: Kubernetes, container, Docker, virtualisation, orchestration, microservices, cloud native, DevOps, CI/CD, container security, Helm, Prometheus, Grafana, pod, deployment, service mesh, Istio, hybrid cloud, multi-cloud, Türkiye cloud technologies, digital transformation

    #bulut bilişim#devops#yapay zeka

    Want to learn more?

    Contact us for information about our cybersecurity, software, and infrastructure services.

    Contact Us→