<?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 Anik Barua on Medium]]></title>
        <description><![CDATA[Stories by Anik Barua on Medium]]></description>
        <link>https://medium.com/@onixoni72?source=rss-967f50af18a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iSQq1p3NNGGP-xHrPyIOLg.jpeg</url>
            <title>Stories by Anik Barua on Medium</title>
            <link>https://medium.com/@onixoni72?source=rss-967f50af18a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 17:07:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@onixoni72/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[Linkerd: Our Choice for Kubernetes Service Mesh]]></title>
            <link>https://medium.com/@onixoni72/linkerd-our-choice-for-kubernetes-service-mesh-d04c842c2200?source=rss-967f50af18a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d04c842c2200</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[istio]]></category>
            <category><![CDATA[linkerd]]></category>
            <category><![CDATA[k8s]]></category>
            <category><![CDATA[service-mesh]]></category>
            <dc:creator><![CDATA[Anik Barua]]></dc:creator>
            <pubDate>Sat, 11 May 2024 23:50:41 GMT</pubDate>
            <atom:updated>2024-05-11T23:50:41.988Z</atom:updated>
            <content:encoded><![CDATA[<p>As we continue to evolve our Kubernetes infrastructure, we’ve made a strategic decision to adopt <a href="https://linkerd.io/"><strong>Linkerd</strong></a> as our service mesh. In this blog post, we’ll dive into why we chose Linkerd, its functionalities, and how it benefits our operations.</p><p>Some thoughts before our decision</p><ul><li>Make operational simplicity for a smaller project with a smaller team</li><li>We don’t want us to need a team just to manage Kubernetes</li><li>Try to keep configuration as simple as easy</li><li>Don’t want to spend more resources/money on infrastructure rather then actual business workloads</li></ul><h3>What is Linkerd?</h3><p>Linkerd is a service mesh designed for Kubernetes. In simple terms, a service mesh helps manage the communication between services in a micro-services architecture. Think of it as a “network for services” rather than bytes.</p><h3>Why Linkerd?</h3><ol><li><strong>Operational Simplicity</strong>: One of the standout features of Linkerd is its simplicity. It’s designed to be straightforward to install, configure, and maintain. This means faster deployment times and less operational overhead for our team.</li><li><strong>Performance</strong>: Linkerd is lightweight and designed for high performance. It adds minimal latency to our service calls, ensuring our applications remain responsive.</li><li><strong>Resource &amp; Cost Efficiency</strong>: Linkerd consumed significantly fewer system resources than any other service-mesh</li><li><strong>Security</strong>: With Linkerd’s policy engine, we can secure service-to-service calls, ensuring that our internal communications are safe from unauthorized access.</li></ol><h3>Core Components of Linkerd:</h3><h4><strong>Data Plane</strong>:</h4><ul><li><strong>Proxy</strong>: Every instance of a service in Linkerd has a lightweight, ultra-fast proxy alongside it. This proxy handles all network communication, ensuring it’s secure and efficient.</li><li><strong>How it works</strong>: When Service A wants to talk to Service B, it sends the request to its proxy. This proxy communicates with the proxy of Service B, which then forwards the request to Service B.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SEV8lEXkYafu20Qg0RzRbw.png" /></figure><p>This happens transparently, with no change required in the application code or its container configuration</p><h4><strong>Control Plane</strong>:</h4><p>This is the brain behind Linkerd. It provides the necessary tools and APIs to manage the entire service mesh.</p><p><strong>Components</strong>:</p><ul><li><strong>Identity</strong>: Provides certificates for mTLS (mutual TLS), ensuring secure communication.</li><li><strong>Proxy Injector</strong>: Automatically adds the Linkerd proxy to pods.</li><li><strong>Destination</strong>: Helps the proxies discover service addresses.</li><li><strong>Web &amp; Grafana</strong>: Provides a UI and dashboards for observability.</li></ul><h4><strong>mTLS (mutual TLS)</strong>:</h4><p>Ensures secure communication between services. Both the sender and receiver verify each other’s identities.</p><h4><strong>Traffic Splits</strong>:</h4><p>Allows us to route traffic between different versions of a service. Useful for canary deployments and blue-green deployments.</p><h4><strong>Policy Engine</strong>:</h4><p>The Policy Engine in Linkerd is a powerful tool that provides fine-grained control over how services communicate with each other. It’s not just about allowing or denying access; it’s about defining the rules of engagement for our services.</p><blockquote>No need external tools/service, its comes along with Linkerd Engine</blockquote><p><strong>Key Features of the Policy Engine:</strong></p><ul><li><strong>Authorization</strong>: Define which services can communicate with each other. For instance, if you have a frontend service and a backend service, you can define a policy that only allows the frontend to communicate with the backend and deny all other communications.</li><li><strong>Traffic Control</strong>: Control how services communicate, not just who can communicate. This includes defining rules for retries, timeouts, and more.</li><li><strong>Secure by Default:</strong> With Linkerd’s Policy Engine, all communication is denied by default. This means you have to explicitly allow communication, ensuring that no unintended communication slips through.</li></ul><blockquote><strong>Fine-grained policy Limitation: </strong>Linkerd Policy has not yet support JWT or external policy engine like OPA or others, so we might not be able to apply custom authorization policy in between service to service call. But they are already added this in their roadmap, sooner or later we also can leverage their policy engine to apply authorization policy logic outside from business logic.</blockquote><h3>Service Pod Structure in Linkerd:</h3><p>In a Kubernetes cluster with Linkerd, each service pod is enhanced with additional components to leverage the features of the service mesh.</p><p>Each pod will have the main <strong>application container</strong>, a <strong>Linkerd proxy</strong>, and a <strong>Linkerd policy sidecar</strong>. Let’s break down the role of each of these components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*ZxbTg4X6ve40VDBE1Wfk_Q.png" /></figure><h4>1. Application Container:</h4><p>This is the primary container that runs our service’s code. It contains the business logic, handles requests, and performs the core functions of our service. In a Linkerd-enabled environment, this container doesn’t need to be aware of the service mesh. It simply processes requests and sends responses as it would in any other environment.</p><h4>2. Linkerd Proxy:</h4><p>The Linkerd proxy is automatically injected into each pod when it’s created. This proxy is responsible for intercepting all the network traffic entering and leaving the pod.</p><p>On namespace-level or pod level, we can control proxy injection by annotating with label linkerd.io/inject: enabled or linkerd.io/inject: disabled, we also can override the namespace-level setting by specifying level on pod.</p><h4>3. Linkerd Policy Sidecar:</h4><p>Linkerd policy sidecar is responsible for evaluating and enforcing policies related to traffic management and security. This would include determining which services can communicate with each other, under what conditions, and how traffic should be managed.</p><h3>How it works</h3><p>When a request is sent to a service, it first hits the Linkerd proxy. The proxy consults with the policy sidecar to determine how to handle the request, whether to route it, deny it, or modify it based on the defined policies. Once a decision is made, the proxy forwards the request to the application container. The application processes the request and sends the response, which again goes through the proxy before being sent back to the requester.</p><p>This trio of containers within a service pod application, Linkerd proxy, and Linkerd policy sidecar ensures that our services are not only performant but also secure and resilient. By offloading traffic management, security, and observability concerns to Linkerd, our application code remains clean, focused, and decoupled from the complex of the service mesh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hlBl_oMufpo_MCeuMySm8A.png" /></figure><h3>Observability with Linkerd:</h3><p>Linkerd proxy can play a vital role providing observability features, including monitoring and tracing, for the traffic that transits the service meshed pod. Here’s how the Linkerd proxy facilitates these capabilities:</p><h4><strong>Metrics Collection</strong>:</h4><p>As each in/out going request transits through the Linkerd proxy sidecar, proxy sidecar automatically can collects a wide range of metrics for each service, including request rates, success rates, and latencies. These metrics are crucial for understanding the health and performance of our services.</p><h4>Tracing log collection:</h4><p>The Linkerd proxy can automatically propagate context headers. This is essential for distributed tracing as it allows individual requests to be tracked as they travel multiple services.</p><p>Linkerd doesn’t natively collect trace data, it is designed to work with popular distributed tracing systems like Jaeger and Zipkin or any opentelemetry collector. By providing proper context propagation information and integrating with these systems, Linkerd can enables end-to-end tracing of requests across the meshed.</p><h3><strong>Conclusion</strong></h3><p>Our decision to adopt Linkerd as our Kubernetes service mesh aligns perfectly with our operational goals and architectural principles. By prioritizing simplicity, performance, resource efficiency, and security, Linkerd addresses our core requirements for managing communication between microservices effectively.</p><p>With Linkerd’s operational simplicity, we can maintain a lean team focused on business workloads rather than infrastructure management. Its lightweight nature ensures minimal overhead, both in terms of system resources and cost. Moreover, the ease of installation, configuration, and maintenance streamlines our deployment processes, allowing us to achieve faster deployment times and increased agility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d04c842c2200" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Becoming a Linux Foundation Certified Kubernetes Application Developer (CKAD): A Guide to…]]></title>
            <link>https://medium.com/@onixoni72/becoming-a-linux-foundation-certified-kubernetes-application-developer-ckad-a-guide-to-a77554652332?source=rss-967f50af18a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/a77554652332</guid>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[the-linux-foundation]]></category>
            <category><![CDATA[ckad-dumps]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ckad-exam]]></category>
            <dc:creator><![CDATA[Anik Barua]]></dc:creator>
            <pubDate>Fri, 02 Jun 2023 09:47:10 GMT</pubDate>
            <atom:updated>2023-06-02T09:47:10.409Z</atom:updated>
            <content:encoded><![CDATA[<h3>Becoming a Linux Foundation Certified Kubernetes Application Developer (CKAD): A Guide to Preparing for the Exam</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ON06Q6bxBL_tvcaqJxRI6A.png" /><figcaption>CKAD</figcaption></figure><p>Kubernetes is a rapidly growing platform that has become the de facto standard for automating the deployment, scaling, and management of containerized applications. With the increasing popularity of <a href="https://kubernetes.io/"><strong>Kubernetes</strong></a>, there’s a growing demand for certified professionals who can demonstrate their expertise with the platform. If you’re interested in becoming a certified Kubernetes application developer, the Linux Foundation’s <a href="https://www.cncf.io/certification/ckad/"><strong>CKAD</strong></a> certification is an excellent option.</p><p>In this article, I’ll try to provide a comprehensive guide to preparing for the CKAD exam and becoming a certified Kubernetes professional.</p><h4>Create your Foundations:</h4><ol><li><strong>Study the Kubernetes Official Documentation: </strong>The <a href="https://kubernetes.io/docs/concepts/"><strong>Kubernetes official documentation</strong></a> is an invaluable resource for anyone interested in learning about the platform. It covers everything from basic concepts to advanced topics, and it provides step-by-step tutorials and examples to help you get started. By studying the official documentation, you’ll build a solid foundation of knowledge that you can use to prepare for the CKAD exam.</li><li><strong>Take Online Courses: </strong>Online courses are a great way to supplement your study of the Kubernetes official documentation. There are many high-quality courses available that cover different aspects of Kubernetes, and they can help you build a deeper understanding of the platform. By taking online courses, you’ll be able to reinforce your knowledge and build your skills in a structured and focused way. I will highly recommend to take <a href="https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&amp;mid=39197&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fcertified-kubernetes-application-developer%2F"><strong>Kubernetes Certified Application Developer (CKAD) with Tests</strong></a><strong> </strong>online Udemy course. This is one of the best and most popular CKAD course at <a href="https://www.udemy.com/">Udemy</a>. It has well-organized with 13 sections &amp; 183 lectures. The instructor Mumshad Mannambeth explain each topic in great details. Just only watching and following his instructions will be far enough to get well prepared for the exam. For me most value of this course is to get free access to <a href="https://kodekloud.com/">KodeKloud</a>. KodeKloud is a virtual training environment that provides hands-on training in Kubernetes.</li><li><strong>Practice with Sample Exercise</strong>: <strong>Practice, Practice, Practice !!!</strong> Remember without enough hands on practice it will be very difficult to pass the exam for anyone even who has experiences on Kubernetes. It is one of the most challenging exams in recent times. The main reason is, unlike other MCQ ( Multiple Choice Questions ) exams, CKAD is a hands on exam where you need to demonstrate your K8s skills on one or more live environments. There are many practice exams available online that simulate the real exam and test your knowledge of Kubernetes. I have followed this below list and exercise minimum 3 times before taking actual exam.</li></ol><blockquote><a href="https://github.com/dgkanatsios/CKAD-exercises">https://github.com/dgkanatsios/CKAD-exercises</a><br><a href="https://github.com/bbachi/CKAD-Practice-Questions">https://github.com/bbachi/CKAD-Practice-Questions</a><br><a href="https://github.com/lucassha/CKAD-resources">https://github.com/lucassha/CKAD-resources</a><br><a href="https://github.com/bmuschko/ckad-prep">https://github.com/bmuschko/ckad-prep</a><br><a href="https://github.com/dguyhasnoname/CKAD-TheHardWay/tree/master/exercises">https://github.com/dguyhasnoname/CKAD-TheHardWay/tree/master/exercises</a><br><a href="https://github.com/bmuschko/ckad-crash-course">https://github.com/bmuschko/ckad-crash-course</a></blockquote><p><a href="https://killercoda.com/killer-shell-ckad"><strong>Killer Shell CKAD</strong></a><strong> scenarios</strong> provide a simulator which is very similar to the actual exam interface and it is also a must do.</p><p><a href="https://killercoda.com/killer-shell-ckad">Killer Shell CKAD | Killercoda</a></p><p>Another nice platform is <a href="https://killer.sh/"><strong>killer.sh</strong></a>. I took this exercise to do a mock exam. The difficulty level is approximately 2–4 times harder than the real exam so this will a provides adequate confidence if you manage to pass it on the first attempt. After purchasing the CKAD exam voucher you will get 2 simulator attempts on killer.sh for free.</p><p><a href="https://killer.sh/ckad">Killer Shell - Exam Simulators</a></p><p>Now Lets talk about <strong>The Exam,</strong></p><h4>Familiarize Yourself with the Exam Objectives:</h4><p>The first step in preparing for the CKAD exam is to familiarize yourself with the exam objectives. The exam objectives outline the specific knowledge areas that you’ll be tested on during the exam, and they’re available on the Linux Foundation’s website. By reviewing the exam objectives, you’ll have a clear understanding of what you need to know to pass the exam.</p><p><strong>Application Design and Build (20%)</strong></p><p><strong>Application Deployment (20%)</strong></p><p><strong>Application Observability and Maintenance (15%)</strong></p><p><strong>Application Environment, Configuration, and Security (25%)</strong></p><p><strong>Services and Networking (20%)</strong></p><p>For more details, see the <a href="https://github.com/cncf/curriculum/blob/master/CKAD_Curriculum_v1.26.pdf">CKAD Curriculum</a> site.</p><p>On the exam, questions will come from all the sections, But I would recommend you to concentrate on this topics especially.</p><blockquote><strong>Deployments, Service, Secrets, ConfigMaps, Security Contexts, Service accounts, Multi containers, PVC, CronJobs, Network Policies, Ingress, Docker, Helm</strong></blockquote><p><strong>Having solid understanding on </strong><a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/"><strong>Deployments</strong></a><strong> Scenario context will surely secure more then 40% marks of the EXAM.</strong></p><h4>Some Tips:</h4><p><strong>Imperative Commands: </strong>Almost 80% of the questions can be solved by the <a href="https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands">imperative commands</a>. Imperative commands are a big time saver. <strong>Never ever write complete yaml files manually</strong> as there are very time consuming. At the max, you can use the kubectl imperative command to partially generate the yaml file and only make necessary changes to that file.</p><pre>alias kg=&#39;kubectl get&#39;<br>alias kd=&#39;kubectl describe&#39;<br>alias kdr=&quot;kubectl --dry-run=client -oyaml&quot;<br><br>alias kn=&#39;kubectl config set-context --current --namespace &#39;<br><br>alias kcurl=&quot;k run kcurl --restart=Never --image=nginx --rm -it --command -- /bin/sh  -c &quot;<br>alias kwget=&quot;k run kwget --restart=Never --image=busybox --rm -it --command -- /bin/sh -c &quot;</pre><p>For example, to create a deployment, we can generate the deployment using the bellow imperative command and</p><pre>kdr create deployment myDeploy --image=nginx --replicas=3 &gt; deployment.yaml</pre><p>Now, we can edit the deployment.yaml file to add/edit/update the necessary place. In this way, we can save a lot of time with this partially generated yaml file.</p><p>Another example, to access a service from a pod, can be used bellow command</p><pre>kcurl &quot;curl -I demo.default.svc.cluster.local:8080&quot;</pre><p><strong>Experts with Vim/Nano Editor: </strong>The CKAD exam environment is typically accessed through a terminal or command-line interface. Knowing how to use Vim or Nano ensures that you can comfortably edit configuration files, YAML files, and other resources directly within the exam environment without relying on external tools or editors. While Vim and Nano may have a learning curve if you’re new to them, investing time in practicing and becoming proficient with these editors before the CKAD exam can significantly enhance your efficiency and productivity during the exam. Here is a one good article you can follow.</p><p><a href="https://medium.com/@pranay.shah/nano-text-editor-tricks-for-ckad-exam-3b07f80dfe77">“Nano” text editor tricks (for CKAD exam)</a></p><p><strong>Use Kubectl explain:</strong> If you don’t remember any syntax while writing YAML files use kubectl explain instead of documentation. It’s faster and has good documentation. I would recommend you practice it. For example, if you don’t remember livenessProbe options for the container, just type kubectl explain Pod.spec.containers.livenessProbe it will give you all the options with good documentation.</p><p><strong>Don’t stack on a single question: </strong>Time will be the most important factor in the EXAM. CKAD is all about speed and accuracy. You will get on average 5/6 mins per questions. So whenever you get stuck on a single question leave it with Flagging so that you can take it back after answering other questions.</p><p><strong>Know Exam Environment: </strong>You must know the Exam Environment before taking Exam, Many peoples fails just due to just don’t know how to the use Environment. Check bellow link to get familiarize before starting the exam.</p><p><a href="https://docs.linuxfoundation.org/tc-docs/certification/tips-cka-and-ckad">Important Instructions: CKA and CKAD | T&amp;C DOCS (Candidate Facing Resources)</a></p><p>Becoming a certified Kubernetes professional is an excellent way to demonstrate your expertise on this platform. By familiarizing yourself with the exam objectives, studying the Kubernetes official documentation, taking online courses, practicing using Kubernetes, and using practice exams and test-taking strategies, you’ll be well-prepared for the CKAD exam and on your way to becoming a certified Kubernetes application developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ByDpceDTuAIZwWSXgRTSRQ.png" /><figcaption>My CKAD Certificate</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a77554652332" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparison of AWS Based Event-Driven Architecture Vs Container-Based Architecture]]></title>
            <link>https://medium.com/@onixoni72/comparison-of-aws-based-event-driven-architecture-vs-container-based-architecture-c5dd5839bdd6?source=rss-967f50af18a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5dd5839bdd6</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[containerarchitecture]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[event-based-architecture]]></category>
            <dc:creator><![CDATA[Anik Barua]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 02:04:01 GMT</pubDate>
            <atom:updated>2023-03-30T02:04:01.508Z</atom:updated>
            <content:encoded><![CDATA[<p>When it comes to building modern, scalable, and resilient applications, two architectural approaches have gained popularity in recent years: event-driven architecture and container-based architecture. While both approaches can be used to build robust and reliable systems, they have different strengths and weaknesses. In this article, we will compare the AWS-based event-driven architecture and container-based architecture and explore the use cases where each approach is most suitable.</p><h3>Event-Driven Architecture</h3><p>Event-driven architecture is a way of developing IT systems that lets loosely coupled applications and Microservices produce and consume events. These applications and Microservices talk through events or event adapters. Events are routed among these applications in publish/subscribe manner according to subscriptions. AWS provides a set of services that can be used to build an event-driven architecture, such as Amazon Simple Notification Service (SNS), Amazon Simple Queue Service (SQS), and AWS Lambda.</p><p>With AWS-based event-driven architecture, we can create an event-driven system that can scale automatically and handle large volumes of data. AWS Lambda, for example, allows us to write functions that execute in response to an event. These functions can be written in various languages, including Node.js, Python, and Java. The event can be generated by any AWS service or third-party application, and the function can be triggered by events such as the creation of an S3 bucket or a new message in an SQS queue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*pnJ5cDGktBfKOkumxKsp6w.png" /><figcaption>Event-Driven Architecture Module</figcaption></figure><h3>Container-Based Architecture</h3><p>A containerized architecture makes it possible to package software and its dependencies in an isolated unit, called a container, which can run consistently in any environment. These containers can then be deployed on various platforms, including on-premise servers, cloud-based virtual machines, and Kubernetes clusters.</p><p>The main advantage of container-based architecture is that it provides a consistent runtime environment, which makes it easier to deploy and manage applications. Containers can be quickly deployed, and we can use container orchestration tools like Kubernetes to manage the scaling and availability of our applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*mTY4nsJpOhzKa1M8Y3GEVQ.jpeg" /><figcaption>Container-Based Solution</figcaption></figure><h3>Comparison of Event-Driven Architecture Vs Container-Based Architecture</h3><p>While both architectures have their advantages, the choice between them depends on the specific requirements of the application. If the application needs to respond to real-time events and scale automatically, an event-driven architecture may be the best choice. However, if the application needs a consistent runtime environment and requires more control over the underlying infrastructure, a container-based architecture may be more appropriate.</p><p>In terms of cost, an event-driven architecture may be more cost-effective, as we only pay for the resources we use when we use them. However, a container-based architecture may provide more control over the underlying infrastructure, which can be important in some applications.</p><p><strong>Here is a comparison chart for Event-Driven Architecture Vs Container-Based Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*Eo80MxsKcKG7Qjcn0gKAaw.png" /><figcaption>Comparison of Event-Driven Architecture Vs Container-Based Architecture</figcaption></figure><h4>Conclusion</h4><p>Event-driven architecture and container-based architecture are two popular approaches to building modern, scalable, and resilient applications. AWS provides a set of services that can be used to build an event-driven architecture, while containerization technology such as Docker can be used to build a container-based architecture. While both architectures have their advantages, the choice between them depends on the specific requirements of the application. By understanding the differences between these two architectures, we can choose the one that best fits our needs and build more robust and reliable systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5dd5839bdd6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing Kubernetes with Open Policy Agent (OPA)]]></title>
            <link>https://medium.com/@onixoni72/securing-kubernetes-with-open-policy-agent-opa-67167157d477?source=rss-967f50af18a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/67167157d477</guid>
            <category><![CDATA[open-policy-agent]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native-application]]></category>
            <category><![CDATA[cloud-native-security]]></category>
            <category><![CDATA[opa-gatekeeper]]></category>
            <dc:creator><![CDATA[Anik Barua]]></dc:creator>
            <pubDate>Tue, 28 Mar 2023 03:24:06 GMT</pubDate>
            <atom:updated>2023-03-28T03:24:06.986Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction:</h3><p>Kubernetes is a powerful tool that helps us manage and deploy our software in an efficient and reliable way. However, as our systems become more complex, it can be challenging to ensure that they are secure and compliant with rules and regulations. That’s where Open Policy Agent (<a href="https://www.openpolicyagent.org/docs/latest/">OPA</a>) comes in. In this article, we’ll explore how OPA can be used with Kubernetes to secure our systems and enforce policy.</p><h3>What is OPA?</h3><p>Before diving into OPA in Kubernetes, it’s worth reviewing what OPA is and how it works. OPA is a policy engine that works by evaluating policies at runtime. It provides a centralized way to manage policies that can be applied across multiple applications and environments. OPA uses a policy language called Rego, which lets developers write policies in a way that’s both human-readable and machine-executable. Once the policies are written, they’re stored in a central policy repository that can be accessed by the OPA engine. You can read fundamental Knowledge of OPA with a given example in the below link.</p><p><a href="https://medium.com/@onixoni72/open-policy-agent-a-powerful-policy-engine-for-cloud-native-environments-8b0a158185e5">Open Policy Agent: A Powerful Policy Engine for Cloud-Native Environments</a></p><h3>How OPA Works with Kubernetes:</h3><p>OPA has native integrations with Kubernetes, which makes it easy to deploy and use OPA in a Kubernetes environment. There are several ways that OPA can be integrated with Kubernetes:</p><h4>OPA with Gatekeeper</h4><p>One of the most popular ways is to use a tool called OPA <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/">Gatekeeper</a>. OPA <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/">Gatekeeper</a> is a Kubernetes validating admission controller that enforces policies on Kubernetes objects as they are created or modified. When a user or process attempts to create or modify a Kubernetes object. OPA Gatekeeper intercepts the request and checks it against the policies defined in OPA. If the request violates a policy, it is rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*llNVOUWr8umnTi1f9NuUJQ.png" /><figcaption>OPA gatekeeper and Kubernetes</figcaption></figure><h4>OPA with Service Mesh:</h4><p>Another way to use OPA with Kubernetes is by using a service mesh like Istio or Envoy. Service meshes help us manage the traffic between our different services, and we can use OPA to ensure that this traffic is secure and follows our policies. For example, we can use OPA to block traffic to a service that does not have the correct authorization or to encrypt traffic between services.</p><p><strong><em>In this article we will discuss and see how Gatekeeper can be installed and use step by step .</em></strong></p><h4>OPA Gatekeeper Overview</h4><p>As we mentioned earlier <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/">OPA Gatekeeper</a> is a <a href="https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/">validating admission controller</a> which will be called through Kubernetes webhook. Validating admission controllers are used to validate whether a Kubernetes resource is permitted with a set of rules or policies before it is created or updated in the actual system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*xZLtUkpyVybeM2ZlMiIH7g.png" /></figure><h4>Installation of OPA Gatekeeper</h4><p>Cluster Admin permission is required to install the OPA gatekeeper.So need to create role and role-binding to gave access OPA gatekeeper to all the resources in Kubernetes.</p><p>There are <a href="https://open-policy-agent.github.io/gatekeeper/website/docs/install">many ways</a> to install the OPA gatekeeper, we can use Helm command as follows. A basic Helm chart exists in <a href="https://github.com/open-policy-agent/gatekeeper/blob/master/charts/gatekeeper/README.md">charts/gatekeeper</a>. If you have Helm installed, you can deploy via the following instructions for Helm v3</p><pre>$ helm repo add gatekeeper https://open-policy-agent.github.io/gatekeeper/charts --force-update<br>&quot;gatekeeper&quot; has been added to your repositories</pre><blockquote>Those who don’t know what helm is, <a href="https://helm.sh/">Helm</a> is a package manager for Kubernetes. It helps you install, manage, and upgrade applications on a Kubernetes cluster. Think of it like a tool that helps you simplify the deployment and management of Kubernetes applications.</blockquote><p>After running above command you can see the deployment results like below.</p><pre>helm install gatekeeper/gatekeeper --name-template=gatekeeper --namespace gatekeeper-system --create-namespace<br>NAME: gatekeeper<br>LAST DEPLOYED: Wed Mar 22 09:21:54 2023<br>NAMESPACE: gatekeeper-system<br>STATUS: deployed<br>REVISION: 1<br>TEST SUITE: None</pre><p>Components of the OPA gatekeeper are installed in the gatekeeper-system namespace. By executing the following command, information such as installed services and pads can be viewed.</p><pre>$ kubectl -n gatekeeper-system get all                                                                       <br>NAME                                                 READY   STATUS    RESTARTS      AGE<br>pod/gatekeeper-audit-549bcc6775-z74gm                1/1     Running   1 (92s ago)   100s<br>pod/gatekeeper-controller-manager-7785cd6b4c-j64zv   1/1     Running   0             100s<br>pod/gatekeeper-controller-manager-7785cd6b4c-mcfv5   1/1     Running   0             100s<br>pod/gatekeeper-controller-manager-7785cd6b4c-xr9kt   1/1     Running   0             100s<br><br>NAME                                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE<br>service/gatekeeper-webhook-service   ClusterIP   10.96.120.252   &lt;none&gt;        443/TCP   100s<br><br>NAME                                            READY   UP-TO-DATE   AVAILABLE   AGE<br>deployment.apps/gatekeeper-audit                1/1     1            1           100s<br>deployment.apps/gatekeeper-controller-manager   3/3     3            3           100s<br><br>NAME                                                       DESIRED   CURRENT   READY   AGE<br>replicaset.apps/gatekeeper-audit-549bcc6775                1         1         1       100s<br>replicaset.apps/gatekeeper-controller-manager-7785cd6b4c   3         3         3       100s</pre><h4>OPA Gatekeeper Constraint Template</h4><p>A ConstraintTemplate resource is essentially a template for generating Constraint resources, which are the actual Kubernetes objects that enforce the policies defined in the ConstraintTemplate. The ConstraintTemplate resource defines the Rego code that will be used to evaluate Kubernetes objects against the set of policies defined in the ConstraintTemplate.</p><p>Let’s create a ConstraintTemplate that block all deployment requests that are missing our private registry private.example.com</p><pre>$ cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: templates.gatekeeper.sh/v1beta1<br>kind: ConstraintTemplate<br>metadata:<br>  name: k8sallowedrepos<br>spec:<br>  crd:<br>    spec:<br>      names:<br>        kind: K8sAllowedRepos<br>      validation:<br>        # Schema for the `parameters` field<br>        openAPIV3Schema:<br>          properties:<br>            repos:<br>              type: array<br>              items:<br>                type: string<br>  targets:<br>    - target: admission.k8s.gatekeeper.sh<br>      rego: |<br>        package k8sallowedrepos<br><br>        violation[{&quot;msg&quot;: msg}] {<br>          container := input.review.object.spec.containers[_]<br>          satisfied := [good | repo = input.parameters.repos[_] ; good = contains(container.image, repo)]<br>          not any(satisfied)<br>          msg := sprintf(&quot;container &lt;%v&gt; has an invalid image repo &lt;%v&gt;, allowed repos are %v&quot;, [container.name, container.image, input.parameters.repos])<br>        }<br><br>        violation[{&quot;msg&quot;: msg}] {<br>          container := input.review.object.spec.initContainers[_]<br>          satisfied := [good | repo = input.parameters.repos[_] ; good = contains(container.image, repo)]<br>          not any(satisfied)<br>          msg := sprintf(&quot;container &lt;%v&gt; has an invalid image repo &lt;%v&gt;, allowed repos are %v&quot;, [container.name, container.image, input.parameters.repos])<br>        }<br>EOF<br><br>$ constrainttemplate.templates.gatekeeper.sh/k8sallowedrepos created</pre><p>We used bellow rego code above to create, If you see closely we are checking valid image repo names of a regular &amp; initContainer containers in a k8s deployment request payload.</p><pre>package k8sallowedrepos<br><br>violation[{&quot;msg&quot;: msg}] {<br>  container := input.review.object.spec.containers[_]<br>  satisfied := [good | repo = input.parameters.repos[_] ; good = contains(container.image, repo)]<br>  not any(satisfied)<br>  msg := sprintf(&quot;container &lt;%v&gt; has an invalid image repo &lt;%v&gt;, allowed repos are %v&quot;, [container.name, container.image, input.parameters.repos])<br>}<br><br>violation[{&quot;msg&quot;: msg}] {<br>  container := input.review.object.spec.initContainers[_]<br>  satisfied := [good | repo = input.parameters.repos[_] ; good = contains(container.image, repo)]<br>  not any(satisfied)<br>  msg := sprintf(&quot;container &lt;%v&gt; has an invalid image repo &lt;%v&gt;, allowed repos are %v&quot;, [container.name, container.image, input.parameters.repos])<br>}</pre><h4>OPA Gatekeeper Constraint</h4><p>Constraints can be thought of as templates for Kubernetes objects that enforce a specific set of policies. Each constraint is composed of two main parts: the spec and the parameters. The spec defines the set of policies that you want to enforce on Kubernetes objects, while the parameters section allows you to pass in variables that can be used in the spec.</p><p>We will create bellow constraints (<strong>K8sAllowedRepos</strong>) to inform Gatekeeper that the admin wants above ConstraintTemplate to be enforced, and Gatekeeper will apply and make sure to only allow valid image repos to be deployed in Kubernetes system.</p><pre>$ cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: constraints.gatekeeper.sh/v1beta1<br>kind: K8sAllowedRepos<br>metadata:<br>  name: allow-only-private-registry<br>spec:<br>  match:<br>    kinds:<br>      - apiGroups: [&quot;&quot;]<br>        kinds: [&quot;Pod&quot;]<br>  parameters:<br>    repos:<br>      - &quot;private.example.com&quot;<br>EOF<br><br>$ K8sAllowedRepos.constraints.gatekeeper.sh/allow-only-private-registry created</pre><blockquote>NOTE: We’ll want to change private.example.com to match the name of our own Image registry host. Also, we can have more than one registry in the list.</blockquote><p>Now Let’s see if constraint works as expected. First, let’s deploy a pod that use private.example.com repository for image which satisfies the constraints.</p><pre>$ cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: allowed-image-pod<br>spec:<br>  containers:<br>    - name: allowed-image-pod<br>      image: private.example.com/sample-api:tagname<br>      resources:<br>        limits:<br>          cpu: &quot;100m&quot;<br>          memory: &quot;30Mi&quot;<br>EOF          <br><br>pod/allowed-image-pod created</pre><p>The pod is deployed so Gatekeeper didn’t denied our deployment,</p><p>Now let’s create another deployment which will not use our allowed image.</p><pre>$ cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: deny-image-pod<br>spec:<br>  containers:<br>    - name: deny-image-pod<br>      image: docker.io/library/nginx:latest<br>      resources:<br>        limits:<br>          cpu: &quot;100m&quot;<br>          memory: &quot;30Mi&quot;<br>EOF          <br><br>Error from server (Forbidden): error when creating &quot;STDIN&quot;: admission webhook &quot;validation.gatekeeper.sh&quot; denied the request: [allow-only-private-registry] container &lt;deny-image-pod&gt; has an invalid image repo &lt;docker.io/library/nginx:latest&gt;, allowed repos are [&quot;private.example.com&quot;]</pre><p>Cool 😎, So Gatekeeper denied our requests to deploy not allowed images.</p><p>This is how we can create many policies with the help of Gatekeeper to keep our Kubernetes system secured.</p><h4>OPA Gatekeeper Policy Library</h4><p>The <a href="https://github.com/open-policy-agent/gatekeeper-library">OPA Gatekeeper Policy Library</a> is a collection of pre-built policies that you can use with OPA Gatekeeper. The library includes policies for enforcing security best practices, compliance requirements, resource quotas, and more. You can use these policies as-is or customize them to fit your specific needs.</p><p>The library includes a set of directories, each containing a set of policies focused on a particular area such as security or compliance. Each policy is defined as a Rego file, and the directory also includes a README file with more information about the policies.</p><h3>Conclusion:</h3><p>Kubernetes is a powerful tool that helps us manage and deploy our software, but it can be challenging to ensure that our systems are secure and compliant. Open Policy Agent (OPA) provides a powerful solution for enforcing policies and securing our systems. By using OPA with Kubernetes, we can simplify policy enforcement, increase security, and ensure compliance with regulations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67167157d477" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open Policy Agent: A Powerful Policy Engine for Cloud-Native Environments]]></title>
            <link>https://medium.com/@onixoni72/open-policy-agent-a-powerful-policy-engine-for-cloud-native-environments-8b0a158185e5?source=rss-967f50af18a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b0a158185e5</guid>
            <category><![CDATA[policy-engine]]></category>
            <category><![CDATA[open-policy-agent]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native-application]]></category>
            <dc:creator><![CDATA[Anik Barua]]></dc:creator>
            <pubDate>Tue, 21 Mar 2023 15:07:59 GMT</pubDate>
            <atom:updated>2023-03-29T09:27:34.927Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-paced digital world, organizations need to enforce policies that ensure the security, reliability, and compliance of their applications and infrastructure. However, with the rise of cloud-native technologies, enforcing policies has become more challenging, as applications and infrastructure are more distributed and dynamic than ever before.</p><p><strong>Open Policy Agent (</strong><a href="https://www.openpolicyagent.org/"><strong>OPA</strong></a><strong>) is a tool that helps organizations enforce policies across their software systems. </strong>The project was created by <a href="https://www.styra.com/">Styra</a> and it is currently maintaining by <a href="https://landscape.cncf.io/selected=open-policy-agent-opa">Cloud Native Computing Foundation</a>.</p><p>Policies are rules that govern how a system should behave, and can include things like security policies (who can access what resources), compliance policies (making sure the system meets certain standards), and many others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_o7QrrlOzcTra6RaT6q20w.png" /><figcaption>OPA Architecture</figcaption></figure><p>OPA works by providing a way for developers to write these policies in a language called <a href="https://sangkeon.github.io/opaguide/chap3/rego.html">Rego</a>. Rego is a simple and easy-to-understand language that lets developers express policies in a way that’s both human-readable and machine-executable. Once the policies are written, OPA evaluates them at runtime to make sure they’re being followed correctly.</p><p>We might be thinking what’s New here, Just an extra layer behind HTTP Service layer which validated the HTTP request context.</p><p><strong>No</strong>, <strong>One of the great things about OPA is that it’s designed to work with a wide range of software systems, including cloud-native platforms, containers, and Microservices. This means that it can help enforce unified policies across many different parts of an organization’s technology stack.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V66tBsPElE9PmRoZDUC99A.png" /><figcaption>OPA Integrated with Many Services</figcaption></figure><p><strong>It can be integrated with APIs, GraphQl, Service Mesh like Istio, the Linux SSH daemon, an object store like CEPH, Event streaming platform like Kafka, Infrastructure Provisional tool like Terraform and so on. </strong>OPA designers purposefully avoided basing it on any other project. Accordingly, the policy query and decision do not follow a specific format. That is, you can use <em>any</em> valid JSON data as request attributes as long as it provides the required data. Similarly, the policy decision coming from OPA can also be any valid JSON data. You choose what gets input and what gets output. For example, you can opt to have OPA return a True or False JSON object, a number, a string, or even a complex data object.</p><p>Another advantage of OPA is that it provides a centralized way to manage policies across multiple applications and environments. This makes it easier to ensure that policies are being followed consistently, no matter where they’re being applied. Isn’t is super cool 😎 ?? Different Teams just need to fucus on their services related Implementation. After service deployment organizations standard policy will be applied to all the Services layer so that all service will be secured in same manner.</p><h3>How to install</h3><p>Download the binary with the following curl command and save it under the name opa.</p><p><strong>Linux (64-bit):</strong></p><pre>$ curl -L -o opa https://openpolicyagent.org/downloads/latest/opa_linux_amd64</pre><p><strong>macOS (64-bit):</strong></p><pre>curl -L -o opa https://openpolicyagent.org/downloads/v0.50.1/opa_darwin_amd64</pre><p>After downloading the file, execute the chmod command to grant permission.</p><pre>$ chmod 755 opa</pre><h4>Test Installation</h4><p>Let’s run the OPA installation to see if it works properly. Move to the directory where opa is installed. Run ./opa in Linux and Mac OS. If you have registered PATH environment variables, you can run them directly with opa. If installed normally, the following results can be seen.</p><pre>$ ./opa<br>An open source project to policy-enable your service.<br><br>Usage:<br>opa [command]<br><br>Available Commands:<br>bench Benchmark a Rego query<br>build Build an OPA bundle<br>check Check Rego source files<br>deps Analyze Rego query dependencies<br>eval Evaluate a Rego query<br>fmt Format Rego source files<br>help Help about any command<br>parse Parse Rego source file<br>run Start OPA in interactive or server mode<br>sign Generate an OPA bundle signature<br>test Execute Rego test cases<br>version Print the version of OPA<br><br>Flags:<br>-h, --help help for opa<br><br>Use &quot;opa [command] --help&quot; for more information about a command.</pre><h3>Run OPA</h3><p>Let’s create a simple policy and evaluate.We will going to check if input text is match with “hello_world”.</p><pre>// hello.rego<br>package hello<br><br>default allow_ok = false<br>default allow_ng = false<br><br>allow_ok {<br>    &quot;hello_world&quot; == input.text<br>}<br><br>allow_ng {<br>    &quot;hello_world&quot; != input.text<br>}</pre><pre>// input.json<br>{<br>    &quot;text&quot;: &quot;hello_world&quot;<br>}</pre><pre>$ opa eval --data hello.rego --input input.json &quot;data.hello.allow_ok&quot;<br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: true,<br>          &quot;text&quot;: &quot;data.hello.allow_ok&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><pre>$ opa eval --data hello.rego --input input.json &quot;data.hello.allow_ng&quot;<br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: false,<br>          &quot;text&quot;: &quot;data.hello.allow_ng&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>This is how we simply can write a policy for checking input message and evaluate the request through policy.</p><p>A Rego Playground provides a great editor to get started with OPA and share policies. Try it out at <a href="https://play.openpolicyagent.org/">https://<strong>play</strong>.<strong>openpolicyagent</strong>.org/</a></p><h3>Deployment</h3><p>There are multiple deployment options available for OPA depending on the specific scenario at hand, such as:</p><ul><li>You can deploy OPA as a standalone binary on your machine or in a containerized environment using Docker.</li><li>OPA can also be integrated with popular container orchestration platforms like Kubernetes as a sidecar proxy or a dedicated server.</li><li>Another option is to deploy OPA as a library within your application code, allowing for more fine-grained control over policy enforcement.</li><li>Additionally, OPA can be deployed as a service, providing a centralized policy engine for multiple applications and services to use.</li></ul><p>Overall, the choice of deployment option for OPA should be based on factors such as your infrastructure environment, scalability requirements, and the level of policy control needed for your applications.</p><blockquote>To know more about deployment follow bellow link <a href="https://www.openpolicyagent.org/docs/latest/deployments/">https://www.openpolicyagent.org/docs/latest/deployments/</a></blockquote><h3>Example Use Case of OPA</h3><p>Let’s say that we are implementing the Salary Service of our example application. This service is responsible for handling Employee’s salary. It exposes an API where it accepts adjustment(Create/Read/Update/Delete) of salary information for an Employee and this privilege will only given to HR Department. It also allows the Employee to query about his current salary information and also gave access to Manager to view all his downline salary information.</p><p>So, to obtain an object containing the salary information service team decided to expose an API with the path /salary/{employee}. Employee can provide their credential information in the Authorization header and send the request. The response would be a JSON data. However, since as a system we don’t want just anyone with network access to have access to the salary API to see others sensitive data, we need to enforce an authorization policy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EU66ISv7fncL17PFwEEdaA.png" /><figcaption>Use case of OPA</figcaption></figure><p>In above scenario, Rob can view his salary but he cant see Bob’s salary, Rob’s manager can view his salary and also Bob salary too. HR can view and also update both Bob’s and Rob’s salary.</p><p>Now, let’s create our policy for above scenario.</p><pre>// salary_policy.rego<br>package play<br>import future.keywords.if<br>import future.keywords.in<br><br>default allow = false<br><br>read_only_all := {<br> &quot;manager&quot;,<br> &quot;hr&quot;,<br>}<br><br>crud_method := {<br> &quot;GET&quot;,<br> &quot;UPDATE&quot;,<br> &quot;CREATE&quot;,<br> &quot;DELETE&quot;<br>}<br><br>crud_user := {<br> &quot;hr&quot;<br>}<br><br>allow if {<br> input.method == &quot;GET&quot;<br> input.path = [&quot;payments&quot;, customer_id]<br> input.user == customer_id<br>}<br><br>allow if {<br> input.method == &quot;GET&quot;<br>    input.user in read_only_all<br>}<br><br>allow if {<br>    input.method in crud_method<br>    input.user in crud_user<br>}</pre><p>Now, create request payload and see what returns by our policy.</p><pre>// rob is requesting his own salary <br>{<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;bob&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: true,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>Bob can see his own salary which is as expected.</p><pre>// rob is requesting for creating his own salary <br>{<br>    &quot;method&quot;: &quot;CREATE&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;bob&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: false,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>Bob cant create his salary as because HR only has rights to create his salary not by himself.</p><p>Now lets if Rob can access Bob’s salary.</p><pre>// rob is requesting Bob&#39;s salary <br>{<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;rob&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: false,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>So Rob cant see Bob’s salary which is also as correct.So far our policy is working as expected.</p><p>Now, let’s see if Manager can see his downline Rob’s &amp; Bob’s salary. Manager can only view but can’t update anyone’s salary.</p><pre>// Manager is requesting Bob&#39;s salary<br>{<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;manager&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: true,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><pre>// Manager is requesting Bob&#39;s salary<br>{<br>    &quot;method&quot;: &quot;CREATE&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;manager&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: false,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>Great, So Manager can access his downline’s salary but he cant update his downline’s salary.</p><p>Finally let’s check if HR has all access to salary system. HR should have privilege to read, create, update, delete of anyone’s Salary.</p><pre>// HR is requesting Bob&#39;s salary<br>{<br>    &quot;method&quot;: &quot;GET&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;hr&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: true,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><pre>// HR is Creating Bob&#39;s salary<br>{<br>    &quot;method&quot;: &quot;CREATE&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;hr&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: true,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><pre>// HR is Deleting Bob&#39;s salary<br>{<br>    &quot;method&quot;: &quot;DELETE&quot;,<br>    &quot;path&quot;: [&quot;payments&quot;,&quot;bob&quot;],<br>    &quot;user&quot;: &quot;hr&quot;<br>}</pre><pre>$ opa eval --data example.rego --input input.json &quot;data.play.allow&quot; <br>{<br>  &quot;result&quot;: [<br>    {<br>      &quot;expressions&quot;: [<br>        {<br>          &quot;value&quot;: true,<br>          &quot;text&quot;: &quot;data.play.allow&quot;,<br>          &quot;location&quot;: {<br>            &quot;row&quot;: 1,<br>            &quot;col&quot;: 1<br>          }<br>        }<br>      ]<br>    }<br>  ]<br>}</pre><p>Awesome 👏 , Our Policy is working exactly what we have decided. So now Salary Service Team doesn’t need to handle this Business Policy as this will handle before Application Layer, Service Team can develop their own logic in their Application Layer.</p><p>Now, If organization decides to create another service called Attendance Service in-that case also we can simply apply similar policy without writing this logic in Application Layer.</p><p>This is how organization can enforce policies to ensure the same security throughout their all applications and infrastructure with the help of <strong>Open Policy Agent</strong>.</p><blockquote>If you want to know how OPA can be used to secure your Kubernetes Cluster, please have a look my bellow article.</blockquote><p><a href="https://medium.com/@onixoni72/securing-kubernetes-with-open-policy-agent-opa-67167157d477">Securing Kubernetes with Open Policy Agent (OPA)</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b0a158185e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>