<?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 Mohammad Zaman on Medium]]></title>
        <description><![CDATA[Stories by Mohammad Zaman on Medium]]></description>
        <link>https://medium.com/@mfzhsn?source=rss-96182e6604de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*iJ7YbVsk5dS4hYQi</url>
            <title>Stories by Mohammad Zaman on Medium</title>
            <link>https://medium.com/@mfzhsn?source=rss-96182e6604de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:36:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mfzhsn/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[Map files in Kubernetes Pod]]></title>
            <link>https://medium.com/@mfzhsn/map-files-in-kubernetes-pod-1de0d6c3319f?source=rss-96182e6604de------2</link>
            <guid isPermaLink="false">https://medium.com/p/1de0d6c3319f</guid>
            <dc:creator><![CDATA[Mohammad Zaman]]></dc:creator>
            <pubDate>Thu, 01 Aug 2024 12:53:34 GMT</pubDate>
            <atom:updated>2024-08-01T12:53:34.858Z</atom:updated>
            <content:encoded><![CDATA[<p>Pods are the simplest elements of the Kubernetes ecosystem, essentially containers. In Kubernetes, pods are ephemeral and don’t have persistent storage on their own. However, many applications require data persistence to maintain state, or database apps need data to persist across pod restarts.</p><p>Fortunately, Kubernetes has the capability to attach a physical volume to pods, ensuring data is preserved even when pods are reloaded or respawned.</p><p>When it comes to mounting files, you can either mount an entire directory or just a single file to an existing location inside a pod. In this blog, I will be demonstrating the latter.</p><p><strong>Mounting File to an existing path inside POD</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVY7aoZbD2zJqwNZ1FeI4Q.png" /></figure><p>In some conditions, directory are already present inside the pods and only files needs to be places inside the specific folder.</p><p>Step-1: Create a configmap</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: topology<br>data:<br>  topology: |-<br>    model:<br>      &quot;model_year&quot;: 2004<br>      &quot;base_mac&quot; : 00:01:01:00:00:00<br>      &quot;batch&quot; : 55867455854dA<br>      &quot;product_name&quot;: &quot;cloudNative&quot;<br>    metrics:<br>      1:<br>        &quot;through_put&quot;: 500<br>        &quot;drop_rate&quot;: 0.001</pre><p>Verify the configmap:</p><pre>[root@master cloudlab]# kubectl get configmap topology<br>NAME       DATA   AGE<br>topology   1      92d</pre><p>Step-2: Create a pod/deployment definition file, Example deployment definition file</p><pre>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: web<br>  labels:<br>    app: web<br>spec:<br>  replicas: 2<br>  selector:<br>    matchLabels:<br>      app: web<br>  template:<br>    metadata:<br>      labels:<br>        app: web<br>    spec:<br>      containers:<br>      - name: web-server<br>        image: ngnix:latest<br>        imagePullPolicy: IfNotPresent<br>        volumeMounts:<br>        - mountPath: /tmp/topology.yml<br>          subPath: topology<br>          name: topology<br>      volumes:<br>      - name: topology<br>        configMap:<br>          name: topology</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1de0d6c3319f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PCI-PassThrough for High Performance Apps in Kubernetes Cluster]]></title>
            <link>https://medium.com/@mfzhsn/pci-passthrough-for-high-performance-apps-in-kubernetes-cluster-375848c2a632?source=rss-96182e6604de------2</link>
            <guid isPermaLink="false">https://medium.com/p/375848c2a632</guid>
            <category><![CDATA[telco-cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[pci-passthrough]]></category>
            <dc:creator><![CDATA[Mohammad Zaman]]></dc:creator>
            <pubDate>Sun, 24 Dec 2023 22:09:45 GMT</pubDate>
            <atom:updated>2023-12-24T22:09:45.379Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qfu9ASfSt31uFLiyJzQRRQ.png" /></figure><p>In the realm of Kubernetes, achieving near-native performance with low latency is imperative for applications demanding high performance like Telco App which operates on extreme time-sensitive.</p><p>Networking between the pods in kubernetes cluster is taken care by the Container Networking Interface — CNI where they map either to Node Port, Cluster IP or Service IP. During situations where the traffic leaving external to kubernetes cluster with a requirement of high speed with low latency can be accomplished through the utilization of SR-IOV or PCI-PassThrough.</p><p>PCI Pass Through is technology where the VMs or the kubernetes PODs/containers will have exclusive access to the physical network-interface without any interruptions from the server kernel resulting in high performance and low latency due to less overhead.</p><p>Following are the steps which needs to be followed to allow PCI-PT to pods.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*oRrA5WsOCwJkD4aZ4z1g9g.png" /><figcaption>In the diagram above the NIC-1 on the left is illustrated to be with PCI-PT where there is no interruptions from the host operating-system.</figcaption></figure><p><strong>Host Part:</strong></p><p>Pre-requisites to enable PCI-PT at worker nodes.</p><p>Make sure the IOMMU is enabled in kernel parameters and it can verified by below command.</p><pre>[root@localhost ~]# dmesg | grep -e DMAR -e IOMMU<br>[    0.018415] ACPI: DMAR 0x00000000A2CE0000 000230 (v01 HPE    Server   00000001 1590 00000001)<br>[    0.018450] ACPI: Reserving DMAR table memory at [mem 0xa2ce0000-0xa2ce022f]<br>[    0.037108] DMAR: IOMMU enabled</pre><p>Load the vfio modules in the worker nodes.</p><pre>modprobe vfio<br>modprobe vfio_iommu_type1<br>modprobe vfio_pci</pre><p>Before loading the new driver to the network-interface, we can check the associated drivers with it using the below command.</p><p>In my worker host machine, the network-interface eno6 has the pciBusID of 5d:00.1.</p><pre>[root@localhost ~]# tree /sys/bus/pci/devices/0000\:5d\:00.1/ | grep driver<br>├── driver -&gt; ../../../../bus/pci/drivers/i40e<br>├── driver_override<br>├── sriov_drivers_autoprobe</pre><p>Bind the NIC to the vfio driver using the driverctl utility.</p><pre>driverctl set-override 0000:5d:00.1 vfio-pci</pre><p>Verify to make sure the network-interface is successfully associated with new vfio driver.</p><pre>[root@localhost ~]# tree /sys/bus/pci/devices/0000\:5d\:00.1/ | grep driver<br>├── driver -&gt; ../../../../bus/pci/drivers/vfio-pci<br>├── driver_override<br>├── sriov_drivers_autoprobe</pre><p>Now the network-interface is moved from host userspace and you should not see this network-interface in the base worker node.</p><p><strong>Kubernetes Part:</strong></p><p>In order for us to connect this network-interface to a POD in kubernetes, we need to first create a network-attachment-definition as below with type as host-device and passing the whole network interface using pciBusID</p><pre>---<br>apiVersion: k8s.cni.cncf.io/v1<br>kind: NetworkAttachmentDefinition<br>metadata:<br>  name: pci-pt-interface-1<br>spec:<br>  config: &#39;{<br>    &quot;cniVersion&quot;: &quot;0.4.0&quot;,<br>    &quot;name&quot;: &quot;net1&quot;,<br>    &quot;type&quot;: &quot;host-device&quot;,<br>    &quot;pciBusID&quot;: &quot;0000:5d:00.1&quot;,<br>    &quot;ipam&quot;: {<br>      &quot;type&quot;: &quot;whereabouts&quot;,<br>      &quot;range&quot;: &quot;10.77.50.0/24&quot;,<br>      &quot;routes&quot;: [<br>        { &quot;dst&quot;: &quot;0.0.0.0/0&quot; }<br>      ],<br>      &quot;gateway&quot;: &quot;10.77.50.1&quot;<br>    }<br>  }&#39;</pre><p>Next, Create a Deployment / Daemon-Set with the newly created network-attachment-definition as annotation.</p><pre>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: linux-app<br>  labels:<br>    app: linux-app<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: linux-app<br>  template:<br>    metadata:<br>      labels:<br>        app: linux-app<br>      annotations:<br>        k8s.v1.cni.cncf.io/networks: pci-pt-interface-1<br>~<br>snip<br>~</pre><p><strong>Verification:</strong></p><p>From the events, you can see two interfaces are added to the pod.</p><pre>[root@master ~]# kubectl describe pods pod0-case-01<br>Name:             pod0-case-01<br>Namespace:        default<br><br>---- snip -----<br><br>Events:<br>  Type    Reason          Age   From               Message<br>  ----    ------          ----  ----               -------<br>  Normal  Scheduled       22m   default-scheduler  Successfully assigned default/pod0-case-01 to worker1.mozaman.lab<br>  Normal  AddedInterface  22m   multus             Add eth0 [192.168.102.29/32] from k8s-pod-network<br>  Normal  AddedInterface  22m   multus             Add net1 [10.77.50.1/24] from default/pci-pt-interface-1</pre><p>Once you login to the pod, you can list the interfaces too.</p><pre>[root@linux-app-855fd88bc6-krd6x /]# ip a sh<br>52: n5d-00-1-0@if5: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc noqueue state UP group default qlen 1000<br>    link/ether 32:95:97:7e:91:f0 brd ff:ff:ff:ff:ff:ff link-netns pci-pt-default<br>    inet6 fe80::3095:97ff:fe7e:91f0/64 scope link<br>       valid_lft forever preferred_lft forever</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=375848c2a632" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>