<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Charles Okojie]]></title><description><![CDATA[Charles Okojie]]></description><link>https://charlzdev.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6998b3d73dc17c486201bba6/aa43a93b-2099-409d-af00-ec35f211e0b3.jpg</url><title>Charles Okojie</title><link>https://charlzdev.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 21:43:11 GMT</lastBuildDate><atom:link href="https://charlzdev.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[I Deployed a 5G Core on Kubernetes With Real GTP Tunnels - Here's What Actually Broke]]></title><description><![CDATA[A technical journey of building a production-ready 5G SA core using free5GC, ArgoCD, and custom Prometheus observability on K8s.]]></description><link>https://charlzdev.hashnode.dev/i-deployed-a-5g-core-on-kubernetes-with-real-gtp-tunnels-here-s-what-actually-broke</link><guid isPermaLink="true">https://charlzdev.hashnode.dev/i-deployed-a-5g-core-on-kubernetes-with-real-gtp-tunnels-here-s-what-actually-broke</guid><category><![CDATA[5G]]></category><category><![CDATA[free5gc]]></category><category><![CDATA[Devops]]></category><category><![CDATA[#prometheus]]></category><category><![CDATA[Telecommunications]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Idemudia Charles Okojie]]></dc:creator><pubDate>Tue, 12 May 2026 01:09:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6998b3d73dc17c486201bba6/e470df93-a076-40f2-9d2b-16f3598fdb75.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Background</h2>
<p>I'm a Packet Core &amp; Cloud SME at Ericsson Nigeria. My day job is EPC - GTP and Diameter traces, EPC node troubleshooting and performing configurations. I know 4G deeply, but needed to build something publicly showcasing my skills in cloud-native 5G (SA), Helm, ArgoCD, Prometheus, GitOps, Kubernetes.</p>
<p>So, I designed a self-directed portfolio project: deploy a full 5G SA core on Kubernetes, instrument it properly, build a GitOps pipeline around it, and make the whole thing publicly observable. Not a tutorial follow-along. A real engineering build, documented honestly.</p>
<p>This post covers the weekly activity breakdown .</p>
<p>The stack at the end of Week 8:</p>
<ul>
<li><p><strong>free5GC v4.2</strong> - all 12 NFs, source-built Docker images</p>
</li>
<li><p><strong>k3s v1.34.5</strong> on GCP spot VM (t2d-standard-2)</p>
</li>
<li><p><strong>UERANSIM (gNB + UE)</strong> on another GCP spot VM (t2d-standard-1)</p>
</li>
<li><p><strong>Cilium v1.19.1</strong> as the secondary CNI, Multus-primary architecture</p>
</li>
<li><p><strong>gtp5g v0.9.14</strong> - real kernel GTP-U module, not simulated</p>
</li>
<li><p><strong>kube-prometheus-stack</strong> - Prometheus + Grafana + Alertmanager</p>
</li>
<li><p><strong>ArgoCD v3.3.7</strong> - GitOps push-to-sync</p>
</li>
<li><p><strong>GitHub Actions</strong> - image builds, GHCR push</p>
</li>
<li><p><strong>Cloudflare Tunnel</strong> - public access without LoadBalancer or NodePort exposure</p>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6998b3d73dc17c486201bba6/97af1be6-4d3b-40b5-a997-5ce4b84d656c.svg" alt="" style="display:block;margin:0 auto" />

<p><strong>Fig. 1: A high-level overview of the GCP infrastructure deployment within the</strong> <code>us-south1-a</code> <strong>region</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6998b3d73dc17c486201bba6/2842bccc-715e-47d5-b370-699faf399abf.svg" alt="" style="display:block;margin:0 auto" />

<p><strong>Fig. 2: free5GC v4.2 Service-Based Architecture (SBA) and 3GPP reference point mapping</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6998b3d73dc17c486201bba6/6d737056-dfa5-4070-99de-9e9b383400fc.png" alt="" style="display:block;margin:0 auto" />

<p>Fig. 3: End-to-end pipeline: from a git push to a live public Grafana dashboard</p>
<hr />
<h2>Observability Week - Prometheus and Grafana</h2>
<p>I ran the NFs before bolting on monitoring.</p>
<pre><code class="language-plaintext">helm upgrade --install kube-prometheus-stack \
  prometheus-community/kube-prometheus-stack \
  --namespace monitoring --create-namespace \
  -f monitoring/values.yaml
</code></pre>
<p>The first decision point: <strong>how do I expose Grafana publicly?</strong></p>
<p>I evaluated two options:</p>
<ul>
<li><p><code>ingress-nginx</code> (kubernetes/ingress-nginx) - retired March 2026, immediately ruled out.</p>
</li>
<li><p><strong>Cloudflare Tunnel</strong> - won. Zero open ports, free tier, works with any ClusterIP.</p>
</li>
</ul>
<p>Cloudflare Tunnel runs as a systemd service on the core-5g VM and creates an outbound-only connection to Cloudflare's edge. Traffic for <code>grafana.niv-dev.xyz</code> routes through Cloudflare → tunnel → ClusterIP. No LoadBalancer.</p>
<pre><code class="language-yaml"># /etc/cloudflared/config.yml
tunnel: free5gc-lab
credentials-file: /root/.cloudflared/&lt;TUNNEL-ID&gt;.json
ingress:
  - hostname: grafana.niv-dev.xyz
    service: http://&lt;GRAFANA-CLUSTERIP&gt;:80
  - hostname: argocd.niv-dev.xyz
    service: http://&lt;ARGOCD-CLUSTERIP&gt;:80
  - service: http_status:404
</code></pre>
<p>One non-obvious lesson: <strong>the service runs as root but the credentials live in</strong> <code>~/.cloudflared/</code>. The fix is a single copy:</p>
<pre><code class="language-bash">sudo mkdir -p /root/.cloudflared
sudo cp ~/.cloudflared/&lt;TUNNEL-ID&gt;.json /root/.cloudflared/
</code></pre>
<p>Dashboard provisioning went in as ConfigMaps - the right pattern for GitOps:</p>
<pre><code class="language-yaml">apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-upf-dashboard
  namespace: monitoring
  labels:
    grafana_dashboard: "1"
data:
  upf-gtp5g-dashboard.json: |
    { ... }
</code></pre>
<p>Grafana picks these up automatically via the sidecar. No manual import needed after a restart.</p>
<hr />
<h2>GitOps Week - Helm, ArgoCD, and the First Push-to-Sync</h2>
<p>With observability in place, I Helm-parameterised all 12 NFs and installed ArgoCD.</p>
<p>The Helm chart covers <code>image</code>, <code>replicas</code>, and <code>metrics</code> fields for every NF via a single <code>values.yaml</code>. The key insight from this week: <strong>free5GC NF configuration has a strict nesting requirement</strong> that cost me significant debugging time.</p>
<p>The metrics block must be nested under <code>configuration:</code>, not at the top level:</p>
<pre><code class="language-yaml"># WRONG - metrics block at top level, silently ignored
configuration:
  ...
metrics:
  enable: true
  bindingIP: 0.0.0.0
  bindingPort: 9089

# CORRECT - nested under configuration
configuration:
  metrics:
    enable: true
    bindingIP: 0.0.0.0
    bindingPort: 9089
</code></pre>
<p>ArgoCD installation was straightforward. The Application manifest:</p>
<pre><code class="language-yaml">apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: free5gc
  namespace: argocd
spec:
  source:
    repoURL: https://github.com/Charlz234/free5gc-k8s
    targetRevision: HEAD
    path: helm/free5gc
  destination:
    server: https://kubernetes.default.svc
    namespace: free5gc
  syncPolicy:
    automated:
      prune: true
      selfHeal: true
</code></pre>
<p>First verified push-to-sync: committed a replica count change, watched ArgoCD detect the drift and self-heal within 30 seconds. 37 resources synced. That moment where the GitOps loop closes for the first time is worth the hours of setup.</p>
<hr />
<h2>CI/CD Week - GitHub Actions and Source-Built Images</h2>
<p>I evaluated Tekton first. Rejected it - too much overhead for a two-repo setup. GitHub Actions gives you the pipeline without the cluster footprint.</p>
<p>Two workflows:</p>
<p><code>build-nf-images.yml</code> - triggered on changes to NF source. Builds each free5GC NF from source (not DockerHub), pushes to GHCR. This is why the metrics work: the official <code>free5gc/*:v4.2.0</code> DockerHub images don't start the Prometheus HTTP server on port 9089 despite having the config entries. Source builds do.</p>
<p><code>build-exporter.yml</code> - builds the gtp5g Prometheus exporter (custom Go binary that reads <code>/proc/gtp5g/</code> kernel stats). 8 successful runs as of Week 8.</p>
<p>All images are public on GHCR. No <code>imagePullSecret</code> needed in the cluster.</p>
<p>The NF startup order is strict and must be enforced via init containers:</p>
<pre><code class="language-plaintext">mongodb → nrf → udr → udm → ausf → pcf → nssf → nef → amf → upf → smf → webui
</code></pre>
<p>UPF must come before SMF. This is non-negotiable - SMF sends PFCP Session Establishment to UPF on startup. If UPF isn't ready, SMF panics.</p>
<hr />
<h2>CP Metrics Week - All 8 NFs on Prometheus</h2>
<p>This week I got all 8 control plane NFs exposing Prometheus metrics on port 9089 via ServiceMonitors.</p>
<p>The ServiceMonitor selector must match the pod label exactly:</p>
<pre><code class="language-yaml">selector:
  matchLabels:
    app: amf  # must match pod label, not deployment name
</code></pre>
<p>ClusterIPs are dynamic - ServiceMonitors use label selectors for auto-discovery. Never hardcode a ClusterIP in a ServiceMonitor.</p>
<p>Three Grafana panels provisioned:</p>
<ul>
<li><p><strong>SBI Latency p99 per NF</strong> - <code>histogram_quantile(0.99, sum by (job, le) (rate(free5gc_sbi_inbound_request_duration_seconds_bucket[1m])))</code></p>
</li>
<li><p><strong>Active PDU Sessions</strong> - <code>sum(free5gc_amf_business_active_pdu_session_current_count)</code></p>
</li>
<li><p><strong>SBI Request Rate per NF</strong> - <code>sum by (job) (rate(free5gc_sbi_inbound_request_duration_seconds_count[1m]))</code></p>
</li>
</ul>
<p>The AMF metric <code>free5gc_amf_business_active_pdu_session_current_count{access_type="3GPP_ACCESS"}</code> is the reliable source for PDU session count. With 4 UEs registered it reads <code>4</code>. This is CP-side truth.</p>
<hr />
<h2>Data Plane Week - The gtp5g Exporter and Live UPF Traffic</h2>
<p>The UPF is where the interesting data lives. GTP tunnel counters, per-UE throughput, packet rates - this is the data plane.</p>
<p>The official free5GC UPF image doesn't expose these. I wrote a custom Go exporter that reads <code>/proc/gtp5g/</code> via the kernel interface and exposes them as Prometheus metrics:</p>
<pre><code class="language-plaintext">free5gc_upf_gtp_ul_bytes_total{ue_addr, seid}
free5gc_upf_gtp_dl_bytes_total{ue_addr, seid}
free5gc_upf_gtp_ul_packets_total{ue_addr, seid}
free5gc_upf_gtp_dl_packets_total{ue_addr, seid}
free5gc_upf_interface_rx_bytes_total{interface}
free5gc_upf_interface_tx_bytes_total{interface}
</code></pre>
<p>The exporter runs in the <code>monitoring</code> namespace (not <code>free5gc</code>) because it reads host-level <code>/proc/gtp5g/</code> - it needs to be on the same node as the UPF but doesn't need to be in the same pod.</p>
<p>UPF Grafana dashboard panels:</p>
<ul>
<li><p>Interface RX/TX bytes (bps)</p>
</li>
<li><p>UL Throughput per UE</p>
</li>
<li><p>DL Throughput per UE</p>
</li>
<li><p>UL/DL Packets per UE</p>
</li>
<li><p>Active UE Sessions - <code>count(count by (seid) (free5gc_upf_gtp_ul_bytes_total))</code></p>
</li>
</ul>
<p>I set this as the default Grafana dashboard. The CP NF dashboard is accurate but flat between registration events - not useful for a live demo. The UPF dashboard shows live traffic whenever a UE is attached and pinging.</p>
<p><strong>Known issue documented:</strong> The Active UE Session count (<code>count by seid</code>) doesn't decrease immediately when a UE is killed (gracefully or ungracefully). The kernel GTP tunnel persists because SMF never sends a PFCP Session Deletion Request. Recovery: restart UPF and SMF together. Always restart AMF too - AMF holds registration state in memory and doesn't clear it on UPF/SMF restart, leading to ghost UE counts.</p>
<hr />
<h2>Hardening Week - Cloudflared, Startup Scripts, and README</h2>
<p>Week 8 was consolidation:</p>
<ul>
<li><p><strong>Cloudflared rebuilt from scratch</strong> after diagnosing the root cause of persistent failures (credentials not copied to <code>/root/.cloudflared/</code> for the root-running systemd service)</p>
</li>
<li><p><strong>Startup script hardened</strong> - monitoring manifests (exporter deployment, service, ServiceMonitor, dashboard ConfigMaps) added to the apply block</p>
</li>
<li><p><strong>Audience access model documented</strong> - port-forward + SSH tunnel for anyone running the lab without Cloudflare.</p>
</li>
<li><p><strong>README rewritten</strong> for <code>5gcore-cloudnative-lab</code> - covers Weeks 1–7, GCP-only architecture, quick start, UERANSIM setup, cost table.</p>
</li>
</ul>
<p>Infrastructure state at end of Week 8:</p>
<table>
<thead>
<tr>
<th>Component</th>
<th>Detail</th>
</tr>
</thead>
<tbody><tr>
<td>core-5g VM</td>
<td>GCP t2d-standard-2, us-south1-a, 10.0.2.3</td>
</tr>
<tr>
<td>ueransim VM</td>
<td>GCP t2d-standard-1, 10.0.2.2</td>
</tr>
<tr>
<td>k3s</td>
<td>v1.34.5</td>
</tr>
<tr>
<td>Cilium</td>
<td>v1.19.1 (Multus-primary)</td>
</tr>
<tr>
<td>gtp5g</td>
<td>v0.9.14 (gcc-12)</td>
</tr>
<tr>
<td>Grafana</td>
<td>grafana.niv-dev.xyz (live, anonymous viewer)</td>
</tr>
<tr>
<td>ArgoCD</td>
<td>argocd.niv-dev.xyz</td>
</tr>
<tr>
<td>IMSI</td>
<td>imsi-208930000000001, uesimtun0 10.60.0.0/16</td>
</tr>
<tr>
<td>Ping</td>
<td>8.8.8.8, 0% loss</td>
</tr>
</tbody></table>
<hr />
<h2>What I Would Do Differently</h2>
<p><strong>1. Build NF images from source from day one.</strong> The DockerHub images look convenient but they don't expose metrics. You'll rebuild them anyway - just start there.</p>
<p><strong>2. Lock</strong> <code>pfcp.nodeID</code> <strong>to a stable value in Helm immediately.</strong> Dynamic ClusterIPs and PFCP don't mix. This caused the most painful debugging session of the project.</p>
<p><strong>3. Restart the full NF stack atomically.</strong> When clearing lab state, always restart AMF + SMF + UPF together. Partial restarts leave ghost state that corrupts metrics.</p>
<hr />
<h2>Links</h2>
<ul>
<li><p><strong>Live Grafana dashboard:</strong> <a href="https://grafana.niv-dev.xyz">grafana.niv-dev.xyz</a></p>
</li>
<li><p><strong>K8s manifests + Helm chart:</strong> <a href="https://github.com/Charlz234/free5gc-k8s">github.com/Charlz234/free5gc-k8s</a></p>
</li>
<li><p><strong>Terraform IaC + portfolio docs:</strong> <a href="https://github.com/Charlz234/5gcore-cloudnative-lab">github.com/Charlz234/5gcore-cloudnative-lab</a></p>
</li>
</ul>
<hr />
<p><em>Charles Okojie is a Packet Core &amp; Cloud SME at Ericsson Nigeria. This post is part of a 60-day cloud-native 5G portfolio project.</em></p>
]]></content:encoded></item></channel></rss>