<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>s3 on Digi Hunch</title><link>https://www.digihunch.com/tag/s3/</link><description>Recent content in s3 on Digi Hunch</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Thu, 17 Apr 2025 14:04:59 -0400</lastBuildDate><atom:link href="https://www.digihunch.com/tag/s3/index.xml" rel="self" type="application/rss+xml"/><item><title>EKS impression</title><link>https://www.digihunch.com/2022/12/eks-impression/</link><pubDate>Fri, 23 Dec 2022 18:18:19 -0400</pubDate><guid>https://www.digihunch.com/2022/12/eks-impression/</guid><description>&lt;img src="https://www.digihunch.com/wp-content/uploads/2025/04/eks-impression-feature.webp" alt="Featured image of post EKS impression" /&gt;&lt;p class="wp-block-paragraph"&gt;I&amp;#8217;ve worked on a few &lt;a href="https://www.digihunch.com/2021/12/aks-troubleshooting-lessons-learned/"&gt;AKS projects&lt;/a&gt; previously. Since I joined AWS I wanted to put aside some time to check out EKS (Elastic Kubernetes Service). Here in this post, I put down my first impression on EKS, and also share my Terraform template in &lt;a href="https://github.com/digihunch/cloudkube"&gt;cloudkube&lt;/a&gt; project to create an EKS cluster.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Similar to AKS, EKS exposes API endpoint and the control plane components are hidden from AWS users. When creating EKS cluster it does not create the underlying VPC and subnets. Therefore, you have create an existing VPC and at least two subnets ahead of time, and specify them during EKS creation. Bear in mind that there is a &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/network_reqs.html"&gt;list of requirement&lt;/a&gt; for the VPC and subnets.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In the cluster, the CNI that EKS officially supports is Amazon VPC CNI plugin. It is available as an add-on. Similar to Azure CNI, each Pod gets its own IP address. In addition, EKS supports other &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/alternate-cni-plugins.html"&gt;compatible CNI plugins&lt;/a&gt; such as Calico, Cilium, Weave Net and Antrea.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="h-computing-nodes-in-eks"&gt;Computing Nodes in EKS&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;There are three modes to address computing capacity: self-managed nodes, EKS managed node groups and AWS Fargate. The documentation has a &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/eks-compute.html"&gt;comparison table&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;With self-managed nodes, users create EC2 instances separately and then register them to the control plane. The instances must use the same IAM role and AMI. You can use Auto Scaling groups of &lt;a href="https://aws.amazon.com/bottlerocket/"&gt;Bottlerocket&lt;/a&gt; (AWS-sponsored purpose-built Linux distro for container host) nodes. The self-managed node option is mostly for AWS outpost customers who bring in their own computing capacity from data centre.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;If you provision computing capacity from AWS, it makes sense to assign EKS managed node groups when creating EKS cluster. We can turn on &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/autoscaling.html"&gt;Cluster Autoscaler&lt;/a&gt;, a Kubernetes construct to manage the auto scaling of node groups. Sometimes we want to have more than one node groups. For example, to build a multi-architecture cluster, we need one node group with amd64 nodes and the other with arm64 nodes (e.g. instances with &lt;a href="https://aws.amazon.com/ec2/graviton/"&gt;Graviton&lt;/a&gt; processor). In general, arm-based CPU delivers better performance with less power consumption and the industry is slowly moving towards more arm-based CPU architecture.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Fargate is what I call managed computing service for EKS. With Fargate you do not need to tweak Cluster Autoscaler to self-manage computing capacity. The Fargate documentation has a long list of &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/fargate.html"&gt;considerations&lt;/a&gt;. For example, Pods must match a Fargate profile (&lt;a href="https://github.com/digihunch/real-quicK-cluster/blob/main/eks/cluster-fargate.yaml"&gt;here&lt;/a&gt;&amp;#8216;s an example) at the time that they&amp;#8217;re scheduled to run on Fargate. So we need to build Fargate profile and Pod labelling properly. Also, Fargate does not support DaemonSet. Another big consideration is that Fargate does not support non-VPC CNI. In my opinion these are pretty significant limitations. Many workloads (system-level or application-level) would need Daemonset (e.g. kube-proxy, some CNI or CSI drivers, &lt;a href="https://www.dynatrace.com/support/help/setup-and-configuration/setup-on-container-platforms/kubernetes/get-started-with-kubernetes-monitoring/set-up-k8s-monitoring-daemonset"&gt;Dynatrace&lt;/a&gt; monitoring). &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The pro of Fargate is the serverless computing model. The construct of a Fargate profile isn&amp;#8217;t complicated. You just specify subnets, namespace and labels. However, the downside is the long list of considerations. Some teams may consider these restrictions too much. The other overhead is the need to manage Fargate profile to ensure all Pods are scheduled somewhere. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To me, using Fargate alone impairs portability of workload. The good thing is that Fargate and Managed Node Group are not mutually exclusive on a cluster. In most cases, we can go partially serverless, and reap the benefits of both of them. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Node AutoScaling&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For workloads that don&amp;#8217;t have a matching Fargate profile, we have to figure out node autoscaling ourselves. I touched on Cluster Autoscaler in &amp;#8220;&lt;a href="https://www.digihunch.com/2022/03/autoscaling-in-kubernetes-from-metric-based-to-event-driven/"&gt;Autoscaling on Kubernetes Platform&lt;/a&gt;&amp;#8220;. CA works on AWS as well and is triggered upon a Pod coming to &lt;em&gt;unschedulable&lt;/em&gt; status in Scheduler. There is some limitations though. For example, CA interacts with Autoscaling Group (instead of EC2 instances directly). When it determines it&amp;#8217;s time to scale up, it bumps up the desired capacity by one at a time in the Autoscaling group. The configurations in Autoscaling group may also be at play and CA do not have direct control. For example, the &amp;#8220;&lt;a href="https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-scaling-cooldowns.html"&gt;scaling cooldown&lt;/a&gt;&amp;#8220;. The pool of nodes is homogenous as per the pre-configured launch template and CA has no control. If a Pod requires a different type of node (e.g. ARM64 CPU, spot instance, etc), then we&amp;#8217;d first have to create a node group with the desired node type. Moreover, in the worst cases, one-at-a-time scale-up does not meet the increase of demand driven by Pod increases, causing nuances such as racing conditions. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Because the Cluster Autoscaler doesn&amp;#8217;t really deal with the nodes themselves, this kind of integration is clunky and slow. Nearly half of Kubernetes customers on AWS report that configuring cluster auto scaling using the Kubernetes Cluster Autoscaler is challenging and restrictive, according to &lt;a href="https://aws.amazon.com/blogs/aws/introducing-karpenter-an-open-source-high-performance-kubernetes-cluster-autoscaler/"&gt;this&lt;/a&gt; blog post. As a result, AWS launched an open-source cluster autoscaler project, &lt;a href="https://karpenter.sh/"&gt;Karpenter&lt;/a&gt;. Karpenter first only supported EKS but now the support includes other CSPs. For EKS, Karpenter directly interact with different types of EC2 instances.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Karpenter makes node scaling work in a more cloud-native manner. In the presence of unschedulable Pods, Karpenter &lt;span style="text-decoration: underline" class="underline"&gt;bypasses the Kubernetes scheduler&lt;/span&gt; and works directly with the Cloud provider, to launch the minimal compute resources needed to fit those Pods and immediately binds the Pods to the newly provisioned Nodes without waiting for scheduler. As Pods are removed or rescheduled to other nodes, Karpenter looks for opportunities to terminate under-utilized nodes. Karpender defines a CR called Provisioner to specify node provisioning configuration, such as instance size, zone, CPU architecture, etc. It is a manifest that describes a node group so the node scaler is aware of all the available node types. You can have multiple Provisioners for different needs, just like node groups. The Provisioner CR can also set TTL for empty Nodes, such that once a Node has no pods other than DaemonSet, Karpenter will terminate the Node on TTL expiry.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Karpenter&amp;#8217;s idea is similar to the idea of AutoPilot cluster in GKE. The new EKS workshop has an &lt;a href="https://www.eksworkshop.com/docs/autoscaling/compute/karpenter/"&gt;section&lt;/a&gt; on how to set up CA and Karpenter in practice.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="h-identity-management-for-eks"&gt;Identity Management for EKS&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For IAM, we need to be concerned with three aspects. The management traffic to the cloud service, the management traffic for Kubernetes cluster and business traffic. &lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-regular"&gt;&lt;table class="has-white-background-color has-background has-fixed-layout"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;strong&gt;Traffic type&lt;/strong&gt;&lt;/th&gt;&lt;th&gt;AWS&lt;/th&gt;&lt;th&gt;Azure&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;I. Cloud Service Endpoint (Management Traffic for Cloud Service)&lt;/td&gt;&lt;td&gt;AWS IAM identity&lt;/td&gt;&lt;td&gt;Azure RBAC&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;II. Kubernetes API (Management Traffic for K8s Cluster)&lt;/td&gt;&lt;td&gt;IAM mapping or OIDC&lt;/td&gt;&lt;td&gt;Azure RBAC (implementation of OIDC)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;III. Business traffic&lt;/td&gt;&lt;td&gt;Up to Kubernetes Ingress&lt;/td&gt;&lt;td&gt;Up to Kubernetes Ingress&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For business traffic (type III), it is all up to the Ingress. I&amp;#8217;ve written another article on &lt;a href="https://medium.com/slalom-build/managing-ingress-traffic-on-kubernetes-platforms-ebd537cdfb46"&gt;managing ingress traffic on Kubernetes platforms&lt;/a&gt;. We interact with cloud service endpoint (type II) with either AWS CLI or Terraform, to create any object, including resources needed for a cluster. This is generally how we work with cloud service, not specific to Kubernetes. Usually the IAM identity assumes another IAM role, which empowers it with a lot of permissions.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For access to Kubernetes API (type III), EKS supports OIDC and IAM mapping. AWS documentation refers to this as &amp;#8220;&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/cluster-auth.html"&gt;Cluster Authentication&lt;/a&gt;&amp;#8220;. There is one special scenario where your identity for type II access inherits your identity for type I access. As the &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/add-user-role.html"&gt;document&lt;/a&gt; puts:&lt;/p&gt;&#10;&lt;blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When you create an Amazon EKS cluster, the AWS Identity and Access Management (IAM) entity user or role, such as a&amp;nbsp;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html"&gt;federated user&lt;/a&gt;&amp;nbsp;that creates the cluster, is automatically granted&amp;nbsp;&lt;code&gt;system:masters&lt;/code&gt;&amp;nbsp;permissions in the cluster&amp;#8217;s role-based access control (RBAC) configuration in the Amazon EKS control plane. This IAM entity doesn&amp;#8217;t appear in any visible configuration, so make sure to keep track of which IAM entity originally created the cluster.&amp;nbsp;&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p class="wp-block-paragraph"&gt;This special scenario (I call it the &amp;#8220;&lt;strong&gt;implicit master&lt;/strong&gt; &lt;strong&gt;user&lt;/strong&gt;&amp;#8220;) allows us to perform critical activities on the cluster, such as creating IAM mapping, or OIDC configuration. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The above addressed how AWS resource access Kubernetes resource. On the other hand, to address how a Kubernetes resource access AWS resources, we need IRSA (&lt;a href="https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up-enable-IAM.html"&gt;IAM Roles for Service Account&lt;/a&gt;). We have a service account in Kubernetes and map it to an IAM role.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;AppMesh&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://aws.amazon.com/blogs/compute/introducing-aws-app-mesh-service-mesh-for-microservices-on-aws/"&gt;AppMesh&lt;/a&gt; is AWS&amp;#8217; Envoy based service-mesh offering supporting Kubernetes cluster, ECS service and even EC2 instance. AppMesh&amp;#8217;s control plane is a managed AWS service, with a &lt;a href="https://aws.github.io/aws-app-mesh-controller-for-k8s/"&gt;controller&lt;/a&gt; running on the Kubernetes cluster. To install AppMesh on the cluster:&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&#10;&lt;li&gt;On the EKS cluster, install AppMesh Controller using Helm&lt;/li&gt;&#10;&lt;li&gt;Associate the cluster with IAM OIDC provider&lt;/li&gt;&#10;&lt;li&gt;Create an IAM role for the appmesh-controller service account&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p class="wp-block-paragraph"&gt;After these steps, you can create a mesh using CloudFormation, Terraform, etc. The data plane (Envoy proxy) can run on Kubernetes (as sidecar). Traffic between control plane and data plane can go through private link (Interface VPC &lt;a href="https://docs.aws.amazon.com/app-mesh/latest/userguide/infrastructure-security.html"&gt;endpoint&lt;/a&gt;) for added security. Like Istio, AppMesh enables mTLS. For observability, you can export Envoy metrics with Prometheus. Coupled with XRay, AppMesh also supports distributed tracing.&lt;/p&gt;&#10;&lt;figure class="wp-block-image size-full"&gt;&lt;img loading="lazy" decoding="async" width="832" height="354" src="https://www.digihunch.com/wp-content/uploads/2022/12/appmesh-virtualgateway.webp" alt="" class="wp-image-12883" srcset="https://www.digihunch.com/wp-content/uploads/2022/12/appmesh-virtualgateway.webp 832w, https://www.digihunch.com/wp-content/uploads/2022/12/appmesh-virtualgateway-300x128.webp 300w, https://www.digihunch.com/wp-content/uploads/2022/12/appmesh-virtualgateway-768x327.webp 768w" sizes="auto, (max-width: 832px) 100vw, 832px" /&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;AppMesh uses a different set of CRDs than Istio. Key CRDs are:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;strong&gt;Mesh&lt;/strong&gt;: represents an entire service mesh. At mesh level you can configure Egress filter (to allow or deny external traffic) and set IP version (v4 vs v6)&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;VirtualGateway&lt;/strong&gt;: a CRD that represents an &lt;a href="https://aws.amazon.com/blogs/containers/introducing-ingress-support-in-aws-app-mesh/"&gt;Ingress&lt;/a&gt; in to the Mesh. A virtual gateway allows resources that are outside of your mesh to communicate to resources that are inside of your mesh. A virtual gateway references Envoy proxy deployment by podSelector. It references GatewayRoutes by namespaceSelector, and optionally gatewayRouteSelector. You also specify listeners in the manifest to reference Envoy proxy Service (LoadBalancer Type).&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;GatewayRoute&lt;/strong&gt;: A gateway route is attached to a virtual gateway and routes traffic to an existing virtual service. If a route matches a request, it can distribute traffic to a target virtual service. In the manifest, you specify a list of httpRoute, each with matching condition and action. In the action section you can specify virtualService as target.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;VirtualService&lt;/strong&gt;: an abstraction of a real service provided by a virtual node directly or indirectly by means of a virtual router. Dependent services call your virtual service by its virtualServiceName, and those requests are routed to the VirtualNode or VirtualRouter that is specified as the provider for the VirtualService.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;VirtualRouter&lt;/strong&gt;: Virtual routers handle traffic for virtual services. In a virtual router manifest, you can define Route to direct incoming requests to virtual nodes as target.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;VirtualNode&lt;/strong&gt;: A virtual node acts as a logical pointer to a particular task group (i.e. ECS service, Kubernetes deployment). It represent a Service in the AppMesh. In the manifest, you reference Pods by podSelector, specify listeners for any inbound traffic that your virtual node expects, and specify serviceDiscovery for your task group.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;You can configure those Custom Resources using YAML manifests (and check the &lt;a href="https://docs.aws.amazon.com/app-mesh/latest/APIReference/Welcome.html"&gt;API reference&lt;/a&gt; a lot). Alternatively, you can configure them from AWS CLI or AWS console. The console will help you visualize what can be configured. For further details on how these CRs play together, there is a &lt;a href="https://www.appmeshworkshop.com/"&gt;workshop&lt;/a&gt; for AppMesh.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;EKS cluster using Terraform&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Officially, there is an &lt;a href="https://github.com/aws-ia/terraform-aws-eks-blueprints"&gt;EKS blueprint&lt;/a&gt; project for provisioning EKS cluster in Terraform.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;I also keep my own Terraform code in the AWS directory of &lt;a href="https://github.com/digihunch/cloudkube"&gt;cloudkube&lt;/a&gt; project. It works out to be a little more complex than my Terraform template to create Azure Kubernetes Cluster (Azure directory). Because I had to create Cognito resources with initial credential to allow users to connect to cluster without using the implicit master account.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Below is the diagram of the processes.&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-full"&gt;&lt;img loading="lazy" decoding="async" width="776" height="496" src="https://www.digihunch.com/wp-content/uploads/2022/12/eks-tf-mod.webp" alt="" class="wp-image-12881" srcset="https://www.digihunch.com/wp-content/uploads/2022/12/eks-tf-mod.webp 776w, https://www.digihunch.com/wp-content/uploads/2022/12/eks-tf-mod-300x192.webp 300w, https://www.digihunch.com/wp-content/uploads/2022/12/eks-tf-mod-768x491.webp 768w" sizes="auto, (max-width: 776px) 100vw, 776px" /&gt;&lt;figcaption class="wp-element-caption"&gt;Create EKS cluster with Terraform module&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The template configures kubectl access on a Bastion host, which assumed the same role that our IAM user uses to create the Kubernetes cluster. Therefore, the IAM role is the master identity. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Note that the IAM user (power-user) has very powerful permissions. Usually it is ideal to assign lots of permission to IAM Roles (temporary credential) instead of IAM user (long-term credential). So the &lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html"&gt;role chaining&lt;/a&gt; would look like:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;The IAM user that Terraform uses has no permission other than assuming a &amp;#8220;PowerUser&amp;#8221; role&lt;/li&gt;&#10;&lt;li&gt;The PowerUser role trusts the IAM user. It also has the permission to assume the &amp;#8220;EKS-Manager&amp;#8221; role&lt;/li&gt;&#10;&lt;li&gt;The EKS-Manager role trusts PowerUser&amp;#8217;s role session.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;However, the role chaining scenario above is not currently supported in &lt;a href="https://github.com/hashicorp/terraform-provider-aws/issues/22728"&gt;Terraform&lt;/a&gt;. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;I use a Bastion host because the cluster endpoint is on private subnet. The bastion host is on a public subnet. However, if we do not like public subnet and public IP, we can place the bastion host on a private subnet, and use SSM system manager agent with &lt;a href="https://aws.amazon.com/premiumsupport/knowledge-center/systems-manager-ssh-vpc-resources/"&gt;SSH tunnel plugin &lt;/a&gt;to have SSH access to private bastion host.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="h-summary"&gt;Summary&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;I first came across &lt;a href="https://medium.com/@andreidascalu/the-awfulness-of-aws-eks-d7700c1eccdc"&gt;this&lt;/a&gt; article about EKS and its awfulness and then decided to check out EKS. I&amp;#8217;m not sure all points are still valid but it&amp;#8217;s generally real-life experiences. There are also many peripheral services, such as AMP (AWS Managed Prometheus), AMG (AWS Managed Grafana), ADOT (AWS Distro for Open Telemetry), AppMesh (Another &lt;a href="https://www.appmeshworkshop.com/introduction/appmesh_components/"&gt;Envoy-based Service Mesh&lt;/a&gt;, &lt;a href="https://vedcraft.com/architecture/aws-appmesh-vs-istio-comparison-of-service-mesh/"&gt;easier to manage than Istio&lt;/a&gt; but less Powerful), with a lot to explore.&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2022/12/landing-zone-in-aws/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Landing Zone in AWS – An Introduction&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2023/01/optimize-cpu-and-memory-for-kubernetes-pods/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Optimize CPU and Memory for Kubernetes Pod&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>AWS serverless services and developer tools</title><link>https://www.digihunch.com/2022/11/aws-serverless-services-and-developer-tools/</link><pubDate>Wed, 09 Nov 2022 12:19:00 -0400</pubDate><guid>https://www.digihunch.com/2022/11/aws-serverless-services-and-developer-tools/</guid><description>&lt;img src="https://www.digihunch.com/wp-content/uploads/2025/04/feature-server-less-devtools.webp" alt="Featured image of post AWS serverless services and developer tools" /&gt;&lt;p class="wp-block-paragraph"&gt;As &lt;a href="https://www.digihunch.com/2022/10/computing-from-paas-to-serverless/"&gt;discussed&lt;/a&gt;, serverless simply means cloud services that delegate autoscaling management to cloud platform. In my mind, the word &amp;#8220;serverless&amp;#8221; translates into &amp;#8220;managed autoscaling&amp;#8221;. As long as a service&amp;#8217;s capacity is managed automatically, we can consider it as serverless. Given that capacity scaling accounts for a good amount of work in IT operation, moving to serverless significantly reduces operation overhead. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Unlike containers, the serverless ecosystem lacks standard. Since &lt;a href="https://serverlessland.com/"&gt;AWS&lt;/a&gt; is leading the charge in this field, let&amp;#8217;s take a look at its offerings.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Lambda Function&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Lambda functions have triggers. We can configure a trigger from an AWS service, or even a non-AWS service which supports AWS event bridge, to invoke Lambda function. Based on the trigger (e.g. SQS, S3, DynamoDB), you then specify event source mapping. For example, if trigger is SQS, you need to specify the queue name, batch size and batch window in event source mapping. If trigger is S3, the event source mapping needs to specify bucket, S3 action, etc. Event source mappings vary significantly among trigger types.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Depending on the trigger, a Lambda function may be invoked in one of the two ways:&lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-stripes"&gt;&lt;table class="has-cyan-bluish-gray-background-color has-background"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-sync.html" target="_blank" rel="noreferrer noopener"&gt;Synchronous&lt;/a&gt; invocation&lt;/th&gt;&lt;th&gt;&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#async-overview" target="_blank" rel="noreferrer noopener"&gt;Asynchronous&lt;/a&gt; invocation&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;Summary&lt;/td&gt;&lt;td&gt;Requestor fires request and waits until it receives response before closing connection.&lt;/td&gt;&lt;td&gt;Lambda places triggering event in a queue and immediately returns a success code (202). Then a separate process reads events off the queue and sends them to your Lambda function. When the function returns a success response or exits without throwing an error, Lambda sends a record of the invocation to an EventBridge event bus.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Pros&lt;/td&gt;&lt;td&gt;Requestor get invocation result as soon as function run is complete&lt;/td&gt;&lt;td&gt;The queue decouples the request and invocation.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Cons&lt;/td&gt;&lt;td&gt;When load is high the function requires higher capacity for concurrency&lt;/td&gt;&lt;td&gt;Involves more parties at play and can be quite complex to troubleshoot.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://docs.aws.amazon.com/lambda/latest/operatorguide/invocation-modes.html" target="_blank" rel="noreferrer noopener"&gt;Here&lt;/a&gt; is a chart with the triggers that support each invocation mode. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Real-life applications often need to include libraries and dependencies that requires language-specific steps. For example, NodeJS applications need &lt;a href="https://aws.amazon.com/blogs/compute/optimizing-node-js-dependencies-in-aws-lambda/"&gt;bundling&lt;/a&gt; (often using Webpack or esbuild). We can use &lt;a href="https://aws.amazon.com/blogs/compute/using-lambda-layers-to-simplify-your-development-process/"&gt;Lambda layers&lt;/a&gt; to simplify the management. The additional libraries often need to be packaged in S3 bucket or as container image.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Lambda functions are subject to &lt;a href="https://aws.amazon.com/blogs/compute/operating-lambda-performance-optimization-part-1/"&gt;cold start&lt;/a&gt; to &lt;a href="https://betterprogramming.pub/lets-stop-talking-about-serverless-cold-starts-38e4c1fda963"&gt;cope with&lt;/a&gt;. When a lot of invocations occur about the same time, the order of executions might be different than the order of upstream events that invokes the function. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="h-api-gateway"&gt;API Gateway&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;AWS API Gateway is an &lt;a href="https://microservices.io/patterns/apigateway.html"&gt;API gateway&lt;/a&gt; implementation for REST and WebSocket APIs. It couples with &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/services-apigateway.html"&gt;Lambda&lt;/a&gt; in the classic &lt;a href="https://docs.aws.amazon.com/whitepapers/latest/serverless-multi-tier-architectures-api-gateway-lambda/welcome.html"&gt;multi-tier serverless&lt;/a&gt; architecture pattern. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In this classic pattern Lambda function often need to work with a database (e.g. DynamoDB etc), to perform &lt;a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete"&gt;CRUD operations&lt;/a&gt; and other custom business logics. The CRUD operations are so commonplace that it makes sense to use mapping template to configure CRUD operation instead of writing similar set of functions for each new data model. API Gateway supports such a &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html"&gt;mapping template&lt;/a&gt; called &lt;a href="https://velocity.apache.org/engine/devel/vtl-reference.html"&gt;Velocity Template Language&lt;/a&gt; (VTL), a technology from Apache &lt;a href="https://velocity.apache.org/"&gt;Velocity&lt;/a&gt; Project.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;API Gateway integrate with many other AWS services. Here are the available integration types:&lt;/p&gt;&#10;&lt;table id="tablepress-20" class="tablepress tablepress-id-20 tbody-has-connected-cells"&gt;&#10;&lt;thead&gt;&#10;&lt;tr class="row-1"&gt;&#10;&#9;&lt;th class="column-1"&gt;Integration Type&lt;/th&gt;&lt;th class="column-2"&gt;Description&lt;/th&gt;&lt;th class="column-3"&gt;Integration Mode&lt;/th&gt;&lt;th class="column-4"&gt;How it works&lt;/th&gt;&#10;&lt;/tr&gt;&#10;&lt;/thead&gt;&#10;&lt;tbody class="row-striping row-hover"&gt;&#10;&lt;tr class="row-2"&gt;&#10;&#9;&lt;td rowspan="2" class="column-1"&gt;AWS integration&lt;/td&gt;&lt;td rowspan="2" class="column-2"&gt;connects gateway to an AWS service action as the end point.&lt;/td&gt;&lt;td class="column-3"&gt;AWS_PROXY&lt;/td&gt;&lt;td class="column-4"&gt;this mode only supports only one action with one service: the function invoking action for Lambda service. Therefore it is available only for Lambda integration and no other AWS services. For that reason, it is also known as Lambda proxy integration. This mode is recommended for Lambda integration and is the default mode for LambdaIntegrationOption CDK construct. It connects a method (PUT, GET, etc) to a Lambda function and pass along the request on the way in, and the response on the way out. You do not set integration request or integration response. Even if you do, there’s no effect. This “pass-along” mode is easier to understand and configure. &lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-3"&gt;&#10;&#9;&lt;td class="column-3"&gt;AWS&lt;/td&gt;&lt;td class="column-4"&gt;this mode connects an API method to a broad range of supported AWS service action. Function invoking for Lambda service is a common example but not the only service action supported in this mode. When used in Lambda integration, it is also referred to as “Lambda custom integration”, or “normal (request/response mapping) integration”. This mode is good for advanced use cases (e.g. header modification) but involves more management effort. You have to control the mapping between method request and integration request, and between integration response and method response. &lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-4"&gt;&#10;&#9;&lt;td rowspan="2" class="column-1"&gt;HTTP integration&lt;/td&gt;&lt;td rowspan="2" class="column-2"&gt;for generic HTTP service endpoint&lt;/td&gt;&lt;td class="column-3"&gt;HTTP_PROXY&lt;/td&gt;&lt;td class="column-4"&gt;the pass-along mode for upstream HTTP endpoint&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-5"&gt;&#10;&#9;&lt;td class="column-3"&gt;HTTP&lt;/td&gt;&lt;td class="column-4"&gt;the request/response mapping mode for upstream HTTP endpoint&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;tr class="row-6"&gt;&#10;&#9;&lt;td class="column-1"&gt;MOCK integration &lt;/td&gt;&lt;td class="column-2"&gt;the API gateway itself serves as the endpoint.&lt;/td&gt;&lt;td class="column-3"&gt;MOCK&lt;/td&gt;&lt;td class="column-4"&gt;the API gateway itself acts endpoint without an upstream. One example use case is to return CORS-related headers upon a pre-flight OPTIONS query.&lt;/td&gt;&#10;&lt;/tr&gt;&#10;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;!-- #tablepress-20 from cache --&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The table above is a summary of API Gateway integration types as covered &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-integration-types.html"&gt;here&lt;/a&gt;. In the AWS context, proxy mode suggests that the request is not being morphed (transformed). In non-proxy mode, request or response may be modified on their ways in or out.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For API gateway to invoke lambda function, synchronous invocation is used by default. You can also configure API gateway to invoke Lambda function &lt;a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-integration-async.html" target="_blank" rel="noreferrer noopener"&gt;asynchronously&lt;/a&gt; by using headers.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;As with other API gateway implementations, AWS API Gateway can also connects to an authorizer (either another Lambda function or Cognito service) in order to authorize the incoming request.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;AppSync&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In a previous post, I discussed &lt;a href="https://www.digihunch.com/2022/10/graphql-and-grpc/"&gt;GraphQL&lt;/a&gt; as a modern and efficient alternative to REST API. &lt;a href="https://aws.amazon.com/appsync/"&gt;AppSync&lt;/a&gt; to GraphQL is the same as API Gateway to REST API. One of the advantages that GraphQL has over REST API is more information in the response. Oftentimes, we use a proxy that supports GraphQL in front of REST API service. AppSync can act as such proxy. I think of it as a managed &lt;a href="https://www.apollographql.com/docs/intro/platform"&gt;Apollo&lt;/a&gt; since they play the the role in the architecture. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Another benefit of GraphQL is the support of subscription, obviating WebSocket configuration. AppSync supports pub/sub API for real-time experience. Client application can get near real-time update as the data on the server is changed.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;We can configure AppSync to connect to different data sources to formulate GraphQL response. The data source can be an HTTP endpoint, a Lambda function, a database (Relational or DynamoDB), or OpenSearch. &lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large"&gt;&lt;img loading="lazy" decoding="async" width="1024" height="408" src="https://www.digihunch.com/wp-content/uploads/2022/12/appsync-1024x408.png" alt="" class="wp-image-7653" srcset="https://www.digihunch.com/wp-content/uploads/2022/12/appsync-1024x408.png 1024w, https://www.digihunch.com/wp-content/uploads/2022/12/appsync-300x119.png 300w, https://www.digihunch.com/wp-content/uploads/2022/12/appsync-768x306.png 768w, https://www.digihunch.com/wp-content/uploads/2022/12/appsync-1536x612.png 1536w, https://www.digihunch.com/wp-content/uploads/2022/12/appsync-2048x816.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /&gt;&lt;figcaption class="wp-element-caption"&gt;App Sync&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Between data source and the request, AppSync uses resolver to convert GraphQL payload to the underlying protocols and executes if the caller is authorized to invoke it. Resolvers are comprised of request and response mapping templates, which contain transformation and execution logic. AppSync also uses VTL as the mapping template for resolvers.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Messaging Services&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Messaging services have three patterns: queues, pub/sub, and event buses. In AWS, the corresponding services are SQS, SNS and EventBridge. Here is a good &lt;a href="https://aws.amazon.com/blogs/compute/choosing-between-messaging-services-for-serverless-applications/"&gt;post&lt;/a&gt; about how to choose among them.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Queues are temporary storage to decouple the source and destination systems. The expectation is that the actions in response to the message can be delayed. If that is not the case and the response needs to be immediate, that is by definition an event-driven pattern. A common solution is to have the AWS service invoke Lambda function. If that is not supported, we can use SNS as an intermediary. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;SNS is for simple event-driven pattern. In a more complicated event-driven architecture, we often need an event bus to route events in certain ways. We also need to support various &lt;a href="https://aws.amazon.com/eventbridge/integrations/"&gt;event sources&lt;/a&gt; by different software providers. Moreover, we want the capability to register our own event schema. These are the scenarios where EventBridge can help.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Developer tools&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In application development with serverless stack, the line between application and infrastructure is somewhat blurred. Developers often find themselves making repeated configuration on cloud resources while writing application code. For example, to test Python code (application), developer has to upload the code to S3, create Lambda function referencing the code, etc. This would require too much work with AWS CLI, or CloudFormation. The AWS &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/what-is-sam.html"&gt;SAM&lt;/a&gt; (AWS Serverless Application Model) is a better utility for serverless development workflow.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;SAM comes with its own CLI and developers can feed it with template that interacts with a number of serverless &lt;a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-resources-and-properties.html"&gt;resources&lt;/a&gt; (e.g. API, SimpleTable, Function, etc). I view SAM as one layer of abstraction on top of CloudFormation that handles some resources in serverless stack. It saves developers from re-writing resources in CloudFormation templates and keeping them consistent, which would have been tedious. Once you deployed your application using SAM, it will appear as a Lambda Application in the console.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;SAM templates are also declarative. It is simple but limited in feature. AWS CDK is also a powerful utility that works with general purpose programming language for IaC and interacts with all AWS resources. It is very powerful for building serverless applications. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;AWS Amplify&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;We have CDK, SAM and CloudFormation but we still have to ensure integration between those resources and our applications. For example, when creating a S3 buckets, they have to get the endpoint and reference it in the application code. So is Cognito. As a result, developers still have to spend time on resource integration. They still can&amp;#8217;t focus on business logic. We need a tool that can make opinionated configuration of cloud resources and automatically reference them from the application code. This is the purpose of AWS Amplify.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Amplify not only help application developers create backend resources with opinionated configurations. It also provides libraries for the application to use and connect to those resources seamlessly. Developers will need to include Amplify libraries in the application code. To create cloud resources, they can use Amplify &lt;a href="https://docs.amplify.aws/cli/"&gt;CLI&lt;/a&gt; or &lt;a href="https://docs.amplify.aws/console/uibuilder/figmatocode/#step-1-set-up-figma-file"&gt;Studio&lt;/a&gt; (a web portal from AWS console). &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Amplify natively supports a number of serverless resources such as API (using API gateway or AppSync), Storage (S3 and CloudFront), Lambda function, Cognito, etc. Developer may use Amplify CLI command to create such supported resources. Amplify will prompt some guiding questions in order to configure them correctly. In addition to the natively supported resources, developers can also create custom resources. They have to declare those custom resources with CloudFormation or CDK. I came across &lt;a href="https://github.com/aws-samples/amazon-location-samples/tree/main/maplibre-js-react-iot-asset-tracking"&gt;this&lt;/a&gt; project as a good illustration of how Amplify works. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The Amplify Studio can save developers from using Amplify CLI commands. It also can integrate with &lt;a href="https://en.wikipedia.org/wiki/Figma_(software)"&gt;Figma&lt;/a&gt;, providing developers with a framework for &lt;a href="https://aws.amazon.com/blogs/mobile/aws-amplify-studio-figma-to-fullstack-react-app-with-minimal-programming/"&gt;frontend development.&lt;/a&gt; However, in my experience, it is still &lt;a href="https://github.com/aws-amplify/amplify-ui/issues"&gt;glitchy&lt;/a&gt;. For now I stick to Amplify CLI.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Amplify also supports &lt;a href="https://docs.aws.amazon.com/amplify/latest/userguide/getting-started.html"&gt;hosting&lt;/a&gt; capability, providing users with opinionated and customizable CI/CD pipeline configuration.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;How about &amp;#8220;clientless&amp;#8221;&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Lambda function can also run client-side logics. System administrators have to create lots of client-side scripting. While Lambda functions can encapsulate those logics, we&amp;#8217;d still need a script orchestrator to invoke those functions. AWS &lt;a href="https://aws.amazon.com/step-functions/"&gt;Step Function&lt;/a&gt; comes to rescue. It was even regarded as the &lt;a href="https://itnext.io/why-step-functions-is-the-best-aws-service-you-are-not-using-4f3c133d7d0d"&gt;most under-utilized service&lt;/a&gt;. As the author states, a state machine (as design pattern) is simply a flow of actions with decision making logics.&amp;nbsp;AWS Step function helps you groom the logic flow of existing actions with &lt;a href="https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html" target="_blank" rel="noreferrer noopener"&gt;Amazon States Language&lt;/a&gt;. There are standard and express workflows. Each step is a state. A state can be of several different types, such as Choice, Task, Succeed, Fail, End, Map, Wait, Parallel. The task can be a Lambda function, and even AWS API calls. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;AWS Step function integrate with Lambda functions. It is typically used for patterns with long process and the need to orchestrate the execution of several Lambda functions. For specific use cases, look at these &lt;a href="https://docs.aws.amazon.com/step-functions/latest/dg/create-sample-projects.html" target="_blank" rel="noreferrer noopener"&gt;sample projects&lt;/a&gt;. For example, a network professional needs to run a lot of connectivity testing, reusing the same Python script but run it from different subnets. We need to create a Lambda function for commands like &amp;#8220;nc -vz&amp;#8221; then &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc-endpoints.html"&gt;invoke the lambda function from VPC&lt;/a&gt;, multiple times from different VPCs. We should use step function to drive this. It works like a Makefile on Linux, without requiring your own computer to run.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;AWS Step function also integrates with &lt;a href="https://docs.aws.amazon.com/step-functions/latest/dg/connect-supported-services.html" target="_blank" rel="noreferrer noopener"&gt;other AWS services&lt;/a&gt;, such as SNS, SQS, Dynamo, Batch, Glue, EMR, EKS, API gateway, event bridge.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Whenever we need to create a script, involving custom actions, or AWS API calls, we should consider using AWS step function to organize the actions. The benefits are: it saves you a laptop or bastion host (&amp;#8220;client-less&amp;#8221;), many ways to invoke them (not just cron&amp;#8221;). &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Summary&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In this post, we started with some serverless services in AWS. For server-side application, we can use API Gateway to invoke Lambda function. For client-side, we can use step function to invoke Lambda function. We then discussed some tools to speed up application development in serverless pattern. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;AWS categorizes both Amplify and AppSync under Front-end Mobile. Amplify does not represent any computing resources in AWS cloud. It is a library and CLI tools to enhance developer experience. AppSync on the other hand is a cloud computing resource acting as GraphQL API for mobile or web application. &lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2022/10/computing-from-paas-to-serverless/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Computing services: from PaaS to Serverless&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2022/11/key-mapping-on-external-pc-keyboard-on-macbook/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Key mapping for external PC keyboard on Mac&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>MinIO for S3-compatible Object Storage</title><link>https://www.digihunch.com/2022/09/minio-object-storage/</link><pubDate>Fri, 09 Sep 2022 09:00:00 -0400</pubDate><guid>https://www.digihunch.com/2022/09/minio-object-storage/</guid><description>&lt;img src="https://www.digihunch.com/wp-content/uploads/2025/04/feature-minio.webp" alt="Featured image of post MinIO for S3-compatible Object Storage" /&gt;&lt;p class="wp-block-paragraph"&gt;I reviewed some storage technologies on Kubernetes but they are all for block and file storage. In this post, I will discuss the current available options for container workload to use object storage. I will also touch on MinIO as an object storage solution.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading" id="h-object-storage"&gt;Object storage&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Block and file system are more native to operating system because they present themselves to the OS as a block device or file system attached to the OS. In other words, application processes running on the OS will be able to access the storage by address expressed as a POSIX-compatible path. On the contrary, object storage is a REST API service, operating at the application layer in the TCP/IP stack. Therefore, we can think of object storage as &amp;#8220;storage as a web service&amp;#8221;.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Object storage can be made very cheap. However, the application protocol may vary depending on the object storage provider. Amazon S3 is a forerunner in object storage market and its protocol has emerged as the de-facto standard for object storage. When building an application and if there is one object storage protocol to support, it should be S3. For non-S3 object storage services, we can front them with an S3 interface, if the provider itself does not have one. For example Ceph storage has its &lt;a href="https://docs.ceph.com/en/latest/radosgw/s3/"&gt;Gateway S3 API&lt;/a&gt;. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Container Object Storage Interface&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;If we use S3 as the universal object storage protocol, does that also address object storage access with container workload on Kubernetes? Absolutely. Nonetheless, for a number of reasons using REST API from containers are not the best option. From platform&amp;#8217;s perspective, it is the platform that should define how to access object storage, instead of leaving it with an application-layer protocol. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When a pattern (for storage, or networking, etc) turns out very common, the platform layer should incorporate it as an infrastructure service, manage it with its own standard, and provide it to application so that developer can focus on business features. With that vision, the community brought up the &lt;a href="https://github.com/kubernetes-sigs/container-object-storage-interface"&gt;Container Object Storage Interface&lt;/a&gt; (COSI) initiative. It is currently in very early stage, but the idea is to commoditize object storage in Kubernetes platform with a unified interface. For more background about this initiative, refer to the post &amp;#8220;&lt;a href="https://thenewstack.io/beyond-block-and-file-cosi-enables-object-storage-in-kubernetes/"&gt;Beyond block and file &amp;#8211; COSI enables object storage in Kubernetes&lt;/a&gt;&amp;#8220;.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;COSI is the ultimate cloud native solution but it is still in pre-alpha phase as of mid 2022. Unfortunately, it is not a recommended solution to any real-life project in 2022, and we are stuck with the unified API approach until COSI matures.. The unified API approach is by no means cloud native, but has come to maturity for adoption. S3 Rest API is our friend, regardless of whether the client process is in a container or not.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Update: on Sept 2, 2022, Kubernetes &lt;a href="https://kubernetes.io/blog/2022/09/02/cosi-kubernetes-object-storage-management/"&gt;introduced COSI&lt;/a&gt; as alpha feature.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;MinIO Introduction&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In order to use S3 protocol without using Amazon S3 storage, we can use MinIO to build our own object storage service serve client via a S3-compatible REST API interface. The main developer of the &lt;a href="https://min.io/"&gt;MinIO&lt;/a&gt; project is MinIO Inc, a startup from 2014. Having learned the lessons from GlusterFS, the founders and developers make MinIO very simple. MinIO operates in two modes: gateway mode (soon to be legacy) and server mode.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In the Gateway mode, MinIO as a gateway between client and destination storage, and does not persist data to itself. In the past, the destination storage can be Azure Blob and Google Cloud Storage (GCS) and HDFS as backend. However, these supports are &lt;a href="https://github.com/minio/minio/pull/14418"&gt;deprecated&lt;/a&gt; now. The current release (July 2022) only supports S3 and NAS backend. According to MinIO&amp;#8217;s blog &lt;a href="https://blog.min.io/deprecation-of-the-minio-gateway/"&gt;post&lt;/a&gt; from February 2022, the entire MinIO Gateway feature will be removed in August, leaving server mode the only option for MinIO.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In the Server mode, the MinIO service will persist data to itself in a file system (or volume). You can specify that file system (or volume) as you launch the server. As one of the &lt;a href="https://docs.min.io/docs/minio-quickstart-guide.html"&gt;quick-start guides&lt;/a&gt; shows, we can host MinIO server using a single executable. For administrative tasks, MinIO has a web console and a client utility called mc.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;MinIO Deployment Options&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For storage service, there are a number of &lt;a href="https://docs.min.io/minio/baremetal/installation/deployment-and-management.html"&gt;deployment options&lt;/a&gt;: &lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;SNSD (single-node, single-drive): single MinIO server with a single storage volume or folder. &lt;/li&gt;&#10;&lt;li&gt;SNMD (signle-node, multi-drive): single MinIO server with four or more storage volumes.&lt;/li&gt;&#10;&lt;li&gt;MNMD (multi-node, multi-drive, aka distributed): multiple MinIO servers with at least four drives across all servers. This should be considered for production grade configuration.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The deployment options above describes the node and volume topology. No matter which topology option, there are also a number of ways to host the MinIO service process: on &lt;a href="https://min.io/docs/minio/linux/index.html"&gt;Linux OS&lt;/a&gt;, &lt;a href="https://min.io/docs/minio/windows/index.html"&gt;Windows OS&lt;/a&gt;, &lt;a href="https://min.io/docs/minio/macos/index.html"&gt;MacOS&lt;/a&gt;, &lt;a href="https://min.io/docs/minio/container/index.html"&gt;Docker Container&lt;/a&gt;, and on &lt;a href="https://min.io/docs/minio/kubernetes/upstream/index.html"&gt;Kubernetes&lt;/a&gt; platform. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In addition, MinIO Inc ships the software under different business models. For example, there are fully managed applications in &lt;a href="https://web.archive.org/web/20220927211802/https://azuremarketplace.microsoft.com/en-us/marketplace/apps/minio.minio-object-storage_v1dot1"&gt;Azure Marketplace&lt;/a&gt;, &lt;a href="https://aws.amazon.com/marketplace/pp/prodview-smchi7bcs4nn4"&gt;AWS Marketplace&lt;/a&gt;, and &lt;a href="https://console.cloud.google.com/marketplace/product/minio-inc-public/minio-enterprise"&gt;GCP Marketplace&lt;/a&gt; all hosted on virtual machines with extra charges. Clients not willing to pay can host MinIO storage all on their own, either on virtual machines, or on managed Kubernetes environment provided by each cloud provider. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;MinIO Hosting solutions&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;MinIO lists these hosting solutions under multi-cloud products. These hosting solutions (or &amp;#8220;products&amp;#8221; in MinIO&amp;#8217;s term) vary in terms of where peripheral services and data tiers are hosted. Here is the list of the supported platforms:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/kubernetes"&gt;(generic) Kubernetes&lt;/a&gt;;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/private-cloud-vmware-tanzu"&gt;VMWare Tanzu&lt;/a&gt;;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/private-cloud-red-hat-openshift"&gt;OpenShift&lt;/a&gt;;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/multicloud-suse-rancher"&gt;SUSE Rancher&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/multicloud-elastic-kubernetes-service"&gt;EKS&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/multicloud-azure-kubernetes-service"&gt;AKS&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://min.io/product/multicloud-google-kubernetes-service"&gt;GKE&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To illustrate how these solutions are different, I put some details on a few options together for an incomplete comparison below:&lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-regular"&gt;&lt;table class="has-very-light-gray-to-cyan-bluish-gray-gradient-background has-background"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Kubernetes&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;EKS&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;AKS&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;GKE&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Hot Storage&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Direct PV (NVMe)&lt;/td&gt;&lt;td&gt;EKS EBS CSI&lt;/td&gt;&lt;td&gt;Azure CSI &lt;/td&gt;&lt;td&gt;GKE Standard SSD&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Warm Storage&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Direct PV (HDD)&lt;/td&gt;&lt;td&gt;S3 IA&lt;/td&gt;&lt;td&gt;Azure BlobStore&lt;/td&gt;&lt;td&gt;GCS&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Cold Storage&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Public Cloud storage&lt;/td&gt;&lt;td&gt;Glacier&lt;/td&gt;&lt;td&gt;Azure Cool Blob&lt;/td&gt;&lt;td&gt;GCS for Data Archiving&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Encryption&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;HashiCorp Vault&lt;/td&gt;&lt;td&gt;KMS&lt;/td&gt;&lt;td&gt;Azure Key Vault&lt;/td&gt;&lt;td&gt;Cloud Key Management&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Observability&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Elastic Stack and Grafana&lt;/td&gt;&lt;td&gt;Managed ElasticSearch Prometheus&lt;/td&gt;&lt;td&gt;Azure Monitor&lt;/td&gt;&lt;td&gt;Stack Driver&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Identity Provider&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;KeyCloak&lt;/td&gt;&lt;td&gt;LDAP, SSO&lt;/td&gt;&lt;td&gt;Azure Active Directory&lt;/td&gt;&lt;td&gt;GCP Cloud Identity&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;LB and Cert Mgmt&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Nginx, Let&amp;#8217;s Entrypt&lt;/td&gt;&lt;td&gt;AWS Cert Mgr, ELB&lt;/td&gt;&lt;td&gt;Azure Load Balancer, JetStack, Let&amp;#8217;s Encrypt&lt;/td&gt;&lt;td&gt;GCP Cloud LB and Managed Cert&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Note that all of these hosting solutions are based on some flavour of Kubernetes. The hot tier is usually based on storage options available to the platform. MinIO service access this hot tier via Kubernetes persistent volume. The warm and cold tiers are backed by different object storage service. Between MinIO and storage client, it always use the same S3 compatible Rest API.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;MinIO also has tiering capability. While the hot storage destination has to be either a file system or Kubernetes persistent volume, remote tiers can be S3 , Azure Blob, or GCS. MinIO supports encryption at rest (SSE-KMS, SSE-S3, SSE-C) and in transit (TLS) for security, as well as many other useful features such as object &lt;a href="https://docs.min.io/minio/baremetal/replication/replication-overview.html"&gt;replication&lt;/a&gt;, &lt;a href="https://docs.min.io/minio/baremetal/object-retention/bucket-versioning.html"&gt;versioning&lt;/a&gt;, &lt;a href="https://docs.min.io/minio/baremetal/object-retention/minio-object-locking.html"&gt;locking&lt;/a&gt;, &lt;a href="https://docs.min.io/minio/baremetal/monitoring/bucket-notifications/bucket-notifications.html"&gt;events&lt;/a&gt;, Prometheus &lt;a href="https://docs.min.io/minio/baremetal/monitoring/metrics-alerts/minio-metrics-and-alerts.html"&gt;metrics&lt;/a&gt;, &lt;a href="https://docs.min.io/minio/baremetal/lifecycle-management/lifecycle-management-overview.html"&gt;lifecycle management&lt;/a&gt; etc. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Connect to MinIO server with S3 client&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To validate that the client is compatible, we use MinIO&amp;#8217;s client utility (mc) to connect to an AWS S3 bucket. Then we use AWS CLI to connect to a MinIO server, similar to this &lt;a href="https://docs.min.io/docs/aws-cli-with-minio"&gt;instruction&lt;/a&gt;. To do so, we first install client and server utilities:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;brew install minio/stable/minio&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;brew install minio/stable/mc&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;minio --version&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc --version&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;Then, we start MinIO server and store an object using AWS CLI&amp;#8217;s S3 tool. In our working directory, we create a new directory called minio_data and launch MinIO server with it:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir minio_data&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;minio server minio_data --console-address :9090&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;Once the server is up, the screen should display the details, including the portal URL and the default username and password will be used as Access Key ID and Secret Key:&lt;/p&gt;&#10;&lt;figure class="wp-block-image size-large"&gt;&lt;img loading="lazy" decoding="async" width="1307" height="649" src="https://www.digihunch.com/wp-content/uploads/2022/07/image-2.png" alt="" class="wp-image-6276"/&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Note that the MinIO service does NOT have &lt;a href="https://docs.min.io/docs/how-to-secure-access-to-minio-server-with-tls.html"&gt;TLS enabled&lt;/a&gt; by default, on the console or API service. At this point, we can browse to the console web page using the given credential. Then, we can configure AWS CLI with a new profile just to act as a client to communicate with the MinIO server:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ aws configure --profile minio-cli&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;AWS Access Key ID &lt;span style="color:#f92672"&gt;[&lt;/span&gt;None&lt;span style="color:#f92672"&gt;]&lt;/span&gt;: minioadmin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;AWS Secret Access Key &lt;span style="color:#f92672"&gt;[&lt;/span&gt;None&lt;span style="color:#f92672"&gt;]&lt;/span&gt;: minioadmin&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default region name &lt;span style="color:#f92672"&gt;[&lt;/span&gt;None&lt;span style="color:#f92672"&gt;]&lt;/span&gt;: us-east-1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Default output format &lt;span style="color:#f92672"&gt;[&lt;/span&gt;None&lt;span style="color:#f92672"&gt;]&lt;/span&gt;: json&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ aws configure set default.s3.signature_version s3v4 --profile minio-cli&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;At this point, the AWS CLI is configured to communicate with MinIO server. Then, we can create bucket, list object in the bucket, copy an object to the bucket, etc&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ aws --endpoint-url http://127.0.0.1:9000 s3 ls --profile minio-cli &lt;span style="color:#75715e"&gt;# list all bucket, should return empty&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ aws --endpoint-url http://127.0.0.1:9000 s3 mb s3://hehebucket --profile minio-cli &lt;span style="color:#75715e"&gt;# create new bucket&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;make_bucket: hehebucket&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ aws --endpoint-url http://127.0.0.1:9000 s3 cp README.md s3://hehebucket --profile minio-cli &lt;span style="color:#75715e"&gt;# copy a file to bucket as a new object&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;upload: ./README.md to s3://hehebucket/README.md&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ aws --endpoint-url http://127.0.0.1:9000 s3 ls s3://hehebucket --profile minio-cli &lt;span style="color:#75715e"&gt;# list objects in the bucket&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;2022-07-09 00:30:23 &lt;span style="color:#ae81ff"&gt;631&lt;/span&gt; README.md&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;The created bucket and object are also visible in MinIO web console, under &amp;#8220;Bucket&amp;#8221;:&lt;/p&gt;&#10;&lt;figure class="wp-block-image size-full"&gt;&lt;img loading="lazy" decoding="async" width="947" height="235" src="https://www.digihunch.com/wp-content/uploads/2022/07/image-3.png" alt="" class="wp-image-6287"/&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The steps above validate that AWS CLI can talk to MinIO server. Because of that, MinIO server can emulate an S3 service in any development environment so users do not always have to use S3 from AWS. This makes sense for both cost and security reasons for the organization. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Connect to S3 with MinIO client&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In this lab, we create an S3 bucket and use mc utility to store an object to it. In order to consistently create S3 bucket and associated permissions, I use the CloudFormation template in &lt;a href="https://github.com/digihunch/cloudformation/blob/master/obj-store-helper/aws-s3-stack.yaml"&gt;this&lt;/a&gt; repo. The output of the CloudFormation stack returns the Access Key ID and Secret Key required for the client to access the bucket. Once we cloned the repo, let&amp;#8217;s enter the &lt;a href="https://github.com/digihunch/cloudformation/tree/master/obj-store-helper"&gt;obj-store-helper&lt;/a&gt; directory, and run aws cli command to launch the CloudFormation template, assuming it has been configured:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;BUCKET_NAME&lt;span style="color:#f92672"&gt;=&lt;/span&gt;c0sas2dsadigihunch&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;S3_STACK_NAME&lt;span style="color:#f92672"&gt;=&lt;/span&gt;$BUCKET_NAME-stack&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;aws cloudformation create-stack --template-body file://aws-s3-stack.yaml --stack-name $S3_STACK_NAME --parameters ParameterKey&lt;span style="color:#f92672"&gt;=&lt;/span&gt;S3BucketName,ParameterValue&lt;span style="color:#f92672"&gt;=&lt;/span&gt;$BUCKET_NAME --capabilities CAPABILITY_IAM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# to delete stack after test, run: aws cloudformation delete-stack --stack-name $S3_STACK_NAME&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;In the AWS console, we should see the configuration information as below:&lt;/p&gt;&#10;&lt;figure class="wp-block-image size-full"&gt;&lt;img loading="lazy" decoding="async" width="925" height="708" src="https://www.digihunch.com/wp-content/uploads/2022/07/image-1.png" alt="" class="wp-image-6266"/&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Supposed the bucket name is vna-tst-c0sas2dsadigihunch as shown above, this allows us to configure the client utility MC as below:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc alias set awss3 https://s3.amazonaws.com &lt;span style="color:#75715e"&gt;# Fill in access key ID and Secret key at the prompt&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc ls awss3/vna-tst-c0sas2dsadigihunch &lt;span style="color:#75715e"&gt;# list objects in the bucket, should return empty&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc cp README.md awss3/vna-tst-c0sas2dsadigihunch/README.md &lt;span style="color:#75715e"&gt;# upload and object to bucket&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc ls awss3/vna-tst-c0sas2dsadigihunch &lt;span style="color:#75715e"&gt;# list objects in the bucket, the uploaded object should be there&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc rm awss3/vna-tst-c0sas2dsadigihunch/README.md &lt;span style="color:#75715e"&gt;# delete the object&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mc alias remove awss3 &lt;span style="color:#75715e"&gt;# remove awss3 alias&lt;/span&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="wp-block-paragraph"&gt;Once we emptied the bucket, we can delete the CloudFormation stack. This test only needs client utility mc to verify that MinIO client is able to talk to AWS S3 server.&lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Erasure Coding&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;For scalable production use, we should deploy MinIO in distributed mode. When MinIO is configured in &lt;a href="https://docs.min.io/minio/baremetal/installation/deploy-minio-distributed.html"&gt;distributed deployment&lt;/a&gt; (MNMD, or multi-node, multi-drive), it implicitly enables an important feature called &lt;a href="https://docs.min.io/minio/baremetal/concepts/erasure-coding.html#minio-erasure-coding"&gt;erasure coding&lt;/a&gt;. This erasure coding feature further unlocks a number of other MinIO features:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;a href="https://docs.min.io/minio/baremetal/object-retention/bucket-versioning.html#minio-bucket-versioning"&gt;Object Versioning&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://docs.min.io/minio/baremetal/replication/bucket-replication-overview.html#minio-bucket-replication-serverside"&gt;Server-Side Replication&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://docs.min.io/minio/baremetal/reference/minio-mc/mc-retention-set.html#minio-bucket-locking"&gt;Write-Once Read-Many (WORM) Locking&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Erasure coding is MinIO&amp;#8217;s data redundancy and availability feature that allows MinIO deployments to automatically reconstruct objects on-the-fly despite the loss of multiple drives or nodes in the cluster. Erasure coding provides object-level handling with less overhead than adjacent technologies such as RAID. The key concept is &lt;a href="https://docs.min.io/minio/baremetal/concepts/erasure-coding.html#erasure-sets"&gt;Erasure Set&lt;/a&gt;, a set of drives in a MinIO deployment that supports Erasure Coding. MinIO evenly distributes object data and parity blocks among the drives in the Erasure Set. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Two important variables are M and N: for a given erasure set of size M, MinIO splits objects into N parity blocks, and M-N data blocks. MinIO uses the &lt;a href="https://docs.min.io/minio/baremetal/concepts/erasure-coding.html#erasure-code-parity-ec-n"&gt;EC:N&lt;/a&gt; notation to refer to the number of parity blocks (N) in the deployment. To determine optimal erasure set size for the cluster, use MinIO&amp;#8217;s &lt;a href="https://min.io/product/erasure-code-calculator"&gt;Erasure Coding Calculator&lt;/a&gt; tool.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;To help client to specify per-object parity with Erasure Coding, MinIO uses storage classes. Note that the storage class concept in MinIO is distinct from AWS &lt;a href="https://aws.amazon.com/s3/storage-classes/"&gt;S3 storage class&lt;/a&gt; or Kubernetes &lt;a href="https://kubernetes.io/docs/concepts/storage/storage-classes/"&gt;storage class&lt;/a&gt;. In MinIO, a &lt;a href="https://github.com/minio/minio/tree/master/docs/erasure/storage-class"&gt;storage class&lt;/a&gt; defines parity settings per object. The STANDARD &lt;a href="https://docs.min.io/minio/baremetal/concepts/erasure-coding.html#storage-classes"&gt;storage class&lt;/a&gt; (default) defines EC:N based on M, which can be overridden. In addition, there is REDUCED_REDUNDANCY storage class, whose parity must be less than or equal to that of STANDARD storage class. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The &lt;a href="https://docs.min.io/minio/baremetal/concepts/erasure-coding.html#bitrot-protection"&gt;erasure coded backend&lt;/a&gt; also protects the storage against &lt;a href="https://github.com/minio/minio/blob/master/docs/erasure/README.md#what-is-bit-rot-protection"&gt;Bit Rot&lt;/a&gt; with HighwayHash algorithm. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;More Features&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Authentication and authorization between MinIO client and MinIO server have a number of options. MinIO client may use the built-in standalone identity management in MinIO server. This is the default mode. In addition, one may delegate IAM to external service. To Active Directory via LDAP, or any Identity provider that supports OIDC (JWT with Authorization Code Flow). &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;As to &lt;a href="https://docs.min.io/minio/baremetal/lifecycle-management/lifecycle-management-overview.html"&gt;Object Lifecycle Management&lt;/a&gt; (OLM), MinIO allows you to define a remote tier storage for each local target (bucket). The remote tier can be Amazon S3, Google Cloud Storage or Azure Blob storage. We can use mc utility to administer the remote tier and OLM. Configuration steps (e.g. &lt;a href="https://docs.min.io/minio/baremetal/lifecycle-management/transition-objects-to-azure.html"&gt;Azure&lt;/a&gt; Blob, &lt;a href="https://docs.min.io/minio/baremetal/lifecycle-management/transition-objects-to-s3.html"&gt;AWS S3&lt;/a&gt;) usually include:&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&#10;&lt;li&gt;Configure required permissions on the MinIO bucket, create user account for OLM activities. &lt;/li&gt;&#10;&lt;li&gt;Configure the Remote Storage Tier&lt;/li&gt;&#10;&lt;li&gt;Create and Apply an ILM Transition Rule. The rule can be expressed in a json document.&lt;/li&gt;&#10;&lt;li&gt;Validate the creation of ILM transition rule&lt;/li&gt;&#10;&lt;li&gt;Validate the effect of transition rule. &lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p class="wp-block-paragraph"&gt;As for encryption, MinIO can support encryption at rest. It can also work with &lt;a href="https://www.digihunch.com/2022/06/etcd-the-key-value-store-for-kubernetes/"&gt;etcd&lt;/a&gt; store to store encrypted IAM assets if KMS is configured. &lt;/p&gt;&#10;&lt;h2 class="wp-block-heading"&gt;Conclusion&lt;/h2&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Even though we watch for the progress of COSI initiative, we still use Rest API to access object storage from container, which is no different than from a virtual machine. If we develop an application, then we should make it support S3 protocol, a de-facto standard protocol for object storage. As for the storage backend, if we want to be vendor neutral, the feature-rich MinIO is the best bet. We can use MinIO to build our own Object storage as a service compatible with S3. We can also lifecycle our object to remote object storage tier backed by Azure, GCP or S3. In this post we validated the S3 compatibility, and discussed some advanced MinIO features.&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2022/08/storage-solution-on-aks-2-of-3-ceph-by-rook/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Kubernetes Storage on Azure 3 of 3 – Ceph by Rook&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2022/09/build-a-kubernetes-cluster/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Build and Manage Kubernetes Clusters&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>Cloud storage overview</title><link>https://www.digihunch.com/2020/08/cloud-storage-overview/</link><pubDate>Wed, 12 Aug 2020 22:19:00 -0400</pubDate><guid>https://www.digihunch.com/2020/08/cloud-storage-overview/</guid><description>&lt;p class="wp-block-paragraph"&gt;In a narrow sense, cloud storage refers to object storage. In a broader sense, it refers to any storage service (block, file or object level) provided by cloud vendors, in a cloud business model. The underlying technology of storage, is the same be it in the cloud or on-premise. &lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-stripes"&gt;&lt;table class="has-background" style="background-color:#e9fbe5"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Block storage&lt;/td&gt;&lt;td&gt;File storage&lt;/td&gt;&lt;td&gt;Object&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Interaction with OS&lt;/td&gt;&lt;td&gt;OS has direct byte-level access to disk blocks.&lt;/td&gt;&lt;td&gt;OS manages storage by file, or byte range of file. Files are organized in POSIX hierarchy.&lt;/td&gt;&lt;td&gt;OS reads and writes the entire object, or a byte range, via rest API calls.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Metadata&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;Stored in file system, for directory or file&lt;/td&gt;&lt;td&gt;customizable metadata&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Common protocol&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;NFS&lt;/td&gt;&lt;td&gt;S3&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Implementation&lt;/td&gt;&lt;td&gt;SAN (bock device is typically dedicated to a single VM) or DAS&lt;/td&gt;&lt;td&gt;NAS, file storage is usually shared amongst multiple VMs. Locking mechanism is usually in place to keep access in order.&lt;/td&gt;&lt;td&gt;S3&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Workload&lt;/td&gt;&lt;td&gt;database storage, scratch data, etc&lt;/td&gt;&lt;td&gt;persistent data, content management, etc&lt;/td&gt;&lt;td&gt;archive data, media streaming, data analytics, static asset serving, etc&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Below is a list of common storage services provided by public cloud vendors to day.&lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-stripes"&gt;&lt;table class="has-background" style="background-color:#e9fbe5"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Block Storage&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;File Storage&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Object Storage&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Other managed storage service&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;a href="https://aws.amazon.com/products/storage/"&gt;&lt;span class="has-inline-color has-black-color"&gt;AWS&lt;/span&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://aws.amazon.com/ebs"&gt;&lt;span class="has-inline-color has-black-color"&gt;Elastic Block Store (EBS)&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://aws.amazon.com/efs/"&gt;&lt;span class="has-inline-color has-black-color"&gt;Elastic File System (EFS)&lt;/span&gt;&lt;/a&gt;&lt;span class="has-inline-color has-black-color"&gt;&lt;br&gt;&lt;/span&gt;&lt;a href="https://aws.amazon.com/fsx/windows/"&gt;&lt;span class="has-inline-color has-black-color"&gt;FSx for Windows&lt;/span&gt;&lt;/a&gt;&lt;br&gt;FSx for Lustre&lt;/td&gt;&lt;td&gt;&lt;a href="https://aws.amazon.com/s3/"&gt;&lt;span class="has-inline-color has-black-color"&gt;Simple Storage Service (S3)&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://aws.amazon.com/storagegateway"&gt;&lt;span class="has-inline-color has-black-color"&gt;Storage Gateway&lt;/span&gt;&lt;/a&gt; &lt;br&gt;Snow Family&lt;br&gt;DataSync&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/storage/common/storage-introduction"&gt;&lt;span class="has-inline-color has-black-color"&gt;Azure&lt;/span&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/managed-disks-overview"&gt;&lt;span class="has-inline-color has-black-color"&gt;Azure Managed Disks&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/storage/files/storage-files-introduction"&gt;&lt;span class="has-inline-color has-black-color"&gt;Azure Files&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction"&gt;&lt;span class="has-inline-color has-black-color"&gt;Azure Blobs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/storage/tables/table-storage-overview"&gt;&lt;span class="has-inline-color has-black-color"&gt;Azure Table&lt;/span&gt;&lt;/a&gt;&lt;span class="has-inline-color has-black-color"&gt; &lt;br&gt;&lt;/span&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/storage/queues/storage-queues-introduction"&gt;&lt;span class="has-inline-color has-black-color"&gt;Azure Queues&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;a href="https://cloud.google.com/products/storage"&gt;&lt;span class="has-inline-color has-black-color"&gt;GCP&lt;/span&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://cloud.google.com/persistent-disk"&gt;&lt;span class="has-inline-color has-black-color"&gt;Persistent Disk&lt;/span&gt;&lt;/a&gt;&lt;span class="has-inline-color has-black-color"&gt;&lt;br&gt;&lt;/span&gt;&lt;a href="https://cloud.google.com/local-ssd"&gt;&lt;span class="has-inline-color has-black-color"&gt;local SSD&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://cloud.google.com/filestore"&gt;&lt;span class="has-inline-color has-black-color"&gt;Filestore&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://cloud.google.com/storage"&gt;&lt;span class="has-inline-color has-black-color"&gt;Cloud Storage&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://firebase.google.com/products/storage/"&gt;&lt;span class="has-inline-color has-black-color"&gt;Cloud Storage for Firebase&lt;/span&gt;&lt;/a&gt;&lt;br&gt;Data Transfer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;&lt;a href="https://www.digitalocean.com/products/"&gt;&lt;span class="has-inline-color has-black-color"&gt;Digital Ocean&lt;/span&gt;&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="https://www.digitalocean.com/products/block-storage/"&gt;&lt;span class="has-inline-color has-black-color"&gt;Volumes Block storage&lt;/span&gt;&lt;/a&gt;&lt;br&gt;local SSD&lt;/td&gt;&lt;td&gt;N/A&lt;/td&gt;&lt;td&gt;&lt;a href="https://www.digitalocean.com/products/spaces/"&gt;&lt;span class="has-inline-color has-black-color"&gt;Space object storage&lt;/span&gt;&lt;/a&gt; (S3 compatible)&lt;/td&gt;&lt;td&gt;Content Delivery Network&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;figcaption class="wp-element-caption"&gt;Storage Products from common public cloud vendor&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Since AWS is the first vendor that provides a full suite of storage service, this post will focus on the storage product lines, as a refresher of AWS cloud storage options: Simple Storage Service, Elastic File Storage and Elastic Block Storage). There will be some overlap with the AWS storage service &lt;a href="https://d0.awsstatic.com/whitepapers/AWS%20Storage%20Services%20Whitepaper-v9.pdf"&gt;whitepaper&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Before getting further to details, here&amp;#8217;s a reminder of two types of policies in AWS:&lt;/p&gt;&#10;&lt;figure class="wp-block-table is-style-stripes"&gt;&lt;table class="has-background" style="background-color:#e9fbe5"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;IAM policy&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&lt;strong&gt;Resource-based policy&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Principal&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Must be attached to individual user, group, or role to take effect&lt;/td&gt;&lt;td&gt;Needs to be explicitly specified, can be ARN under other AWS account&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Element&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Action/NotAction&lt;br&gt;Resource/NotResource&lt;br&gt;Effect (Allow/Deny)&lt;br&gt;Condition&lt;/td&gt;&lt;td&gt;Principal/NotPrincipal&lt;br&gt;Action/NotAction&lt;br&gt;Resource/NotResource&lt;br&gt;Effect (Allow/Deny)&lt;br&gt;Condition&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;Managed policy, custom policy&lt;/td&gt;&lt;td&gt;File system policy, S3 bucket policy, access point policy, etc&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;figcaption class="wp-element-caption"&gt;Two types of policies&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Although the resource is usually assumed in a resource-based policy, the policy usually target a sub-section of a resource (e.g. object with certain prefix), so resource section is still required in resource-based policy. In storage services, we may use S3 bucket policy, access point policy, or file system policy for EFS.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Below we go over the three families of storage service in AWS.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-ebs-elastic-block-storage"&gt;EBS (Elastic Block Storage)&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;EBS is a distributed system. Each volume is a logical volume, made up of multiple physical devices. EBS data is persistent, and access is dedicated to a single EC2 instance at a time. If EC2 instance failed, the attached EBS volume can be detached, and then re-attached to other instance, in the same Availability Zone. There are two types of EBS:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;EC2 Instance store: ephemeral, block-level storage for EC2 instance, no replication by default, no snapshot support. Used as buffers, caches, scratch data, temporary content.&lt;/li&gt;&#10;&lt;li&gt;EBS volume (persistent) : used for database, dev/test, enterprise application, etc. There are two sub-categories:&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;SSD-backed volumes:&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Optimized for transnational workloads that requires very low latency&lt;/li&gt;&#10;&lt;li&gt;Dominant performance attribute is IOPS&lt;/li&gt;&#10;&lt;li&gt;For frequent, read/write with small size and &lt;a href="https://www.digihunch.com/2019/04/application-i-o-characteristics/"&gt;random&lt;/a&gt; I/O&lt;/li&gt;&#10;&lt;li&gt;Typical use case include relational database (PostgresQL, MySQL) and NoSQL (Cassandra, Mongo)&lt;/li&gt;&#10;&lt;li&gt;gp2 (general purpose) and io1 (provisioned IOPS)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;HDD-backed volumes:&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Optimized for large streaming workloads demanding throughput&lt;/li&gt;&#10;&lt;li&gt;Dominant performance attribute is &lt;span style="text-decoration: underline;"&gt;throughput&lt;/span&gt;&lt;/li&gt;&#10;&lt;li&gt;For workloads with lots of &lt;a href="https://www.digihunch.com/2019/04/application-i-o-characteristics/"&gt;sequential&lt;/a&gt; I/O&lt;/li&gt;&#10;&lt;li&gt;Typical use case icnlude big data, analytics (Kafka, Splunk, Hadoop, data warehousing), file/media server&lt;/li&gt;&#10;&lt;li&gt;st1 (throughput optimized0 and sc1 (cold HDD)&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The four types of EBS are compared here:&lt;/p&gt;&#10;&lt;figure class="wp-block-image size-large"&gt;&lt;img loading="lazy" decoding="async" width="865" height="770" src="https://www.digihunch.com/wp-content/uploads/2020/08/image-10.png" alt="" class="wp-image-1307"/&gt;&lt;/figure&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Note that the volume can be modified (change type, increase size) after creation. However, you cannot decrease size. If you increase the size, the file system must be extended after the increase.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Another way to deliver better performance is to use &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-optimized.html"&gt;EBS-optimized instances&lt;/a&gt;. These instances have dedicated network bandwidth for its I/O traffic to and from EBS. Without EBS-optimized instance, the traffic between EBS volume and EC2 instance uses shared network link with EC2, which is subject to latency during heavy traffic. This distinction is similiar to the difference between iSCSI SAN and FC SAN. Also, you may increase read-ahead buffer in OS for better EBS performance.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;On EBS, users can create snapshot, a point-in-time incremental backup. When snapshot is restored to a volume, data is loaded lazily in the background, so that volume is available immediately. This also means that initial read of data that is not yet loaded will be subject to latency, known as first read penalty. To achieve target performance, user may run an initialization on the volume, by reading all blocks with data upfront.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In a newly created snapshot, only the data blocks modified since the previous snapshot are stored as is. The rest are pointers to unchanged data blocks in the original snapshot. When a previous snapshot is deleted, AWS ensures changes are reconciled into the newer snapshot so there is no loss of data. Creation of snapshots on many volumes can be automated with Data Lifecycle Manager (DLM).&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;As far as encryption goes, the best practice is to create your own master key. KMS uses envelop encryption, where the data key encrypts the data, and the master key encrypts the data key. The encryption key is stored in EC2 instance memory only and never written to disk, for security and performance considerations.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-efs-elastic-file-storage"&gt;EFS (Elastic File Storage)&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;EFS is a managed implementation of file storage that supports NFS 4.0 and 4.1, with strong data consistency and file locking. An EFS includes a single mount target in (one subnet of) each availability zone. EC2 instance, or on-premise client via Direct Connect, can mount EFS volumes using amazon-efs-utils yum package. EC2 instance can also be configured to automatic mount EFS volume in launch wizard. EFS also has a lifecycle management policy, and a storage class for infrequent access.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://docs.aws.amazon.com/efs/latest/ug/performance.html"&gt;Performance &lt;/a&gt;wise, EFS has two performance modes and two throughput modes. The two performance modes are:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;strong&gt;General Purpose&lt;/strong&gt;: for latency-sensitive applications and general-purpose workloads. limit of 7k ops/sec, best choice for most workloads&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Max I/O&lt;/strong&gt;: for large-scale and data-heavy applications, with virtually unlimited ability to scale out throughput/IOPS, but with slightly higher latencies. consider this for large scale-out workloads&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The two throughput modes are:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;strong&gt;Bursting throughput&lt;/strong&gt;: recommended for the majority of workload. Since file system workload is typically spiky, aws use credit system to determine when the file system throughput can burst. credit accumates idle time, and consumed in retrieval&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;Provisioned throughput&lt;/strong&gt;: recommended for higher throughput to storage ratio workload, can increase the provisioned throughput afterwards. but it incurs separate throughput charge&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Other ways to achieve higher performance, include parallelization of file operation (e.g. multiple threads, more instances); and increase I/O size for better throughput.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In terms of security, EFS encryption at rest must be selected at the time of file system creation. There is an TLS mount option to encrypt traffic in transit. EFS involves its own resource-based policy called file system policy to manage file-level POSIX permissions. IAM policy is used to manage NFS administration access and client access. EFS &lt;a href="https://docs.aws.amazon.com/efs/latest/ug/efs-access-points.html"&gt;access points&lt;/a&gt; is also a means to enforce the use of a specific operating system user, and group to access EFS.&lt;/p&gt;&#10;&lt;h3 class="wp-block-heading" id="h-s3-simple-storage-service"&gt;S3 (Simple Storage Service)&lt;/h3&gt;&#10;&lt;p class="wp-block-paragraph"&gt;S3 is one of the earliest and maturest AWS services for object storage. It is very cheap and easy to use, and supports user-defined metadata on objects as well as many peripheral features. There is no limit to the number of objects in a bucket. As the object in bucket increases, S3 scales to request rate by automatically creating more partitions to meet the target number of request per partition. There used to be a performance trick, that requires client to make object key naming pattern distribute across multiple prefixes. It is &lt;a href="https://aws.amazon.com/about-aws/whats-new/2018/07/amazon-s3-announces-increased-request-rate-performance/"&gt;not required&lt;/a&gt; any more as of July 2018.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Versioning can be enabled at bucket level, and suspended afterwards. New version of object is created on every upload, without performance penalty. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;S3 integrate well with other event-driven AWS services, such as SNS, SQS, Lambda, etc. Event can fire on request such as PUT, POST, COPY. &lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Object &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/object-tagging.html"&gt;tags &lt;/a&gt;(not to be confused with object metadata) can help categorize storage. It also facilitates access control (i.e. by being referenced in bucket policy or IAM policy), lifecycle policy, analysis and CloudWatch configurations.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://aws.amazon.com/s3/features/#s3-select"&gt;S3 select&lt;/a&gt; is a way to retrieve only a subset of data from an object based on a SQL expression, to reduce amount of data and help with performance. The &lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/API/API_SelectObjectContent.html"&gt;input &lt;/a&gt;can be json or CSV and output will be in CSV.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-inventory.html"&gt;S3 Inventory&lt;/a&gt; is a tool to audit object replication status and encryption status. It generates CSV report with all objects in the given bucket name, including: key name, version id, islatest, size, last modified date, etag, storage class, multipart upload flag, delete marker, replication status, encryption status. For storage-class analysis, S3 inventory is much faster than list-object API call which parses through all objects.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;S3 also has &lt;a href="https://aws.amazon.com/s3/features/access-points/"&gt;access point&lt;/a&gt;, similar to EFS, with unique hostnames that customers create to enforce distinct permissions and network controls for any request made through the access point.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;S3 &lt;a href="https://aws.amazon.com/s3/transfer-acceleration/"&gt;transfer acceleration&lt;/a&gt; take advantage of edge locations (at additional charge) to speed up transfer of large object over long distance, by providing a separate end point. It is also helpful for faster uploads over long distances. Apart from transfer acceleration, for faster uploads for large object, user may also consider multi-part upload API when the object reaches 100MB. Orphaned uploaded parts can be cleaned up in lifecycle configuration. For better download performance, take advantage of CloudFront and byte range request.&lt;/p&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2020/08/java-garbage-collection/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Java Garbage Collection&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2020/08/virtualization-3-of-3-containers/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Virtualization 3 of 4 – Containers&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item><item><title>Storage Nitty-Gritty 3 of 5 – NAS and Object Storage</title><link>https://www.digihunch.com/2019/07/storage-nitty-gritty-3-of-5-nas-and-object-storage/</link><pubDate>Sat, 13 Jul 2019 23:31:00 -0400</pubDate><guid>https://www.digihunch.com/2019/07/storage-nitty-gritty-3-of-5-nas-and-object-storage/</guid><description>&lt;h4 class="wp-block-heading" id="h-nas-network-attached-storage"&gt;&lt;strong&gt;NAS (network attached storage)&lt;/strong&gt;&lt;/h4&gt;&#10;&lt;p class="wp-block-paragraph"&gt;NAS server is dedicated to file-serving. NAS device runs its own specialized operating system that is optimized for file I/O, integrated hardware and software component that meets specific file-service needs, and performs file I/O better than a general-purpose server. NAS device can serve more clients than general-purpose servers and provide the benefit of server consolidation (centralized storage).&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;NAS uses network and file-sharing protocols to provide access to the file data. These protocols include TCP/IP for data transfer, and Common Internet File System (CIFS) and Network File System (NFS) for network file service.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Network File Sharing&lt;/strong&gt; &amp;#8211; user who creates a file determines the type of access to be given to other user. When multiple users try to access a shared file at the same time, a locking scheme is required to maintain data integrity and, at the same time, make this sharing possible. Examples of file sharing method (FTP, DFS, NFS, CIFS, P2P)&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Components of NAS&lt;/strong&gt; &amp;#8211; NAS head (CPU, memory, NIC, optimized OS, ports, applications that supports CIFS/NFS) and Storage Array&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-42.png" alt="" class="wp-image-379" width="502" height="279"/&gt;&lt;figcaption class="wp-element-caption"&gt;Typical NAS components&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NAS I/O operation&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&#10;&lt;li&gt;Client packages an I/O request into TCP/IP and forwards it through network stack. NAS head receives this request from network;&lt;/li&gt;&#10;&lt;li&gt;NAS head converts the I/O request into an appropriate physical storage request, which is a block-level I/O, and then performs the operation on the physical storage;&lt;/li&gt;&#10;&lt;li&gt;When NAS head receives data from the storage array, it processes and repackages the data into an appropriate NFS/CIFS response;&lt;/li&gt;&#10;&lt;li&gt;NAS head packages this response into TCP/IP again and forwards it to the client through the network&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large"&gt;&lt;img loading="lazy" decoding="async" width="1128" height="452" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-43.png" alt="" class="wp-image-380"/&gt;&lt;figcaption class="wp-element-caption"&gt;NAS I/O operation&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NAS implementation&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Unified NAS&lt;/strong&gt; &amp;#8211;&amp;nbsp; consolidate NAS-based and SAN-based data access within a unified storage platform and provides a unified management interface for managing both the environments. &lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-44.png" alt="" class="wp-image-381" width="464" height="456"/&gt;&lt;figcaption class="wp-element-caption"&gt;Unified NAS connectivity&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Gateway implementation&lt;/strong&gt; &amp;#8211; similar to unified NAS, the storage is shared with other applications that use block-level I/O. The gateway NAS is more scalable compared to unified NAS because NAS heads and storage arrays can be independently scaled up when required. For example, NAS heads can be added to scale up the NAS device performance.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;When the storage limit is reached, it can scale up, adding capacity on the SAN, independent of NAS heads. Similar to a unified NAS, a gateway NAS also enables high utilization of storage capacity by sharing it with the SAN environment.&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-45.png" alt="" class="wp-image-382" width="547" height="366"/&gt;&lt;figcaption class="wp-element-caption"&gt;Gateway NAS connectivity&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Scale-out NAS&lt;/strong&gt; &amp;#8211; enables grouping multiple nodes together to construct a clustered NAS system. A scaled-out NAS provides the capability to scale its resources by simply adding nodes to a clustered NAS architecture. The cluster works as a single NAS device and is managed centrally. Scaled-out NAS creates a single file system that runs on all nodes in the cluster. All information is shared among nodes, so the entire file system is accessible by clients connecting to any node in the cluster. Scale-out NAS stripes data across all nodes in a cluster along with mirror or parity protection. As data is sent from clients to the cluster, the data is divided and allocated to different nodes in parallel. When a client sends a request to read a file, the scale-out NAS retrieves the appropriate blocks from multiple nodes, recombines the blocks into a file, and presents the file to the client. As nodes are added, the file system grows dynamically and data is evenly distributed to every node. Each node added to the cluster increases the aggregate storage, memory, CPU, and network capacity. Hence, cluster performance also increases.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Scale-out NAS use separate internal and external networks for back-end and front-end connectivity, respectively. The internal network offers high throughput and low-latency and uses high-speed networking technology, such as InfiniBand or Gigabit Ethernet.&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-46.png" alt="" class="wp-image-383" width="475" height="247"/&gt;&lt;figcaption class="wp-element-caption"&gt;Scale-out NAS with dual internal and single external networks&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NFS protocol &lt;/strong&gt;&amp;#8211; originally based on UDP, uses RPC as a method of inter-process communication between two computers. NFS provides a set of RPCS to access remote file system for the following operations:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Searching files and directories&lt;/li&gt;&#10;&lt;li&gt;Opening, reading, writing to and closing a file&lt;/li&gt;&#10;&lt;li&gt;Changing file attributes&lt;/li&gt;&#10;&lt;li&gt;Modifying file links and directories&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NFSv3&lt;/strong&gt; and earlier is stateless protocol. Each call provides a full set of arguments to access files on the server. NFSv3 is most commonly used version, based on UDP or TCP.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NFSv4&lt;/strong&gt; uses TCP and is based on stateful protocol design.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;CIFS&lt;/strong&gt; &amp;#8211; a public, or open variation of SMB protocol. Filenames in CIFS are encoded using unicode characters. It is stateful protocol because the server maintain connection information regarding every connected client. If a network failure or CIFS server failure occurs, the client receives a disconnection notification. If application has embedded intelligence to restore the connection, then the storage solution is fault tolerant. If the embedded intelligence is missing, the user must take steps to reestablish the CIFS connection.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;NAS Performance&lt;/strong&gt; &amp;#8211; network congestion is one of the most significant sources of latency in NAS environment. Other factors&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&#10;&lt;li&gt;number of hops&lt;/li&gt;&#10;&lt;li&gt;authentication with AD&lt;/li&gt;&#10;&lt;li&gt;Retransmission &amp;#8211; speed and duplex settings on the network devices and NAS heads must match&lt;/li&gt;&#10;&lt;li&gt;Over-utilized routers and switches&lt;/li&gt;&#10;&lt;li&gt;File system lookup and metadata request &amp;#8211; deep directory structure could cause delay.&lt;/li&gt;&#10;&lt;li&gt;&lt;span style="text-decoration: underline;"&gt;Over-utilized NAS devices&lt;/span&gt; &amp;#8211; client accessing multiple files can cause high utilization levels on a NAS device&lt;/li&gt;&#10;&lt;li&gt;&lt;span style="text-decoration: underline;"&gt;Over-utilized clients&lt;/span&gt; &amp;#8211; if a client is busy itself, it requires a longer time to process the request and responses.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large"&gt;&lt;img loading="lazy" decoding="async" width="988" height="664" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-47.png" alt="" class="wp-image-385"/&gt;&lt;figcaption class="wp-element-caption"&gt;NAS latency&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;NFS server manages privilege and does not require username and password from the client at the time of mounting. CIFS share does require username and password.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Common network optimization practices&lt;/strong&gt; for network contestion:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;A &lt;span style="text-decoration: underline;"&gt;VLAN&lt;/span&gt; is a logical segment of a switched network or logical grouping of end devices connected to different physical networks. The segmentation or grouping can be done based on business functions, project teams, or applications. VLAN is a Layer 2 (data link layer) construct and works similar to a physical LAN. A network switch can be logically divided among multiple VLANs, enabling better utilization of the switch and reducing overall cost of deploying a network infrastructure.&amp;nbsp;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The broadcast traffic on one VLAN is not transmitted outside that VLAN, which substantially reduces the broadcast overhead, makes bandwidth available for applications, and reduces the network&amp;#8217;s vulnerability to broadcast storms.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;span style="text-decoration: underline;"&gt;MTU&lt;/span&gt; setting determines the size of the largest packet that can be transmitted without data fragmentation. &lt;span style="text-decoration: underline;"&gt;Path maximum transmission&lt;/span&gt; unit discovery is the process of discovering the maximum size of a packet that can be sent across a network without fragmentation. The default MTU setting for an Ethernet interface card is 1,500 bytes. A feature called &lt;span style="text-decoration: underline;"&gt;jumbo frames&lt;/span&gt; sends, receives or transports Ethernet frames with an MTU of more than 1,500 bytes. The most common deployments of jumbo frames have an MTU of 9,000 bytes. However, not all vendors use the same MTU size for jumbo frames. Servers send and receive larger frames more efficiently than smaller ones in heavy network traffic conditions. Jumbo frames ensure increased efficiency because it takes fewer, larger frames to transfer the same amount of data. Larger packets also reduce the amount of raw network bandwidth being consumed for the same amount of payload. Larger frames also help to smooth sudden I/O burst.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The &lt;span style="text-decoration: underline;"&gt;TCP window size&lt;/span&gt; is the maximum amount of data that can be sent at any time for a connection. For example, if a pair of hosts is talking over a TCP connection that has a TCP windows size of 64KB, the sender can send only 64KB of data and must then wait for an acknowledgement from the receiver. If the receiver acknowledges that all the data has been received, then the sender is free to send another 64 KB of data. If the sender receives an acknowledgment from the receiver that only the first 32 KB of data has been received, which can happen only if another 32 KB of data is in transit or was lost, the sender can send only another 32 KB of data because the transmission cannot have more than 64 KB of unacknowledged data outstanding.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In theory, the TCP window size should be set to the product of the available bandwidth of the network and the round-trip time of data sent over the network. For example, if a network has a bandwidth of 100 Mbps and the round-trip time is 5 milliseconds, the TCP window should be as follows:&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;100 Mb/s x .005 seconds = 524,288 bits or 65,536 bytes&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;The size of the TCP window fi eld that controls the fl ow of data is between 2 bytes and 65,535 bytes&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;span style="text-decoration: underline;"&gt;Link aggregation&lt;/span&gt; is the process of combining two or more network interfaces into a logical network interface, enabling higher throughput, load sharing or load balancing, transparent path failover, and scalability. Due to link aggregation, multiple active Ethernet connections to the same switch appear as one link. If a connection or a port in the aggregation is lost, then all the network traffic on that link is redistributed across the remaining active connections.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;File-level virtualization&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;File-level virtualization eliminates the dependencies between the data accessed at the file level and the location where the files are physically stored. Implementation of file-level virtualization is common in NAS or file-server environments. It provides non-disruptive file mobility to optimize storage utilization.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;It provides user or application independence from the location where the files are stored. File-level virtualization creates a logical pool of storage, enabling users to use a logical path, rather than a physical path, to access files. While the files are being moved, clients can access their files non-disruptively. Clients can also read their files from the old location and write them back to the new location without realizing that the physical location has changed. A global namespace is used to map the logical path of a file to the physical path names.&lt;/p&gt;&#10;&lt;figure class="wp-block-image size-large"&gt;&lt;img loading="lazy" decoding="async" width="1114" height="682" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-48.png" alt="" class="wp-image-386"/&gt;&lt;figcaption class="wp-element-caption"&gt;File-serving environment before and after file-level virtualization&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;h4 class="wp-block-heading" id="h-object-based-storage"&gt;&lt;strong&gt;Object-based storage&lt;/strong&gt;&lt;/h4&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In NAS, metadata are stored as part of the file distributed throughout the environment, which adds to the complexity and latency in searching and retrieving files. Object-based storage, on the other hand, stores file data in the form of objects based on its content and other attributes, rather than the name and location.&lt;/p&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-49.png" alt="" class="wp-image-387" width="402" height="240"/&gt;&lt;figcaption class="wp-element-caption"&gt;Hierarchical File System and Flat Address Space&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;OSD &amp;#8211; object-based storage devices&lt;/strong&gt;, stores data in the form of objects using flat address space. There is no hierarchy of directories and file. Object is identified by objectID, which is usually generated using hash function.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;In block storage, when file system receives the IO from an application, the file system maps the incoming I/O to the disk blocks. The block interface is used for sending the I/O over the channel or network to the storage device. The I/O is then written to the block allocated on the disk drive. When an application accesses data stored in OSD, the request is sent to the file system user component. The file system user component communicates to the OSD interface, which in turn sends the request to the storage device. The storage device has the OSD storage component responsible for managing the access to the object on a storage device.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Benefit of object storage&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;security and reliability: OSD can use special algorithm for strong encryption capacity. Request authentication is performed at the storage device rather than with an external authentication mechanism&lt;/li&gt;&#10;&lt;li&gt;platform independence: standard web access via REST or SOAP&lt;/li&gt;&#10;&lt;li&gt;scalability: Both storage and OSD nodes can be scaled independently in terms of performance and capacity&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-50.png" alt="" class="wp-image-388" width="401" height="445"/&gt;&lt;figcaption class="wp-element-caption"&gt;Block-level access vs object-level access&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;OSD components&lt;/strong&gt;:&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;nodes: a server with OSD operating environment to provide services to store, retrieve and manage data. Two key services are metadata service (generating objectID and maintaining the mapping between objectID and file) and storage service (manage a set of disks where data are stored).&lt;/li&gt;&#10;&lt;li&gt;private network: provides node-to-node connectivity and node-to-storage connectivity.&lt;/li&gt;&#10;&lt;li&gt;storage device&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-51.png" alt="" class="wp-image-389" width="518" height="166"/&gt;&lt;figcaption class="wp-element-caption"&gt;OSD system components&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Storage mechanism&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&#10;&lt;li&gt;The application server presents the file to be stored to the OSD node.&lt;/li&gt;&#10;&lt;li&gt;The OSD node divides the file into two parts: user data and metadata.&lt;/li&gt;&#10;&lt;li&gt;The OSD node generates the object ID using a specialized algorithm. The algorithm is executed against the contents of the user data to derive an ID unique to this data.&lt;/li&gt;&#10;&lt;li&gt;For future access, the OSD node stores the metadata and object ID using the metadata service.&lt;/li&gt;&#10;&lt;li&gt;The OSD node stores the user data (objects) in the storage device using the storage service.&lt;/li&gt;&#10;&lt;li&gt;An acknowledgment is sent to the application server stating that the object is stored.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-52.png" alt="" class="wp-image-390" width="512" height="334"/&gt;&lt;figcaption class="wp-element-caption"&gt;OSD: object storage&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Retrieval mechanism&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol class="wp-block-list"&gt;&#10;&lt;li&gt;The application server sends a read request to the OSD system.&lt;/li&gt;&#10;&lt;li&gt;The metadata service retrieves the object ID for the requested file.&lt;/li&gt;&#10;&lt;li&gt;The metadata service sends the object ID to the application server.&lt;/li&gt;&#10;&lt;li&gt;The application server sends the object ID to the OSD storage service for object retrieval.&lt;/li&gt;&#10;&lt;li&gt;The OSD storage service retrieves the object from the storage device.&lt;/li&gt;&#10;&lt;li&gt;The OSD storage service sends the file to the application server.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-53.png" alt="" class="wp-image-391" width="525" height="291"/&gt;&lt;figcaption class="wp-element-caption"&gt;OSD object retrieval&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;OSD usage&lt;/strong&gt;: data archival, especially long-term; and cloud storage, storage as service&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;CAS &amp;#8211; content addressed storage&lt;/strong&gt;, a special type of OSD designed for secure online storage and retrieval of fixed content. Data access in CAS differs from other OSD devices. &lt;span style="text-decoration: underline;"&gt;In CAS, the application server access the CAS device only via the CAS API running on the application server&lt;/span&gt;. However, the way CAS stores data is similar to the other OSD systems.&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;CAS&lt;/strong&gt; &lt;strong&gt;Use case &lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;Healthcare: storing patient studies &amp;#8211; size of radiology study ranges from 15MB to more than 1GB. Newly acquired studies are retained for 60 days and moved to long term storage.&lt;/li&gt;&#10;&lt;li&gt;Finance: storing financial records &amp;#8211; bank stores images of cheques (~25KB each) for about 90 millions a month. Images are processed in transaction system for 5 days. For the next 60 days images are requested for verifications. After 60 days access requirements drop drastically. Retention policy manages life-cycle of the images.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p class="wp-block-paragraph"&gt;&lt;strong&gt;Unified storage&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p class="wp-block-paragraph"&gt;Components&lt;/p&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;storage controller: The storage controller provides block-level access to application servers through iSCSI, FC, or FCoE protocols.&lt;/li&gt;&#10;&lt;li&gt;NAS head: a dedicated file server that provides file access to NAS clients&lt;/li&gt;&#10;&lt;li&gt;OSD node: accesses the storage through the storage controller using a FC or FCoE connection.&lt;/li&gt;&#10;&lt;li&gt;Storage&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="wp-block-image"&gt;&#10;&lt;figure class="aligncenter size-large is-resized"&gt;&lt;img loading="lazy" decoding="async" src="https://www.digihunch.com/wp-content/uploads/2019/11/image-54.png" alt="" class="wp-image-392" width="459" height="533"/&gt;&lt;figcaption class="wp-element-caption"&gt;Unified storage platform&lt;/figcaption&gt;&lt;/figure&gt;&#10;&lt;/div&gt;&#10;&lt;h4 class="wp-block-heading" id="h-related-postings"&gt;Related Postings&lt;/h4&gt;&#10;&lt;ul class="wp-block-list"&gt;&#10;&lt;li&gt;&lt;a href="https://www.digihunch.com/2019/03/storage-nitty-gritty-1-5/"&gt;Disk and RAID&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.digihunch.com/2019/05/storage-nitty-gritty-2-5/"&gt;SAN&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.digihunch.com/2019/07/storage-nitty-gritty-3-of-5-nas-and-object-storage/"&gt;Backup and Archive Solutions&lt;/a&gt;&lt;/li&gt;&#10;&lt;li&gt;&lt;a href="https://www.digihunch.com/2019/11/storage-nitty-gritty-5-of-5-replication/"&gt;Replication&lt;/a&gt;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;nav class="wp-post-navigation" aria-label="Post navigation"&gt;&#10;&lt;a rel="prev" href="https://www.digihunch.com/2019/07/practical-cryptography-for-it-professional/"&gt;&lt;span class="wp-post-navigation-label"&gt;Previous Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;Cryptography Basics 1 of 2&lt;/strong&gt;&lt;/a&gt;&#10;&lt;a rel="next" href="https://www.digihunch.com/2019/08/aws-certified-devops-engineer-exam-tips/"&gt;&lt;span class="wp-post-navigation-label"&gt;Next Post&lt;/span&gt;&lt;strong class="wp-post-navigation-title"&gt;AWS Certified DevOps Engineer Exam Tips&lt;/strong&gt;&lt;/a&gt;&#10;&lt;/nav&gt;&#10;</description></item></channel></rss>