<?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 Ohad Senior on Medium]]></title>
        <description><![CDATA[Stories by Ohad Senior on Medium]]></description>
        <link>https://medium.com/@ohadse?source=rss-9eacae91bb7b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lbnw6TOPMdZmwrWux89rJA.png</url>
            <title>Stories by Ohad Senior on Medium</title>
            <link>https://medium.com/@ohadse?source=rss-9eacae91bb7b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 21:20:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ohadse/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[GitOps: quick Intro & key players]]></title>
            <link>https://medium.com/cloudzone/gitops-quick-intro-key-players-d488212742f9?source=rss-9eacae91bb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d488212742f9</guid>
            <dc:creator><![CDATA[Ohad Senior]]></dc:creator>
            <pubDate>Thu, 18 Nov 2021 09:15:50 GMT</pubDate>
            <atom:updated>2021-11-18T09:15:50.467Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*TAE-oQmPtP84pVomsH7OHw.jpeg" /></figure><p>In recent years, a major development on the operations and infrastructure side of software has been GitOps. Git is a very powerful tool for code collaboration and version control. GitOps makes use of Git as a source of truth for your entire setup, including infrastructure and operations. Infrastructure maintainers can then maintain your infrastructure as code in Git using declarative code.</p><p>GitOps is considered to be bound to Kubernetes, but don’t think you can only use this with Kubernetes — you can use GitOps with any part of your infrastructure.</p><h3>What Exactly Happens in GitOps and the Reconciler Pattern?</h3><p>After maintainers define their infrastructure as declarative code in Git, a process runs to detect any changes made in the Git repository, which would mean there are changes in Git that are not present in your infrastructure; those changes will then be applied.</p><p>GitOps works per the reconciler pattern, which is one such process to detect and apply changes. Kubernetes itself works as a reconciler, and all Kubernetes objects are declarative using YAML. If there is a change in Kubernetes objects, you can just apply the YAML and Kubernetes itself will detect the change and then apply it.</p><h3>How Can You Implement CI/CD with GitOps?</h3><p>There are different steps in any application deployment pipeline, which include building images, code checks, pushing images, and deploying — all of which are parts of any CI/CD pipeline.</p><h3>CI/CD Review</h3><p>Before delving into how to implement GitOps with your pipeline, let’s cover the basic steps of CI/CD:</p><p><strong>Store your code:</strong> This is fairly easy. You can use any of the Git services, e.g., GitHub or GitLab, or you can host your own GitgitLab.</p><p><strong>Create a deployable artifact:</strong> This can be a bit tricky, as there may be different kinds of artifacts generated, e.g., JAR, binary, TAR, a Debian package, or a Docker image. You can use any of the executors for these steps, like Jenkins.</p><p><strong>Deliver and store that artifact:</strong> After building the artifacts or images, you can push them to artifact storage like Artifactory. From there, the artifacts can be served when the deployment is triggered.</p><p><strong>Run tests: </strong>Basic Sanity entails unit testing, code checking, and limiting or integration testing, which can be done at different stages. You should run unit tests while someone commits the code; but you can run integration tests in a different environment, so you can do this after building the artifacts. Code checking and linting should also be done after code commits.</p><p><strong>Deploy your application:</strong> Finally, you can deploy the workload on your cluster, which can be a cluster of VMs, Kubernetes, Mesos Marathon, or any similar tool. You put load balancers in front of these clusters to serve the traffic, and this is how a basic CI/CD pipeline is implemented.</p><h3>GitOps and CI/CD</h3><p>Now, let’s take a look at how CI/CD can be driven with GitOps. You can define the state of your infrastructure in Git, e.g., how many machines you have and which services you’re using, like Kubernetes. You can then use Terraform to spawn the cluster defined in Git using declarative syntax. Any change in code will result in infrastructure synchronization because your infrastructure is driven by Gitops using Terraform.</p><p>Next, whenever you make any code changes, a build is created and along with it, a few YAML (deployment and service YAML) to deploy it. These manifests will be the service definition for Kubernetes. Once the image is pushed and the manifests are generated, they can be applied to Kubernetes, and Kubernetes will then sync the service to the latest version.</p><p>You can automate the steps of detecting changes in Git and taking action on these changes by using Git Pipeline, including GitHub Actions and GitLab Ci/CD Pipelines. Once a Git change is detected, a webhook can be called, which will trigger Jenkins to build the image, push it to your artifact storage, generate manifests, and apply them to Kubernetes. Plus, you can automate all of these steps with some basic scripts.</p><p>This is how a GitOps model can be applied to your application as well as the infrastructure running your application.</p><h3>GitOps vs. Traditional Deployment</h3><p>The main difference between the traditional and GitOps models is that Git is used as a source of truth. In the traditional model, you write scripts to do your jobs, while in GitOps, you try to write things in a more declarative way — you define the state of your system, and GitOps tries to sync to that state. Terraform, Kubernetes, Chef, etc. are based on this model.</p><p>GitOps also makes it easy to recover your entire infrastructure with some basic changes in case of a disaster.</p><p>Implementing traditional models can also be more complex, as you have to use multiple tools. While in GitOps, delivery time is decreased because you don’t have to go to a separate place to deploy. Just commit the code, and deployment will start.</p><p>GitOps improves system security as well because there is an approval flow for all merge requests. This enables you to record and easily audit all security rules and increases the stability of the system since there are fewer ad hoc changes. And any changes that do happen have to be approved by the maintainers of the project before merging to the master.</p><p>GitOps lets you standardize a set of rules that must be followed to make any changes in production. This is still a dream for many organizations to implement, as a standard procedure means fewer chances of issues occurring in production.</p><h3>Pros of GitOps</h3><ul><li>Faster delivery of changes</li><li>Source of truth maintained, can be used to spawn up the same state</li><li>Hybrid model of deployment, as it can be plugged into different clouds and in-house servers</li><li>A well-defined track of all changes in Git</li><li>Ops cost savings; developers can now handle the deployment of their services instead of relying on DevOps</li><li>Stronger security, an audit of all changes, and approval of all merge request</li><li>Standardized procedure, very useful for disaster recovery scenarios</li></ul><h3>Cons of GitOps</h3><ul><li>You have to be able to understand the tools needed to implement the GitOps model.</li><li>There can be a lot of repositories that you have to design and maintain.</li><li>You will have to maintain RBAC at the Git level; you cannot give access to repositories to everyone.</li><li>You must take care of Secrets Management separately.</li></ul><h3>Implementing GitOps in Kubernetes: Argo CD vs. Flux CD</h3><p>There are multiple tools available to facilitate deployments in Kubernetes. Spinnaker, being the oldest, has a lot of features, while Argo CD and Flux CD are comparatively new and focus on the GitOps model. We’ll be comparing the Argo and Flux solutions here, as these two are the leaders when it comes to GitOps models and ease of use. Spinnaker, on the other hand, is very bulky and needs a full-fledged team to operate.</p><h3>Argo CD</h3><p><a href="https://argo-cd.readthedocs.io/en/stable/">Argo CD</a> serves as a Kubernetes tool for continuous delivery and works on the GitOps model, as well as on multiple repositories. It has a GUI from where you can control the deployment and supports multi-tenancy with concepts called projects. Argo can also support and control multiple Kubernetes clusters.</p><h4>Pros</h4><ul><li>Supports multiple Kubernetes clusters and repositories</li><li>Supports multi-tenancy</li><li>Performs garbage collection, i.e., deletes resources on Kubernetes no longer being used</li><li>Handles resource drifting, can detect drift and sync it</li><li>Features separate CI and UI, making it easier to use and manage</li></ul><h4>Cons</h4><ul><li>Alerts and notifications are not built into Argo CD, so it relies on other tools like Prometheus, Grafana, and Alert Manager.</li><li>There are more components to manage separately.</li></ul><h3>Flux CD</h3><p><a href="https://fluxcd.io/">Flux CD</a> was built with GitOps as the main motivation. A continuous delivery solution for Kubernetes, Flux was created by Weaveworks; later, it was open-sourced and became a part of CNCF.</p><h4>Pros</h4><ul><li>Supports multiple clusters and repositories</li><li>Supports multi-tenancy</li><li>Features native support to send alerts and notifications</li><li>Can detect and fix any drifts in resources</li><li>Can delete unused objects from Kubernetes</li></ul><h4>Cons</h4><ul><li>There is no official UI, although there is an experimental UI in progress.</li><li>You can only deploy Flux1 using Helm charts; there is no operator to run it. Flux2, however, does come with an operator to manage this.</li><li>There are no SSO integrations.</li></ul><h3>Which One Should You Choose?</h3><p>Both Argo CD and Flux CD are easy to install and use. A better UI on the former, along with access control and event-based actions, make it a great choice. But you have to understand that with more features comes more complexity. You have to run a lot of components of Argo CD to achieve event-based actions, access control, etc. Argo also uses plugins to enable extra features like notifications, events, and workflows, which means more complexity to manage as well.</p><p>Flux CD gives you a very easy and simple way to implement GitOps. Less complex than Argo CD, Flux uses Kubernetes for its RBAC implementation. However, you may end up running multiple operators to have access to different components like ConfigMaps, deployments, etc. Flux also doesn’t have a GUI but does offer native support for alerts and notifications.</p><p>Both products have great communities, although Argo CD has a bit of an edge here. Both are also part of the CNCF community, but here, Flux seems to have the edge, as <a href="https://www.weave.works/blog/cncf-user-community-recommend-flux-and-helm">CNCF recommends adopting Flux</a> for GitOps. Still, Argo CD is very powerful and has a few features that are not present in Flux.</p><p>If your teams are more into UI, Argo CD is a great choice due to its RBAC and GUI. If not, Flux CD is also a great choice. At the end of the day, the product you pick should depend on your organization and what process you implement for deployment.</p><h3>Conclusion</h3><p>GitOps can save you a lot of time with the help of faster delivery, reliability, and disaster recovery. It can also help you keep your environment more secure by not letting anything pass unnoticed and creating a proper workflow for developers to follow.</p><p>When used with Kubernetes, GitOps is very powerful and saves a lot of time in manual deployments. So it is highly recommended that you use GitOps with Kubernetes. You can work with either of the tools discussed above. Both Argo CD and Flux CD are great for GitOps. In the end, maybe try both of them before making a decision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d488212742f9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudzone/gitops-quick-intro-key-players-d488212742f9">GitOps: quick Intro &amp; key players</a> was originally published in <a href="https://medium.com/cloudzone">CloudZone</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K8s Service Mesh: Linkerd or Istio]]></title>
            <link>https://medium.com/cloudzone/k8s-service-mesh-linkerd-or-istio-4bb650d51bc6?source=rss-9eacae91bb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bb650d51bc6</guid>
            <dc:creator><![CDATA[Ohad Senior]]></dc:creator>
            <pubDate>Sun, 03 Oct 2021 05:38:21 GMT</pubDate>
            <atom:updated>2021-10-03T05:38:21.610Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKXIJZZ7PSzIO3cM2_x4eg.png" /></figure><p>In the Kubernetes networking space, a very important development in recent years has been the service mesh. Even though service meshes have been around for a long time now, there is a lot of hype surrounding them in the world of Kubernetes. Many service mesh tools have even specifically been introduced for Kubernetes, two major ones being Linkerd and Istio.</p><p>In this post, we’ll look into these tools and compare them based on different criteria. But before that, let’s take a moment to explain just what a service mesh does.</p><h3>What Is a Service Mesh?</h3><p>A service mesh is a layer in your infrastructure that can take care of routing, rate limiting, observability, mTLS, and other capabilities. Using a service mesh, information regarding all other services is present on all nodes, enabling faster and more secure communication between two or more services.</p><p>There is a small misconception that service meshes are somehow bound to Kubernetes and came about solely due to it, but this is not the case. Service meshes as a concept have been around for some time now (<a href="https://thenewstack.io/history-service-mesh/">early 2010s</a>), and Lyft began developing <a href="https://thenewstack.io/building-lyfts-new-application-service-mesh-envoy/">Envoy as a service mesh</a> back in 2017.</p><p>A service mesh has two primary components: the control plane and the data plane.</p><p>Users interact with the control plane to configure the service mesh; the control plane then configures the data plane, which is generally a proxy to routing, rate limiting, mTLS, and other functionalities. Actual data flows through the data plane or the proxy.</p><p>All the requests going out of an application or coming in are actually routed to a proxy sidecar, and the various capabilities — like rate limiting, mTLS, etc. — are applied by the proxy. After that, traffic is forwarded either inside the pod or to the requested service.</p><h3>What Are Your Options?</h3><p>When we talk about a service mesh in the context of Kubernetes, there are two major choices: Istio and Linkerd.</p><h3>Linkerd</h3><p>Originally, <a href="https://buoyant.io/">Buoyant</a> built Linkerd for native machines using Scala and made it open-source. It joined CNCF in 2017 as <a href="https://www.cncf.io/blog/2017/01/23/linkerd-project-joins-cloud-native-computing-foundation/">an incubating project</a> in the service mesh category. Buoyant later modified Linkerd using Golang and Rust, with Kubernetes still the target; this resulted in Linkerd2. Linkerd has gained a lot of popularity as a minimalist, ultra-light, security-first service mesh for Kubernetes.</p><h3>Istio</h3><p>In contrast to Linkerd, Istio tries to solve a large number of problems related to a service mesh and is thus very complex. It comes with some extra built-in features you may not require, but it can be great if you want all of these.</p><p>In the beginning, Istio followed a microservices-based architecture for its control plane. But later, they decided to merge these microservices into monoliths, as things were becoming very complex. You can read about what Istio said about <a href="https://istio.io/latest/blog/2020/istiod/">simplifying its control plane here</a>.</p><h3>Feature Comparison</h3><p>When it comes to a service mesh, there are a lot of different possible features and components to consider. Below, we’ll discuss what Linkerd and Istio have to offer and how they compare.</p><h3>Proxy</h3><p>Linkerd uses a <a href="https://github.com/linkerd/linkerd2-proxy">linkerd2-proxy</a>, a lightweight proxy built-in Rust that is very fast and for this purpose only.</p><p>Istio uses <a href="https://github.com/envoyproxy/envoy">Envoy</a>, an open-source project from Lyft, as its proxy. Envoy is complex and heavy compared to Linkerd’s proxy, as it was built to be a general-purpose proxy to solve a diverse range of issues like load balancing, header rewrite, rate limiting, reverse proxy, etc.</p><p>Istio can also perform circuit breaking, a mechanism to handle failure by short-circuiting your calls to a different path. For example, you can send an already-decided status code to let the calling service know about it or fall back to another location, such as a cache for the information, and serve that data to deal with the faulty APIs. Once a recurring failure is detected, it prevents the application from calling the faulty service and handles it with different logic.</p><h3>System Complexity</h3><p>Istio is a lot more complex than Linkerd due to the fact that it tries to solve far more problems than Linkerd. Linkerd, on the other hand, has a very targeted set of problems it solves, making it less complex. This doesn’t mean Linkerd is not powerful, but simply that it has well-defined boundaries and implementation.</p><p>Istio tends to be a generalized solution for your service mesh, and it’s a fact that the more generalized you try to build a solution, to potentially handle any issue that arises, the more underlying complexity there will be.</p><p>When it comes to configuration, Linkerd is easy to install, with all the configurations a part of annotations in Kubernetes manifests. Istio, on the other hand, has a huge learning curve and takes time to understand and configure.</p><h3>Ingress</h3><p>An ingress handles how you can accept incoming traffic inside your Kubernetes clusters. Istio uses Envoy as an ingress, while you may need to deploy third-party controllers like Nginx in Linkerd to enable a few capabilities like rewriting the incoming header. In short, Istio has better support for its ingress, but it takes a lot of configuration.</p><p>Since Linkerd can be integrated with Nginx, there are capabilities you can enable at the Nginx ingress layer, like rewrite rules, etc.</p><h3>Egress</h3><p>Egress lets you control traffic going out of the cluster. Istio provides a way to control outgoing traffic with the help of virtual service objects and gateways. Egress implementation in Linkerd, however, is not straightforward and can only be implemented using DNS and DTAB.</p><h3>Handling Traffic</h3><p>Both proxies support timeouts, retries, rate limiting, mTLS, GRPC, and HTTP2. Timeouts let you configure when to time-out your request with the help of a proxy. Similarly, retries and rate-limiting are also configured at the proxy level, and the application is thus unaware of these when using a service mesh. mTLS makes sure all the communication between services is encrypted.</p><h3>Distributed Tracing</h3><p>Tracing a request end to end, meaning how it passes through each upstream microservice, is a great capability needed in today’s microservices-based architectures. Both Linkerd and Istio provide this with the help of Jaeger.</p><h3>Monitoring</h3><p>Both with Istio and Linkerd we can use Prometheus and Grafana to get the observability that we need.</p><p>with Linkerd, we will need to deploy <a href="https://github.com/linkerd/linkerd-viz">viz</a> — linkerd-viz is a monitoring application based on <a href="https://prometheus.io/">Prometheus</a> and <a href="http://grafana.org/">Grafana</a>, autoconfigured to collect metrics from <a href="https://linkerd.io/">linkerd</a>.</p><p>with Istio (<a href="https://istio.io/latest/blog/2020/addon-rework/">since 1.8 </a>) we will have to deploy the Prometheus and Grafana separately, and configure Prometheus to scrape Istio components — <a href="https://istio.io/latest/docs/ops/integrations/prometheus/">https://istio.io/latest/docs/ops/integrations/prometheus/</a></p><h3>Multi-Cluster Support</h3><p>Multi-cluster support means a single service mesh can span across multiple Kubernetes clusters. This enables different applications running in different clusters to be able to talk to each other like they are part of a single service mesh. Both Linkerd and Istio support multi-cluster service mesh deployments.</p><h3>Fault Injection and Traffic Splitting</h3><p>Fault injection is used to create chaos in a system to see how it reacts. It lets you artificially increase the error rates in your system to see how it copes with said errors.</p><p>Traffic splitting maps canary and blue-green deployments, where you can divert a certain percentage of traffic to newer deployments and the remainder to older deployments.</p><p>Both of these features can be configured very easily in Linkerd and Istio; they give you better control over your deployments and make your system more reliable.</p><p>Aside from the above features, there are a couple of other factors to consider when choosing a service mesh for Kubernetes.</p><h3>Performance and Resource Consumption</h3><p>Linkerd runs a very lightweight proxy built in Rust. The Linkerd2-proxy only works with Linkerd but is known for running its set tasks very efficiently.</p><p>Istio runs Envoy, a multipurpose proxy written in C++ and used by a lot of different software as a data plane. Istio relies on Envoy because it is very feature-rich, but this is also why Istio can be so complex.</p><p>The choice of Rust for Linkerd’s proxy gives it a good advantage over others, as Rust has a very light memory footprint compared to Java. It is faster and safer for tail latencies since it is not a garbage-collected language like Golang (When garbage collection gets triggered in serving requests, it can induce tail latencies). Rust is also a memory-safe language compared to C or C++, making it less vulnerable to security threats due to memory-related buffer overflows, use-after-free, etc.</p><p>For these reasons, choosing Rust over other languages has proven beneficial, and you can see the performance differences in Linked versus Istio.</p><p>Linkerd is primarily more performant than Istio due to its targeted approach and lightweight proxy. Its data plane is 2–5 times faster, depending on the scenario.</p><p>As to resource consumption, Istio consumes around 2–3 times the memory and 8 times the CPU of Linkerd. You can read more about these benchmarking results <a href="https://linkerd.io/2021/05/27/linkerd-vs-istio-benchmarks/">here</a>.</p><h3>Community</h3><p>When we talk about open-source projects, it is very important to know about the community that can back you up. Istio has a great community, and big companies like Google are very much involved in this project. But the fact that Istio is not part of the CNCF landscape — although Envoy is — raises some concerns.</p><p>Linkerd is a CNCF project that has a great community and has also gained a lot more traction recently compared to Istio.</p><p>Both communities are great, but being a member of CNCF gives Linkerd a bit of an advantage.</p><h3>Conclusion</h3><p>Linkerd and Istio are both very powerful service meshes, and it really depends on your requirements as to which one you should use. If you want something to solve your service mesh problems and want your data plane to be very fast, less resource-intensive, and less complex to manage, Linkerd should be your choice.</p><p>If you want a lot of features and have a great team to manage your service mesh and its components and complexity, you can go with Istio. With Istio, you can easily configure egress and rules on outgoing traffic, something that can also be a bit tricky with Linkerd. Of course, resource usage and latency are two additional factors you need to keep in mind when making this decision, and Linkerd is the preferred choice for both.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bb650d51bc6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudzone/k8s-service-mesh-linkerd-or-istio-4bb650d51bc6">K8s Service Mesh: Linkerd or Istio</a> was originally published in <a href="https://medium.com/cloudzone">CloudZone</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure IoT Hub — how to expose it using fixed IP, and create a more secure environment along the way]]></title>
            <link>https://medium.com/cloudzone/azure-iot-hub-how-to-expose-it-using-fixed-ip-and-create-a-more-secure-environment-along-the-way-988661a8f67a?source=rss-9eacae91bb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/988661a8f67a</guid>
            <dc:creator><![CDATA[Ohad Senior]]></dc:creator>
            <pubDate>Sun, 04 Jul 2021 16:16:55 GMT</pubDate>
            <atom:updated>2021-07-04T16:16:55.415Z</atom:updated>
            <content:encoded><![CDATA[<h3>Azure IoT Hub — how to expose it using fixed IP, and create a more secure environment along the way</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*NBmeYP9s2WFkQziL.jpg" /></figure><p>One of the most painful outcomes of using PaaS services is the fact that they expose their endpoints via FQDN that resolves to a dynamic IP List that the cloud provider might change.</p><p>If you need to connect from on-prem to your PaaS service and whitelist that service using an IP address, you are in trouble!</p><p>At least at Azure, you can get the IP list of <a href="https://docs.microsoft.com/en-us/azure/virtual-network/service-tags-overview#use-the-service-tag-discovery-api-public-preview">Service Tags</a> using REST, Powershell, or Azure CLI. But, let’s say that you provide a solution for thousands of customers — do really want the headache of following up and updating them with IP list changes? And then waiting for them to implement the changes on their network appliances?</p><p>I had to develop a workaround for a customer that provides an IoT solution to thousands of clients. Each client had my customer’s IoT devices on-prem and needed to send data through their own Network Appliances (like Firewall, Proxies, etc) to Azure IoT Hub, which as we all know exposes FQDN that resolves to a dynamic IP address.</p><p>My workaround involved creating the following Azure components:</p><p>1. Azure Load-Balancer Standard SKU</p><p>2. VMSS with HAProxy VMs (Spot)</p><blockquote>I used <a href="https://www.packer.io/">Hashicorp Packer</a> to create the HAProxy images and push them into the <a href="https://docs.microsoft.com/en-us/azure/virtual-machines/shared-image-galleries">Azure shared image gallery</a>. As VMSS VMs are stateless and used only for HAProxy, to reduce costs I used Spot VMs.</blockquote><p>3. Shared Image Gallery</p><p>4. Private link</p><p>5. IoT Hub</p><p>6. <a href="https://cloud.google.com/kubernetes-engine">Google Cloud GKE</a> — for running IoT device simulation to POC and load test the solution that has been created in Azure.</p><h4>Data flow explained</h4><p>IoT devices at the clients’ sites send data to an Azure load-balancer that has a fixed PIP (Public-IP).</p><blockquote>Each client can whitelist the IoT hub connection, by configuring its network appliance to allow outbound traffic to that IP.</blockquote><p>From the load-balancer, traffic flows into VMSS with HAProxy installed, and HAProxy reroutes traffic to the Azure IoT Hub private link IP address (Private IP).</p><blockquote>We configure the Azure NSG, to allow traffic from our client’s IPs and on port <a href="https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-protocols#port-numbers">443 and MQTT (8883) and/or AMQP (5671)</a>.</blockquote><p>We then configure the IoT hub to admit traffic only from private links, thereby creating a much more secure environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pI6gv2VehttMf5FuGoT4fQ.png" /></figure><h3>Automation Explained</h3><h4>Packer</h4><p>For the VMSS HAProxy, I used <a href="https://www.packer.io/docs/builders/azure/arm">Hashicorp Packer ARM builder (HCL2) </a>which creates the images and pushes them to the Azure shared image gallery.</p><blockquote>Be aware that the shared image gallery and image definition need to be manually created beforehand, using IaC!</blockquote><p>Packer code</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a75ac8ab9afa97724993dfcacc1f27b/href">https://medium.com/media/3a75ac8ab9afa97724993dfcacc1f27b/href</a></iframe><p>HAProxy.cfg</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ff1d16bd5c45b85ec22df8442767960/href">https://medium.com/media/2ff1d16bd5c45b85ec22df8442767960/href</a></iframe><p>We can configure the Azure VMSS to do a rolling update whenever we push a new HAProxy image to the Azure shared image gallery.</p><h3>Load testing our configuration</h3><p>For load tests, I used Microsoft’s <a href="https://github.com/Azure-Samples/Iot-Telemetry-Simulator">IoT Telemetry Simulator</a>. The repo contains a helm chart that we can deploy and simulate thousands of devices that send data to our IoT Hub.</p><p>For the purpose of resolving my IoT Hub FQDN to the load-balancer Public IP, I added it to the helm chart deployment.yaml (lines 30–33) and the corresponding values in values.yaml (lines 27–28).</p><p>deployment.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42c200e43d7f408b25cdc4b1da799be7/href">https://medium.com/media/42c200e43d7f408b25cdc4b1da799be7/href</a></iframe><p>values.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11e15313daba61450665ad3cb6374907/href">https://medium.com/media/11e15313daba61450665ad3cb6374907/href</a></iframe><p>I deployed the helm chart into GKE. All this was performed with the following <a href="https://pulumi.com/"><strong>pulumi</strong></a> (IaC) code</p><p>__main__.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8c1c68d88645520bf9c3ece1a580edc/href">https://medium.com/media/f8c1c68d88645520bf9c3ece1a580edc/href</a></iframe><p>Pulumi.dev.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c984d2f368bae06b0b3d78f65670bbdc/href">https://medium.com/media/c984d2f368bae06b0b3d78f65670bbdc/href</a></iframe><h3>Conclusion</h3><p>Although our solution is not fully supported by Microsoft, and there are a number of ‘moving’ parts involved, we did manage to solve our IoT Hub Dynamic Public IP address issue and achieved a more secure IoT Hub flow.</p><p>Just remember to POC the solution properly and load test it to resemble your production environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=988661a8f67a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudzone/azure-iot-hub-how-to-expose-it-using-fixed-ip-and-create-a-more-secure-environment-along-the-way-988661a8f67a">Azure IoT Hub — how to expose it using fixed IP, and create a more secure environment along the way</a> was originally published in <a href="https://medium.com/cloudzone">CloudZone</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing WAF and mTLS on Kubernetes with Nginx ModSecurity]]></title>
            <link>https://medium.com/cloudzone/implementing-waf-and-mtls-on-kubernetes-with-nginx-modsecurity-34b1bbc14c09?source=rss-9eacae91bb7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/34b1bbc14c09</guid>
            <category><![CDATA[pulumi]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Ohad Senior]]></dc:creator>
            <pubDate>Tue, 01 Dec 2020 10:58:40 GMT</pubDate>
            <atom:updated>2020-12-01T10:58:40.239Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*7iJTKnaKTyflsvfrE2ISzw.png" /></figure><p>Hey there,</p><p>In a recent project that included deploying microservices into AKS, our client had a number of specific requirements:</p><ol><li>Use Azure Kubernetes Service (AKS) as the platform for the application microservices.</li><li>Integrate mTLS capabilities to authenticate clients approaching our client’s APIs.</li><li>Use the client certificate to validate the client’s origin (in our case, a hospital).</li><li>Protect the public-facing microservices with a web application firewall (WAF).</li></ol><h3><strong>Challenge</strong></h3><p>Azure does provide WAF services, like Application Gateway and Front Door, but neither of them has mTLS capabilities.</p><h3><strong>Solution</strong></h3><p>To meet our client’s requirements, we had to search for a third-party solution that provides it all. We came up with the idea of using the tried-and-tested Kubernetes<a href="https://kubernetes.github.io/ingress-nginx/"> Ingress-NGINX</a> Controller for the following reasons: as well as being an Ingress controller with all the advantages of the NGINX engine, it also supports mTLS (client requirement 3); with its <a href="https://www.modsecurity.org/">opensource WAF ModSecurity</a> add-on (client requirement 2), it provides <a href="https://coreruleset.org/">OWASP CRS</a> support; and we can add more rules if we want to.</p><p>For the validation requirement, we configured the NGINX to transfer the client certificate fingerprint to the backend app.</p><h3><strong>Solution Demo:</strong></h3><p>If you want to follow this demo, you will need the following:</p><ol><li>Azure account (<a href="https://azure.microsoft.com/en-us/free/">https://azure.microsoft.com/en-us/free/</a>).</li><li>Your own domain.</li><li>DNS to manage your DNS records (I manage mine with Azure’s DNS service).</li></ol><p>Let’s start by installing AKS (client requirement 1) with<a href="https://www.pulumi.com/"> Pulumi</a>, a rising star in the IaC world which uses familiar language code, like Python, Typescript, GO, and more.</p><ul><li>Install Pulumi (in my case MacOS)</li></ul><pre>$ brew install pulumi</pre><ul><li>Install <a href="https://www.python.org/downloads/">Python 3.6</a> or above and verify PIP is installed</li><li>Next, we will create a new Pulumi project</li></ul><pre>$ mkdir quickstart &amp;&amp; cd quickstart <br>$ pulumi new azure-python</pre><ul><li>The command will launch a short configuration section for a new Pulumi project.</li></ul><pre>Enter a value or leave blank to accept the (default), and press &lt;ENTER&gt;.<br>Press ^C at any time to quit.</pre><pre>project name: (pulum) aks-nginx-waf<br>project description: (A minimal Azure Python Pulumi program)<br>Created project ‘aks-nginx-waf’</pre><pre>Please enter your desired stack name.<br>To create a stack in an organization, use the format &lt;org-name&gt;/&lt;stack-name&gt; (e.g. `acmecorp/dev`).<br>stack name: (dev)<br>Created stack ‘dev’</pre><pre>azure:environment: The Azure environment to use (`public`, `usgovernment`, `german`, `china`): (public)<br>azure:location: The Azure location to use: (WestUS) westeurope<br>Saved config</pre><ul><li>Now we have three main files</li></ul><ol><li>Pulumi.yaml defines the project</li><li>Pulumi.dev.yaml contains <a href="https://www.pulumi.com/docs/intro/concepts/config/">configuration</a> values for the <a href="https://www.pulumi.com/docs/intro/concepts/stack/">stack</a> we initialized.</li><li>__main__.py is the Pulumi program that defines our stack resources</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b923bc1904fe176d3c2722ce477661c/href">https://medium.com/media/8b923bc1904fe176d3c2722ce477661c/href</a></iframe><ul><li>Next, we will deploy AKS</li></ul><pre>$ pulumi up</pre><ul><li>The next step is to connect to our AKS</li></ul><pre>$ az aks get-credentials -g &lt;your resource group name&gt; -n &lt;AKS cluster name&gt; — admin</pre><ul><li>Now, we create two namespaces - one for the application, and one for the Ingress-NGINX</li></ul><pre>$ kubectl create ns cldze<br>$ kubectl create ns ingress</pre><ul><li>Next, we have to create self-signed certificates for the client verification -mTLS (client requirement 3). (See this <a href="https://medium.com/@awkwardferny/configuring-certificate-based-mutual-authentication-with-kubernetes-ingress-nginx-20e7e38fdfca">blog</a> for more information about how to do this)</li></ul><pre>$ openssl req -x509 -sha256 -newkey rsa:4096 -keyout ca.key -out ca.crt -days 356 -nodes -subj ‘/CN=cldze’ <br>$ openssl req -new -newkey rsa:4096 -keyout server.key -out server.csr -nodes -subj ‘/CN=cldze.info’<br>openssl x509 -req -sha256 -days 365 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt<br>$ openssl req -new -newkey rsa:4096 -keyout client.key -out client.csr -nodes -subj ‘/CN=client’<br>openssl x509 -req -sha256 -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 02 -out client.crt</pre><ul><li>For the server authentication, I created a Let’s Encrypt certificate with Certbot. (See this <a href="https://bit.ly/2TzISDA">blog</a> for more information about how to do this)</li></ul><pre>$ sudo certbot certonly \<br> — manual \<br> — preferred-challenges=dns \<br> — email user@cldze.info \ # Replace suffix with your own domain<br> — server <a href="https://acme-v02.api.letsencrypt.org/directory">https://acme-v02.api.letsencrypt.org/directory</a> \<br> — agree-tos \<br>-d “*.cldze.info” # Replace with your own domain</pre><p>The result of this command is two pem files privkey.pem and fullchain.pem.</p><ul><li>Now, after completing all the certificate creation steps, we can deploy secrets into the AKS app namespace, for the Ingress deployment.</li></ul><pre><strong># Server Authentication (using Letsencrypt)</strong><br>$ sudo kubectl create secret tls ingress — key privkey.pem — cert fullchain.pem -ncldze<br><strong># Client Authentication (using the self-signed)</strong><br>$ kubectl create secret generic ca-secret — from-file=ca.crt=ca.crt -ncldze</pre><ul><li>Now for the Ingress-NGINX deployment. I use Helm 3 to deploy Ingress-NGINX into the cluster, with the following value file:</li></ul><pre><strong># To enable modsecurity and owasp</strong><br> enable-modsecurity: “true”<br> enable-owasp-modsecurity-crs: “true”</pre><p>(See <a href="https://bit.ly/3jOz3fO">here</a> for an explanation of the different ModSecurity configuration option s)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8452cfbdadb9eb4db7144cdf4c22185/href">https://medium.com/media/e8452cfbdadb9eb4db7144cdf4c22185/href</a></iframe><ul><li>Now that we have the Ingress-NGINX Controller up and running, let’s deploy our app into AKS. The app will just echo back to us with HTTP request properties. We also deploy the service and Ingress in the same yaml stack. Each of the ModSecurity and configuration annotation snippets will demonstrate one of the capabilities that our use case needs.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6050db02ec70e3d03b121f52e89ed714/href">https://medium.com/media/6050db02ec70e3d03b121f52e89ed714/href</a></iframe><p>Now we can check if our Ingress configuration answers the client’s requirements.</p><h4>Client requirement 1: We are using AKS as our application platform.</h4><h4><strong>Client requirements 2 and 3: Enforcing mTLS and forwarding the client fingerprint to the client microservice for another validation phase.</strong></h4><p>Let’s try to curl the website without client certificate and key certificate - we get an error message: “400 Bad Request”.</p><pre>curl — http2 <a href="https://echo.cldze.info/">https://echo.cldze.info</a><br>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;400 No required SSL certificate was sent&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;center&gt;&lt;h1&gt;400 Bad Request&lt;/h1&gt;&lt;/center&gt;<br>&lt;center&gt;No required SSL certificate was sent&lt;/center&gt;<br>&lt;hr&gt;&lt;center&gt;nginx&lt;/center&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>And if we try with client and key certificate we get “200”.</p><pre>curl — http2 <a href="https://echo.cldze.info/">https://echo.cldze.info</a> — cert client.crt — key client.key<br>{<br> “path”: “/”,<br> “headers”: {<br> “host”: “echo.cldze.info”,<br> “ssl-client-verify”: “SUCCESS”,<br> “ssl-client-subject-dn”: “CN=client”,<br> “ssl-client-issuer-dn”: “CN=cldze”,<br> “x-request-id”: “82513020001a3ebd584c7b5a0c2767df”,<br> “x-real-ip”: “34.242.209.15”,<br> “x-forwarded-for”: “34.242.209.15”,<br> “x-forwarded-host”: “echo.cldze.info”,<br> “x-forwarded-port”: “443”,<br> “x-forwarded-proto”: “https”,<br> “x-scheme”: “https”,<br> “x-client-fingerprint”: “2e36447d771d246111d52337b2fbcd5a4a3568aa”,<br> “user-agent”: “curl/7.61.1”,<br> “accept”: “*/*”<br> },<br> “method”: “GET”,<br> “body”: “”,<br> “fresh”: false,<br> “hostname”: “echo.cldze.info”,<br> “ip”: “34.242.209.15”,<br> “ips”: [<br> “34.242.209.15”<br> ],<br> “protocol”: “https”,<br> “query”: {},<br> “subdomains”: [<br> “echo”<br> ],<br> “xhr”: false,<br> “os”: {<br> “hostname”: “http-https-echo-deployment-5c969b8dcf-nvmmt”<br> },<br> “connection”: {}</pre><p>We can also see that we have forwarded the client certificate fingerprint.</p><pre>“x-client-fingerprint”: “2e36447d771d246111d52337b2fbcd5a4a3568aa”,</pre><pre>openssl x509 -noout -in client.crt -fingerprint -noout<br>SHA1 Fingerprint=2E:36:44:7D:77:1D:24:61:11:D5:23:37:B2:FB:CD:5A:4A:35:68:AA</pre><h4><strong>Now, let’s turn to client requirement 4: ModSecurity as WAF.</strong></h4><p>We have created two rules and SecRuleEngine is ‘On’. This means that ModSecurity will be in prevention mode.</p><p>Let&#39;s check the IP rule :</p><pre>SecRule REMOTE_ADDR “@ipMatch 34.242.209.15” “log,deny,id:161,status:403,msg:\’Non IP address\’”</pre><p>I get “ 403 Forbidden” curling from IP “34.242.209.15”</p><pre>$ curl — http2 <a href="https://echo.cldze.info/">https://echo.cldze.info</a> — cert client.crt — key client.key<br>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;403 Forbidden&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;center&gt;&lt;h1&gt;403 Forbidden&lt;/h1&gt;&lt;/center&gt;<br>&lt;hr&gt;&lt;center&gt;nginx&lt;/center&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>$ curl checkip.amazonaws.com<br>34.242.209.15</pre><p>let&#39;s check the logs to see the error:</p><pre>$ kubectl logs po/&lt;ingress pod name&gt; -ningress we get the modsecurity log</pre><pre>2020/11/01 15:03:35 [error] 15446#15446: *980749 [client 34.242.209.15] ModSecurity: Access denied with code 403 (phase 1). Matched “Operator `IpMatch’ with parameter `34.242.209.15&#39; against variable `REMOTE_ADDR’ (Value: `34.242.209.15&#39; ) [file “&lt;&lt;reference missing or not informed&gt;&gt;”] [line “4”] [id “161”] [rev “”] [msg “Non IP address”] [data “”] [severity “0”] [ver “”] [maturity “0”] [accuracy “0”] [hostname “10.0.0.210”] [uri “/”] [unique_id “160424301560.131541”] [ref “v0,13”], client: 34.242.209.15, server: echo.cldze.info, request: “GET / HTTP/2.0”, host: “echo.cldze.info”</pre><p>Now, let’s check the request header rule: as user: <em>admin</em> I get blocked; changing to user: <em>user</em>, I pass.</p><pre>$ curl — http2 <a href="https://echo.cldze.info/">https://echo.cldze.info</a> -H “user-agent: <strong>admin</strong>” — cert client.crt — key client.key</pre><pre>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;403 Forbidden&lt;/title&gt;&lt;/head&gt;<br>&lt;body&gt;<br>&lt;center&gt;&lt;h1&gt;403 Forbidden&lt;/h1&gt;&lt;/center&gt;<br>&lt;hr&gt;&lt;center&gt;nginx&lt;/center&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><pre>$ curl — http2 <a href="https://echo.cldze.info/">https://echo.cldze.info</a> -H “user-agent: <strong>user</strong>” — cert client.crt — key client.key <br></pre><pre>{<br> “path”: “/”,<br> “headers”: {<br> “host”: “echo.cldze.info”,<br> “ssl-client-verify”: “SUCCESS”,<br> “ssl-client-subject-dn”: “CN=client”,<br> “ssl-client-issuer-dn”: “CN=cldze”,<br> “x-request-id”: “37cb4f2120e416ca317ffe674d53a0dd”,<br> “x-real-ip”: “34.242.209.15”,<br> “x-forwarded-for”: “34.242.209.15”,<br> “x-forwarded-host”: “echo.cldze.info”,<br> “x-forwarded-port”: “443”,<br> “x-forwarded-proto”: “https”,<br> “x-scheme”: “https”,<br> “x-client-fingerprint”: “2e36447d771d246111d52337b2fbcd5a4a3568aa”,<br> “accept”: “*/*”,<br> “user-agent”: “user”</pre><h3>Conclusion :</h3><p>Using ModSecurity and Ingress-NGINX, we have managed to resolve all our client’s demands that couldn’t be met by the Azure service alone. Ingress-NGINX and ModSecurity are two powerful tools that give us the agility and freedom to control Ingress traffic and protect our environment and we have the extra benefit of minimizing our vendor-lock.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34b1bbc14c09" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloudzone/implementing-waf-and-mtls-on-kubernetes-with-nginx-modsecurity-34b1bbc14c09">Implementing WAF and mTLS on Kubernetes with Nginx ModSecurity</a> was originally published in <a href="https://medium.com/cloudzone">CloudZone</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>