Multi-Cloud Kubernetes with GitOps: A Complete Reference Architecture
Over the course of this series, we have explored individual components of a modern infrastructure stack: Terraform for provisioning, ArgoCD for GitOps deployments, Vault for secrets, Grafana for observability, security hardening, CI/CD pipeline design, disaster recovery, and the internal developer platform that ties them together.
Now it is time to show how all of these fit into a single, coherent architecture. This post is the technical capstone — a complete reference architecture for running production workloads across AWS and Hetzner Cloud with GitOps as the operating model and GitLab CI/CD as the developer interface.
graph TD
subgraph Developer
GL[GitLab CI/CD]
end
subgraph Infrastructure
TF[Terraform] --> AWS[AWS EKS]
TF --> HZ[Hetzner K3s]
end
subgraph GitOps
ARGO[ArgoCD] --> AWS
ARGO --> HZ
end
subgraph Security
VAULT[Vault] --> AWS
VAULT --> HZ
KYV[Kyverno] --> AWS
KYV --> HZ
end
subgraph Observability
OTEL[OpenTelemetry] --> GRAF[Grafana Stack]
end
GL --> TF
GL --> ARGO
Architecture Overview
┌─────────────────────────────────────────────────────────────┐
│ DEVELOPER INTERFACE │
│ GitLab CI/CD │
│ Code Push → Build → Test → Security Scan → Deploy Trigger │
└──────────────────────────┬──────────────────────────────────┘
│
┌────────────┴────────────┐
│ │
▼ ▼
┌──────────────────────┐ ┌──────────────────────┐
│ INFRASTRUCTURE │ │ DEPLOYMENT │
│ Terraform │ │ ArgoCD │
│ │ │ │
│ ┌──────┐ ┌────────┐ │ │ App-of-Apps pattern │
│ │ AWS │ │Hetzner │ │ │ Auto-sync + prune │
│ │ EKS │ │ K3s │ │ │ Multi-cluster │
│ └──────┘ └────────┘ │ └──────────┬───────────┘
└──────────────────────┘ │
▼
┌─────────────────────────────────────────────────────────────┐
│ KUBERNETES CLUSTERS │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────────┐ │
│ │ Vault │ │ OTel + Grafana│ │ Kyverno Policies │ │
│ │ (Secrets) │ │ (Observability)│ │ (Security) │ │
│ └─────────────┘ └──────────────┘ └────────────────────┘ │
│ │
│ ┌─────────────┐ ┌──────────────┐ ┌────────────────────┐ │
│ │ Velero │ │ Cert-Manager│ │ External DNS │ │
│ │ (Backup) │ │ (TLS) │ │ (DNS Automation) │ │
│ └─────────────┘ └──────────────┘ └────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Layer 1: Infrastructure With Terraform
The foundation is two Kubernetes clusters managed by Terraform — one on AWS (EKS) for services requiring AWS-native integrations, and one on Hetzner for cost-effective general workloads.
# terraform/main.tf
terraform {
required_version = ">= 1.5"
backend "s3" {
bucket = "robto-terraform-state"
key = "infrastructure/terraform.tfstate"
region = "eu-central-1"
encrypt = true
dynamodb_table = "terraform-locks"
}
}
module "aws_cluster" {
source = "./modules/eks-cluster"
cluster_name = "production-aws"
region = "eu-central-1"
kubernetes_version = "1.29"
node_groups = {
general = {
instance_types = ["m6i.xlarge"]
min_size = 3
max_size = 10
desired_size = 3
}
}
enable_cluster_autoscaler = true
}
module "hetzner_cluster" {
source = "./modules/hetzner-k3s"
cluster_name = "production-hetzner"
location = "fsn1"
k3s_version = "v1.29.2+k3s1"
control_plane = {
count = 3
server_type = "cpx31"
}
worker_nodes = {
count = 5
server_type = "cpx41"
}
}
# Shared networking: VPN tunnel between clouds
module "cross_cloud_vpn" {
source = "./modules/wireguard-tunnel"
aws_vpc_id = module.aws_cluster.vpc_id
hetzner_network = module.hetzner_cluster.network_id
tunnel_cidr = "10.99.0.0/24"
}
The key architectural decision: use a WireGuard tunnel between clouds for service-to-service communication. This gives you a flat network across providers without vendor-specific service mesh dependencies.
Terraform state is stored in S3 with encryption and locking, following the patterns from our infrastructure as code post. Each environment (staging, production, DR) has its own state file.
Layer 2: GitOps With ArgoCD
ArgoCD runs on the Hetzner cluster and manages both clusters. The app-of-apps pattern provides hierarchical control:
# argocd/app-of-apps.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: platform-root
namespace: argocd
spec:
project: default
source:
repoURL: https://gitlab.example.com/platform/gitops.git
targetRevision: main
path: argocd/applications
destination:
server: https://kubernetes.default.svc
namespace: argocd
syncPolicy:
automated:
prune: true
selfHeal: true
Inside argocd/applications/, each YAML file defines a component:
# argocd/applications/vault.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: vault
namespace: argocd
annotations:
argocd.argoproj.io/sync-wave: "1" # Deploy early
spec:
project: platform
source:
repoURL: https://gitlab.example.com/platform/gitops.git
targetRevision: main
path: clusters/hetzner/vault
helm:
valueFiles:
- values-production.yaml
destination:
server: https://kubernetes.default.svc
namespace: vault
syncPolicy:
automated:
prune: true
selfHeal: true
syncOptions:
- CreateNamespace=true
Sync waves control deployment order: Vault deploys first (wave 1), then cert-manager and external-dns (wave 2), then application workloads (wave 3+). This ensures dependencies are ready before consumers start.
For the AWS cluster, ArgoCD connects as a remote cluster:
# argocd/applications/aws-workloads.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: aws-workloads
namespace: argocd
spec:
project: workloads
source:
repoURL: https://gitlab.example.com/platform/gitops.git
targetRevision: main
path: clusters/aws/workloads
destination:
server: https://eks-production.eu-central-1.amazonaws.com
namespace: workloads
Layer 3: Secrets With Vault
HashiCorp Vault runs on Hetzner (HA mode with Raft storage) and serves secrets to both clusters. Applications access secrets through the Vault Agent Injector or the CSI driver:
# Example application deployment with Vault secret injection
apiVersion: apps/v1
kind: Deployment
metadata:
name: api-service
spec:
template:
metadata:
annotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "api-service"
vault.hashicorp.com/agent-inject-secret-db: "secret/data/api/database"
vault.hashicorp.com/agent-inject-template-db: |
{{- with secret "secret/data/api/database" -}}
DATABASE_URL=postgresql://{{ .Data.data.username }}:{{ .Data.data.password }}@{{ .Data.data.host }}:5432/{{ .Data.data.database }}
{{- end }}
spec:
serviceAccountName: api-service
containers:
- name: api
image: registry.example.com/api-service:latest
envFrom:
- secretRef:
name: vault-injected # Populated by Vault Agent
Vault policies enforce least privilege. Each service can access only its own secrets. The authentication chain is: Kubernetes ServiceAccount → Vault Kubernetes Auth → Vault Policy → Secret Access. No static credentials anywhere in the pipeline. This builds on the patterns detailed in our secrets management post.
Layer 4: Observability With OpenTelemetry and Grafana
The observability stack runs on the Hetzner cluster and collects data from both:
# OpenTelemetry Collector configuration
apiVersion: opentelemetry.io/v1alpha1
kind: OpenTelemetryCollector
metadata:
name: cluster-collector
spec:
mode: daemonset
config: |
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
prometheus:
config:
scrape_configs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
processors:
batch:
timeout: 10s
memory_limiter:
limit_mib: 512
resource:
attributes:
- key: cluster
value: ${CLUSTER_NAME}
action: upsert
exporters:
prometheusremotewrite:
endpoint: http://mimir:9009/api/v1/push
otlp:
endpoint: tempo:4317
loki:
endpoint: http://loki:3100/loki/api/v1/push
service:
pipelines:
metrics:
receivers: [otlp, prometheus]
processors: [memory_limiter, batch, resource]
exporters: [prometheusremotewrite]
traces:
receivers: [otlp]
processors: [memory_limiter, batch, resource]
exporters: [otlp]
logs:
receivers: [otlp]
processors: [memory_limiter, batch, resource]
exporters: [loki]
The Grafana stack (Mimir for metrics, Tempo for traces, Loki for logs, Grafana for visualization) provides unified observability across both clouds. Dashboards are provisioned through GitOps, following the patterns from our Grafana post.
Layer 5: Security and Policy
Kyverno policies enforce security standards across both clusters:
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: require-resource-limits
spec:
validationFailureAction: Enforce
rules:
- name: check-limits
match:
any:
- resources:
kinds:
- Pod
validate:
message: "CPU and memory limits are required."
pattern:
spec:
containers:
- resources:
limits:
memory: "?*"
cpu: "?*"
---
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: disallow-privileged
spec:
validationFailureAction: Enforce
rules:
- name: no-privileged
match:
any:
- resources:
kinds:
- Pod
validate:
message: "Privileged containers are not allowed."
deny:
conditions:
any:
- key: "{{ request.object.spec.containers[].securityContext.privileged }}"
operator: AnyIn
value: [true]
Network policies restrict cross-namespace communication. Pod security standards enforce non-root execution. Image scanning runs in the CI/CD pipeline before any image reaches the cluster. These layers stack to create defense in depth, as discussed in our Kubernetes security post.
Layer 6: The Developer Interface — GitLab CI/CD
Developers interact with this entire stack through GitLab. A typical developer workflow:
- Push code to a feature branch
- GitLab CI builds a container image, runs tests, performs security scans
- CI updates the image tag in the GitOps repository
- ArgoCD detects the change and deploys to staging automatically
- Developer verifies in staging, merges to main
- CI updates the production image tag
- ArgoCD deploys to production (with optional manual approval gate)
The CI pipeline template:
# .gitlab-ci.yml (uses golden path template)
include:
- project: 'platform/ci-templates'
file: '/templates/golden-path-microservice.yml'
variables:
SERVICE_NAME: my-api
DEPLOY_CLUSTERS:
value: "hetzner"
description: "Target clusters: hetzner, aws, or both"
That is the entire CI/CD configuration a developer writes. The golden path template — part of the internal developer platform — handles everything else.
Behind the scenes, the template updates image tags in the GitOps repository:
# Inside the CI template (simplified)
git clone ${GITOPS_REPO}
cd gitops/clusters/${TARGET_CLUSTER}/workloads/${SERVICE_NAME}
kustomize edit set image ${IMAGE_NAME}:${CI_COMMIT_SHA}
git add .
git commit -m "deploy: ${SERVICE_NAME} ${CI_COMMIT_SHA:0:8}"
git push
ArgoCD picks up the commit. The deployment rolls out. Grafana shows the deployment annotation. If health checks fail, ArgoCD rolls back automatically.
Disaster Recovery
The DR strategy follows our disaster recovery as code approach:
- Velero backs up Kubernetes resources and persistent volumes daily to cross-region object storage
- Database backups run every 6 hours with WAL archiving for point-in-time recovery
- Terraform maintains a DR environment definition (warm standby on a third cloud region)
- Automated DR tests run monthly through Ansible playbooks in the GitLab CI scheduled pipeline
Failover is a single pipeline trigger that scales up the DR site and updates DNS.
Cost Breakdown: Why Multi-Cloud
A common question: why run two clouds instead of one? The answer is cost optimization and risk reduction.
| Workload Type | Provider | Rationale |
|---|---|---|
| General compute | Hetzner | 60-70% cheaper than AWS for equivalent specs |
| AWS-dependent services | AWS EKS | Native integration with S3, SQS, RDS |
| Object storage (backups) | Both | Cross-cloud redundancy |
| Observability stack | Hetzner | High resource usage, cost-sensitive |
For a mid-size deployment (20 services, 3 environments), this architecture typically costs 40-50% less than an all-AWS equivalent while providing cloud-provider redundancy.
Repository Structure
The entire architecture lives in three Git repositories:
platform/infrastructure/ # Terraform code
├── modules/
│ ├── eks-cluster/
│ ├── hetzner-k3s/
│ └── wireguard-tunnel/
├── environments/
│ ├── production/
│ ├── staging/
│ └── dr/
└── terraform.tf
platform/gitops/ # ArgoCD application definitions
├── argocd/
│ └── applications/
├── clusters/
│ ├── aws/
│ │ ├── platform/ # Vault, monitoring agents
│ │ └── workloads/ # Application deployments
│ └── hetzner/
│ ├── platform/ # Vault, Grafana, ArgoCD
│ └── workloads/
└── base/ # Shared Kustomize bases
platform/ci-templates/ # Golden path CI/CD templates
├── templates/
│ ├── golden-path-microservice.yml
│ ├── docker-build.yml
│ ├── security-scan.yml
│ └── deploy-argocd.yml
└── scripts/
Everything is versioned. Everything is reviewable. Every change goes through a merge request. This is GitOps at organization scale.
Getting Started
You do not need to implement this entire architecture at once. Start with one cluster on Hetzner, ArgoCD for deployments, and Grafana for observability. Add Vault when you outgrow Kubernetes secrets. Add the second cloud when you have a business reason. Layer in policies and automation as your team grows.
The architecture is modular by design. Each component we have covered in this series can be adopted independently and integrated incrementally. The reference architecture shows where you are heading — the path there is walked one step at a time.
In our final post in this series, we step back from the technical details and discuss what CTOs should look for when choosing a DevOps partner — the questions to ask, the red flags to watch for, and what separates genuine expertise from buzzword compliance.