<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Hani on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Hani on Medium]]></description>
        <link>https://medium.com/@mhani18403?source=rss-6e54dac2825a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Fzq9LtTmLdH5gJ1Y</url>
            <title>Stories by Muhammad Hani on Medium</title>
            <link>https://medium.com/@mhani18403?source=rss-6e54dac2825a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 00:26:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mhani18403/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting Started with Tetragon for Security Observability in Kubernetes Clusters]]></title>
            <link>https://medium.com/@mhani18403/getting-started-with-tetragon-for-security-observability-in-kubernetes-clusters-870d9dbc34c2?source=rss-6e54dac2825a------2</link>
            <guid isPermaLink="false">https://medium.com/p/870d9dbc34c2</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[security-observabilty]]></category>
            <category><![CDATA[tracing-policy]]></category>
            <category><![CDATA[tetragon]]></category>
            <dc:creator><![CDATA[Muhammad Hani]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 18:30:33 GMT</pubDate>
            <atom:updated>2025-03-25T18:30:33.173Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>As cloud-native applications grow in complexity, security observability and enforcement become critical challenges. Kubernetes workloads interact dynamically, making it difficult to detect unauthorized activity, enforce security policies, and trace system events effectively. <strong>Tetragon</strong>, an open-source eBPF-based security observability and runtime enforcement tool by <strong>Cilium</strong>, addresses these challenges by providing <strong>real-time process monitoring, system call tracing, and policy enforcement</strong> at the kernel level.</p><p>Unlike traditional security tools that rely on logs or static rules, <strong>Tetragon leverages eBPF (Extended Berkeley Packet Filter)</strong> to trace system events with minimal performance overhead. It enables users to:</p><ul><li>Monitor <strong>process execution</strong>, <strong>network connections</strong>, and <strong>file access</strong> in real time.</li><li>Enforce security policies based on system behavior.</li><li>Detect anomalies and unauthorized access to critical resources.</li></ul><p>In this article, we’ll explore <strong>Tetragon’s architecture</strong> and how to <strong>deploy it in a Kubernetes cluster</strong> for enhanced security observability.</p><h3>Tetragon Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9T4aHSvmNJR2hr5TujO7bw.png" /><figcaption>Tetragon Architecture</figcaption></figure><p>Tetragon’s architecture consists of the following key components:</p><ol><li><strong>eBPF Programs</strong> — Tetragon deploys eBPF probes into the kernel to monitor system calls, process execution, and network events.</li><li><strong>Tracing Policies</strong> — Users define policies in YAML to specify what events to monitor and what actions to take (e.g., block a process, log an event).</li><li><strong>Tetragon Agent</strong> — Runs as a DaemonSet in Kubernetes, collecting and processing eBPF events.</li><li><strong>Exporters</strong> — Sends events to external systems like Prometheus, Fluentd, or SIEM tools.</li><li><strong>CRD (Custom Resource Definition)</strong> — Kubernetes-native way to define and manage tracing policies.</li></ol><h3>Setting Up Tetragon in a Kubernetes Cluster</h3><p>To deploy Tetragon in a Kubernetes cluster, follow these steps:</p><h3>1. Install Helm (if not already installed)</h3><p>Tetragon is deployed using Helm. Ensure Helm is installed:</p><pre>curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash</pre><h3>2. Setup Kubernetes Cluster with the following configuration:</h3><p>In this tutorial, I am using kind cluster with 1 control plane and 2 worker nodes.</p><p><strong>kind-config.yaml:</strong></p><pre>kind: Cluster<br>apiVersion: kind.x-k8s.io/v1alpha4<br>nodes:<br>  - role: control-plane<br>    extraMounts:<br>      - hostPath: /sys/kernel<br>        containerPath: /sys/kernel<br>  - role: worker<br>    extraMounts:<br>      - hostPath: /sys/kernel<br>        containerPath: /sys/kernel<br>  - role: worker<br>    extraMounts:<br>      - hostPath: /sys/kernel<br>        containerPath: /sys/kernel<br>networking:<br>  disableDefaultCNI: false<br>  kubeProxyMode: &quot;iptables&quot;</pre><p>Make the cluster by running the following command:</p><pre>kind create cluster --config kind-config.yaml</pre><h3>2. Add the Cilium Helm Repository</h3><pre>helm repo add cilium https://helm.cilium.io<br>helm repo update</pre><h3>3. Deploy Tetragon in the Cluster</h3><pre>helm install tetragon cilium/tetragon \<br>  --namespace kube-system \<br>  --set tetragon.enableBTF=true \<br>  --set tetragon.enableProcessCred=true \<br>  --set tetragon.enableProcessNs=true \<br>  --set tetragon.enableKernelEvents=true \<br>  --set tetragon.enableTracingPolicies=true \<br>  --set tetragon.bpf.mountPath=/sys/fs/bpf</pre><h3>4. Verify Installation</h3><p>Check if Tetragon pods are running:</p><pre>kubectl get pods -n kube-system | grep tetragon</pre><h3>5. View Logs and Events</h3><p>To see security events collected by Tetragon:</p><pre>kubectl logs -n kube-system -l k8s-app=tetragon -f</pre><h3>6. Understanding the Tracing Policy YAML File</h3><pre>apiVersion: &quot;cilium.io/v1alpha1&quot;<br>kind: TracingPolicy<br>metadata:<br>  name: &quot;block-writing&quot;<br>spec:<br>  kprobes:<br>    - call: &quot;sys_execve&quot;<br>      syscall: true<br>      args:<br>        - index: 0<br>          type: &quot;string&quot;<br>      selectors:<br>        - matchArgs:<br>            - index: 0<br>              operator: &quot;Equal&quot;<br>              values:<br>                - &quot;/usr/bin/mkdir&quot;<br>          matchActions:<br>            - action: Sigkill</pre><p>The given YAML file defines a <strong>Tetragon TracingPolicy</strong> that monitors and enforces security rules based on system calls. Let’s break down each section of the file:</p><blockquote>1. Basic Metadata</blockquote><pre>apiVersion: &quot;cilium.io/v1alpha1&quot;<br>kind: TracingPolicy<br>metadata:<br>  name: &quot;block-writing&quot;</pre><ul><li><strong>apiVersion</strong>: Specifies the API version (cilium.io/v1alpha1) used by Tetragon.</li><li><strong>kind</strong>: Indicates that this is a TracingPolicy, which defines what system calls to monitor and how to react.</li><li><strong>metadata.name</strong>: A unique name (block-writing) for the policy.</li></ul><blockquote>2. Specifying the System Call to Monitor (kprobes)</blockquote><pre>spec:<br>  kprobes:<br>    - call: &quot;sys_execve&quot;<br>      syscall: true<br>      args:<br>        - index: 0<br>          type: &quot;string&quot;</pre><ul><li><strong>call: &quot;sys_execve&quot;</strong> – Tetragon will hook into the execve system call, which is triggered when a new process is executed.</li><li><strong>syscall: true</strong> – Indicates that this is a syscall (as opposed to a kernel function).</li><li><strong>args</strong> – Defines the arguments to capture:</li><li><strong>index: 0</strong> – The first argument (argv[0]) of execve, which is typically the path to the executable.</li><li><strong>type: &quot;string&quot;</strong> – Ensures the argument is treated as a string.</li></ul><blockquote>3. Defining Selectors &amp; Actions (When to Block)</blockquote><pre>      selectors:<br>        - matchArgs:<br>            - index: 0<br>              operator: &quot;Equal&quot;<br>              values:<br>                - &quot;/usr/bin/mkdir&quot;<br>          matchActions:<br>            - action: Sigkill</pre><ul><li><strong>matchArgs</strong> – Filters events based on argument values.</li><li><strong>index: 0</strong> – Checks the first argument (argv[0]).</li><li><strong>operator: &quot;Equal&quot;</strong> – Matches if the argument exactly equals /usr/bin/mkdir.</li><li><strong>matchActions</strong> – Specifies the enforcement action</li><li><strong>action: Sigkill</strong> – If a match is found, Tetragon sends a SIGKILL signal, forcefully terminating the process.</li></ul><h3>Conclusion</h3><p>Tetragon, with its <strong>eBPF-based tracing and enforcement capabilities</strong>, provides <strong>deep visibility and security controls</strong> for Kubernetes workloads. By leveraging <strong>tracing policies</strong>, security teams can <strong>detect, log, and prevent malicious activities</strong> at the kernel level with minimal performance overhead.</p><p>By integrating <strong>Tetragon</strong> with existing security frameworks and monitoring tools, organizations can significantly <strong>enhance Kubernetes security</strong>, enforce runtime policies, and <strong>prevent potential threats before they escalate</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=870d9dbc34c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring Kubernetes Cluster With Grafana and Prometheus]]></title>
            <link>https://medium.com/@mhani18403/monitoring-kubernetes-cluster-with-grafana-and-prometheus-7a3fc1032e56?source=rss-6e54dac2825a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a3fc1032e56</guid>
            <category><![CDATA[kubernetes-monitoring]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[prometheus]]></category>
            <dc:creator><![CDATA[Muhammad Hani]]></dc:creator>
            <pubDate>Tue, 02 Jul 2024 16:38:12 GMT</pubDate>
            <atom:updated>2024-07-02T16:47:27.512Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s cloud-native ecosystem, Kubernetes has become the standard for container orchestration. It enables the automation of deployment, scaling, and management of containerized applications. However, managing a Kubernetes cluster can be challenging without the right monitoring tools in place. That’s where Grafana and Prometheus come in.</p><h4>Introduction to Grafana and Prometheus</h4><p>To monitor and visualize the health and performance of your Kubernetes clusters, you need robust monitoring tools like Prometheus and Grafana.</p><p><strong>Prometheus</strong> is an open-source monitoring and alerting toolkit originally built at SoundCloud. It has a multi-dimensional data model with time series data identified by metric name and key/value pairs.</p><p><strong>Grafana</strong> is an open-source platform for monitoring and observability. It provides a powerful and flexible way to visualize your metrics, logs, and traces. Grafana allows you to query, visualize, alert on, and understand your metrics no matter where they are stored. Key features include:</p><ul><li><strong>Beautiful visualizations</strong>: Create, explore, and share dashboards with your team.</li><li><strong>Multiple data sources</strong>: Support for Prometheus, InfluxDB, Graphite, Elasticsearch, and many others.</li><li><strong>Alerting</strong>: Create, manage, and receive alerts directly in Grafana.</li><li><strong>Extensible</strong>: Plugins for data sources, panels, and apps.</li></ul><p><strong>Setup Prometheus and Grafana using Minikube</strong></p><p>Follow the steps below to setup prometheus and grafana on kubernetes. Make sure you have some application pods running in minikube cluster.</p><p>First add prometheus and grafana repos using helm.</p><pre>helm repo add prometheus-community https://prometheus-community.github.io/helm-charts</pre><pre>helm repo add grafana https://grafana.github.io/helm-charts</pre><pre>helm repo update</pre><p>Then install grafana and prometheus using helm</p><pre>helm install prometheus prometheus-community/prometheus</pre><pre>helm install grafana grafana/grafana</pre><p>Expose prometheus server to port 9090 and grafana service to port 3000.</p><pre>kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-svc</pre><pre>kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-svc</pre><p>Type minikube service prometheus-server-svc` to open the prometheus dashboard. It will look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W978dEBqmqSfwWb38yHGng.jpeg" /><figcaption>Prometheus Dashboard</figcaption></figure><p>Open a new terminal and type the command minikube service grafana-svc`. It will open the Grafana dashboard on the browser.</p><p>Type `kubectl get secret — namespace default grafana -o jsonpath=”{.data.admin-password}” | base64 — decode ; echo` to get grafana dashboard password and login</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_AsH2iOfIDn8_Val2oWzw.jpeg" /><figcaption>Grafana Dashboard</figcaption></figure><p>Go to Connections -&gt; Data Sources and select prometheus as data source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yo6ZFRs2z7qqCpXdxEOm4w.jpeg" /><figcaption>Prometheus Data Source Screen</figcaption></figure><p>Enter the “Prometheus server URL” by running the command minikube service prometheus-server-svc` in the terminal. Enter the cluster IP which in my case is <strong>192.168.49.2</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*87sKKy5_aCj986q4PAXLTQ.jpeg" /><figcaption>Getting prometheus local IP</figcaption></figure><p>Now click save and test and then go to Dashboards -&gt; Import Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XHHLSEO2shH_sYN2ywvRsQ.jpeg" /><figcaption>Importing dashboard</figcaption></figure><p>Add the dashboard ID from <a href="https://grafana.com/grafana/dashboards/">https://grafana.com/grafana/dashboards/</a>. As I have Node applications running in pods so I have selected the Node Dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrlK3eVmsjqXX8VItiRamw.jpeg" /><figcaption>Grafana Dashboard for NodeJS</figcaption></figure><p><strong>Conclusion</strong></p><p>Monitoring the resource usage of Kubernetes pods is essential for maintaining the optimal performance and efficiency of your cluster. Prometheus and Grafana provide a powerful combination of monitoring and visualization tools that enable administrators to gain deep insights into the behavior of their pods.</p><p><strong>References</strong></p><ul><li><a href="https://github.com/rchidana/K8s-SetUp/blob/main/Monitoring.md">K8s-SetUp/Monitoring.md at main · rchidana/K8s-SetUp</a></li><li><a href="https://medium.com/cloud-native-daily/monitoring-kubernetes-pods-resource-usage-with-prometheus-and-grafana-c17848febadc">Monitoring Kubernetes Pods Resource Usage with Prometheus and Grafana</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a3fc1032e56" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>