<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Leon Mwandiringa on Medium]]></title>
        <description><![CDATA[Stories by Leon Mwandiringa on Medium]]></description>
        <link>https://medium.com/@leonmwandiringa?source=rss-2fe5be16443f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-fYX9XBcHtNwzAQx</url>
            <title>Stories by Leon Mwandiringa on Medium</title>
            <link>https://medium.com/@leonmwandiringa?source=rss-2fe5be16443f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:10:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leonmwandiringa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Data Warehouse vs Data Lake vs Data LakeHouse in AWS and Kubernetes]]></title>
            <link>https://medium.com/@leonmwandiringa/data-warehouse-vs-data-lake-vs-data-lakehouse-in-aws-and-kubernetes-8c18064e21ea?source=rss-2fe5be16443f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c18064e21ea</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Leon Mwandiringa]]></dc:creator>
            <pubDate>Fri, 24 Nov 2023 09:17:00 GMT</pubDate>
            <atom:updated>2023-11-24T09:17:00.439Z</atom:updated>
            <content:encoded><![CDATA[<p>As Technology keeps advancing, data is growing. While businesses are always looking for better ways of working to be as efficient and productive collecting and making sense of data has become a pain and the main focus for businesses to grow and stay competitive. Data is the new gold, it has allowed new-age tech companies like Google and Facebook to provide their platforms free of charge to their consumers so as to sell the data they are collecting from their users.</p><p>This collection of data has led to an exponential growth of the data from mere gigabytes to exabytes. With an increase in data comes new problems which are how this data is collected, stored, and processed so that accurate information can be extracted and made use of for growth. We have noticed a shift from relational databases to Columnar databases and then file/object storage.</p><p>For every problem we have faced, there has always been a solution. This brought us to getting into Data Warehouse -&gt; Data Lake -&gt; Data LakeHouse. The goal has been to allow room for data growth without impacting much of the performance during transformations, operating costs, complexity overhead, and the like.</p><p><strong>Data Warehouse<br></strong>A data warehouse is structured data collected and filtered for specific tasks from multiple data sources. It integrates with multiple sources like log data, websites, social media, mobile applications, etc. Before data is loaded from input sources it is transformed.<br><strong>Sources</strong> of data for a Data warehouse can be from flat/object files, relational databases like Postgres, MySQL etc, and NoSQL databases like MongoDB, Cassandra etc.<br>Data can possibly come from all kinds of sources but before loaded, it needs to be transformed.<br>There are many technologies we can use to transform our data but from AWS there is plenty of services to make use of for the <strong>transformation</strong> of data like Glue, Data Pipeline, Lambda function, AWS EKS with Spark Operators etc.</p><p>This data which is loaded to the OLAP database like Redshift from AWS this data can now be consumed by BI tools, Machine Learning use cases, and reporting dashboards to extract the resultant results.</p><p>Below is an example design example of how a data warehouse can be built in AWS using EKS with Spark Operators and other AWS tools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9icaLwveK_XCu6M3xaOeA.png" /></figure><p>The downside of managing a data warehouse is it&#39;s not scalable, operating costs keep growing, and transformation needs to be done before loading any of the data. With that in mind, there are multiple options for how to but the most desirable solution is EKS with Spark Operator because of its flexibility, scalability capabilities, and its cost efficiency from elasticity, variety of computing providers like Fargate, Fargate spot, reserved instances, spot instance, and on-demand instances. It&#39;s all a matter of which compute type works and during which times.</p><p><strong>Data Lake<br></strong>A data lake is a collection of unprocessed and centralized data. They could contain clickstreams, logs, file dumps, and real-time data. Data lakes are simple to maintain but require expert knowledge to extract and make sense of the data. Data is extracted, loaded, and transformed when it is needed for analysis purposes. A data lake is highly flexible and can contain all kinds of data types either semi-structured or unstructured data.<br>Since a data lake doesn&#39;t require any structuring it is extremely cheap because data is stored in file/object format, in AWS it is via S3. Besides being cheap it takes some time for data to be retrieved.</p><p>Below is a basic design of a data lake using AWS EKS with Spark Operators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nIMv3m6nR22V0i-a_Bf9g.png" /></figure><p><strong>Data LakeHouse<br></strong>A Data LakeHouse is a data lake on steroids, it combines the best of Data Lakes and Data Warehouse. It&#39;s the new kid on the block even though it not be fully mature but its worth noting that it has a plethora of features it comes with. In data lakehouses, data warehouse-like structures and schemas are used for unstructured data like a data lake. Data Lake Warehouse makes use of all data lake principles and components with more added.</p><p>In addition to the Data lake’s core components like Ingestion, storage, and consumption it has a metadata, caching, API and indexing layer which makes retrieval of data faster, BI and BA-ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nuo598vPqVgJ6yrUyRGpog.png" /></figure><p>With all that the provided benefits from a Data Lakehouse there is a price to pay, It requires a deeper understanding and knowledge to implement and manage it.</p><p><strong>Conclusion<br></strong>A Data LakeHouse is by far the best solution considering that it is a hybrid mesh of a data lake and data warehouse. Data in the data warehouse is easy to use, but harder to store. A data lake is easy to ingest and store data, but hard to query data. It all depends on the type of data you have and what its use cases are but a Data Lakehouse takes the trophy with its shiny features.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c18064e21ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Deep Dive into Cloud Agnostic Data Pipelines with Apache Spark]]></title>
            <link>https://medium.com/@leonmwandiringa/a-deep-dive-into-cloud-agnostic-data-pipelines-with-apache-spark-2db6aefd526?source=rss-2fe5be16443f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2db6aefd526</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[apache-spark]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Leon Mwandiringa]]></dc:creator>
            <pubDate>Thu, 27 Jul 2023 20:23:13 GMT</pubDate>
            <atom:updated>2023-07-27T20:26:26.462Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKpgoVIJzwF7I8uOweUuBw.png" /></figure><p>With the growth of data over the past years it has become almost impossible to process data using traditional frameworks and general-purpose engines. There has been a scramble to find efficient, lightweight, cost-effective, and performant ways to process data. Fast forward to the 1st iteration of Hadoop’s birth, it has been the de facto data processing engine that allowed storing and processing large amounts of data. Hadoop with Map Reduce is still 1 of the best data processing engines to date and is as scalable as the modern data processing engines which came after it.</p><p>Hadoop consisted of<br>1. <strong>Hadoop File System</strong>: A distributed file system that runs on standard or low-end hardware. Performant storage<br>2. <strong>Yet Another Resource Negotiator (YARN</strong>): Manages and monitors cluster performance and resource usage, while also making job triggers.<br>3. <strong>MapReduce: </strong>A Computation framework that processes data. — <em>nowadays is interchangeable with Spark</em><br>4. <strong>Hadoop Core:</strong> Has core and common libraries which is used by other modules.</p><p>Hadoop over the years has matured a lot, it has brought quite a lot of big data modules, tools, and applications growing its ecosystem. There is now interchangeability of Hadoop applications with the addition of applications like Presto, Hive, Spark, etc. AWS has EMR which is managed by Hadoop, it&#39;s quite a useful tool with it being able to run on Fargate, ec2. In addition to all that EMR on EKS offering is out of the box with minimal setup and configuration.</p><p>Enough about EMR, our focus for today is on Spark.<br><strong>Spark: </strong>it&#39;s open source, data is processed in a distributed manner, it makes use of in-memory caching and optimized execution resulting in blazing-fast processing of data. Data using Apache Spark is executed in, batch processing, streaming, machine learning, and also graph databases.</p><p>Apache Spark has become a de facto data processing tool for all kinds of big data processing. AWS Glue comes with Spark baked into it, the same as other big 3 cloud providers. It&#39;s quite seamless to use when provided as a service, a load of setting up and configuration headaches is taken away from you for the price of ridiculous cloud charges.</p><p>It is a good investment to take on and run spark without the dependency on any cloud-provided services like Glue or EMR. That&#39;s where Kubernetes comes into the picture, we can&#39;t be using some server or instance because we care so much about the future lol, I mean scalability, performance, flexibility, and a whole lotta other features Kubernetes offers.</p><p>We are using EKS for now from AWS, which is a managed Kubernetes from AWS, we surely don&#39;t want to also setup Kubernetes the hard way, <em>Kelsey Hightower, </em>probably knows what I mean but if need be we can have it run it anywhere even on bare metal. There are many ways we can run apache spark on Kubernetes, Apache on K8 Operators is the most mature at the moment. Spark can plug into all kinds of storage providers from cloud-provided ones and on-prem. For this article, we have chosen S3 data storage as our data source/target to get and put optimized output. S3 works perfectly especially when paired with EKS because of the native storage driver from AWS which makes use of AWS private network hence minimizing latency, network hops, and enhanced speed.</p><p><strong>Prerequisites<br></strong>1. AWS Account with AWS keys and programmatic access permissions<br>2. Terraform<br>3. Helm<br>4. Kube ctl<br>5. AWS 2.0<br>6. Spark Submit</p><p>No need to worry about the complexity of deploying an EKS cluster in terraform because I have written one for you already, with a whole lot more resources that are required to have it running. The only component being left out are the VPC components from the Route table, subnets, NACL, and internet gateway. I know this can easily get complicated but we don&#39;t have to worry because I have already written some modules which will help in having the whole infrastructure up and running in no time. For this build, our cluster will be in a public subnet because we don&#39;t want to pay for nat gateway ridiculous charges.</p><p><strong>Step1:</strong> Configure AWS CLI<br><strong>Step 2:</strong> write terraform code</p><pre>#filename: main.tf<br><br>## Esparkling <br>provider &quot;aws&quot; {<br>  region = &quot;af-south-1&quot;<br>}<br><br>############################## ecr  #########################################<br>module &quot;ecr&quot; {<br>  source                   = &quot;git::https://github.com/leonmwandiringa/ecr.git&quot;<br>  scan_images_on_push      = true<br>  images_definition    = [<br>    &quot;esparkling&quot;<br>  ]<br>  encryption_configuration = {<br>    encryption_type = &quot;AES256&quot;,<br>    kms_key         = null<br>  }<br>  image_tag_mutability     = &quot;MUTABLE&quot;<br><br>  tags = {<br>    &quot;Name&quot; = &quot;ecr repos&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br>}<br><br>########################## eks cluster security group ###################################<br>module &quot;eks_cluster_security_group&quot; {<br>  source         = &quot;git::https://github.com/leonmwandiringa/terraform-aws-security-group.git&quot;<br>  sg_name = &quot;eks_cluster_security_group&quot;<br>  vpc_id = &quot;vpc-yourvpcid&quot;<br>  sg_rules_egress    = [<br>    {<br>      from_port   = 0<br>      to_port     = 0<br>      protocol    = &quot;-1&quot;<br>      cidr_blocks = &quot;0.0.0.0/0&quot;<br>    },<br>  ]<br>  sg_rules_ingress   = [<br>    {<br>      description = &quot;HTTPS&quot;<br>      from_port   = 0<br>      to_port     = 65535<br>      protocol    = &quot;all&quot;<br>      cidr_blocks = &quot;0.0.0.0/0&quot;<br>    }<br>  ]<br>  global_tags = {<br>    &quot;Name&quot; = &quot;eks log group&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br>}<br><br>################## eks cluster role ############################<br>module &quot;eks_service_iam_role&quot; {<br>  source = &quot;git::https://github.com/leonmwandiringa/iam-role.git&quot;<br>  tags = {<br>    &quot;Name&quot; = &quot;eks service iam&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br>  name = &quot;eks_iam&quot;<br>  principal_name = &quot;eks.amazonaws.com&quot;<br>  policies_attachment = [&quot;arn:aws:iam::aws:policy/AmazonEKSClusterPolicy&quot;, &quot;arn:aws:iam::aws:policy/AmazonEKSVPCResourceController&quot;]<br>  policies = [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;logs:CreateLogGroup&quot;,<br>                &quot;logs:CreateLogStream&quot;,<br>                &quot;logs:DescribeLogGroups&quot;,<br>                &quot;logs:DescribeLogStreams&quot;,<br>                &quot;logs:PutLogEvents&quot;,<br>                &quot;logs:GetLogEvents&quot;,<br>                &quot;logs:FilterLogEvents&quot;,<br>                &quot;ec2:DescribeAccountAttributes&quot;,<br>                &quot;ec2:DescribeAddresses&quot;,<br>                &quot;ec2:DescribeInternetGateways&quot;,<br>                &quot;elasticloadbalancing:SetIpAddressType&quot;,<br>                &quot;elasticloadbalancing:SetSubnets&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>  ]<br>}<br><br>######################## eks cluster #################################<br>module &quot;eks_cluster&quot; {<br>  source = &quot;git::https://github.com/leonmwandiringa/terraform-aws-ecscluster.git&quot;<br>  name = &quot;e-spark-ling-eks&quot;<br>  region                       = &quot;af-south-1&quot;<br>  vpc_id                       = &quot;vpc-yourvpcid&quot;<br>  subnet_ids                   = [&quot;subnet1&quot;, &quot;subnet2&quot;]<br>  eks_cluster_service_role_arn = module.eks_service_iam.role_arn<br>  kubernetes_version           = &quot;1.25&quot;<br>  local_exec_interpreter       = [&quot;/bin/bash&quot;, &quot;-c&quot;] # this might differ for you<br>  oidc_provider_enabled        = true<br>  enabled_cluster_log_types    = []<br>  cluster_log_retention_period = 1<br><br>  cluster_encryption_config_enabled                         = true<br>  cluster_encryption_config_kms_key_id                      = &quot;&quot;<br>  cluster_encryption_config_kms_key_enable_key_rotation     = true<br>  cluster_encryption_config_kms_key_deletion_window_in_days = 10<br>  cluster_encryption_config_kms_key_policy                  = null<br>  cluster_encryption_config_resources                       = [&quot;secrets&quot;]<br><br>  security_group_ids = [module.eks_cluster_security_group.security_group_id]<br><br>  tags = {<br>    &quot;Name&quot; = &quot;eks log group&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br>}<br><br>################## eks cluster role ###########################<br>module &quot;eks_node_group_service_iam&quot; {<br>  source = &quot;git::https://github.com/leonmwandiringa/iam-role.git&quot;<br>  tags = {<br>    &quot;Name&quot; = &quot;eks iam role&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br>  name = &quot;eks_node_group_iam&quot;<br>  principal_name = &quot;ec2.amazonaws.com&quot;<br>  policies_attachment = [<br>    &quot;arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy&quot;, <br>    &quot;arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy&quot;,<br>    &quot;arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly&quot;,<br>    &quot;arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy&quot;<br>  ]<br>  policies = [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;logs:CreateLogGroup&quot;,<br>                &quot;logs:CreateLogStream&quot;,<br>                &quot;logs:DescribeLogGroups&quot;,<br>                &quot;logs:DescribeLogStreams&quot;,<br>                &quot;logs:PutLogEvents&quot;,<br>                &quot;logs:GetLogEvents&quot;,<br>                &quot;logs:FilterLogEvents&quot;,<br>                &quot;ec2:DescribeAccountAttributes&quot;,<br>                &quot;ec2:DescribeAddresses&quot;,<br>                &quot;ec2:DescribeInternetGateways&quot;,<br>                &quot;elasticloadbalancing:SetIpAddressType&quot;,<br>                &quot;elasticloadbalancing:SetSubnets&quot;,<br>                &quot;appmesh:*&quot;,<br>                &quot;s3:*&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>  ]<br>}<br><br><br>######################### eks cluster security group ################################<br>module &quot;eks_nodes_security_group&quot; {<br>  source         = &quot;git::https://github.com/leonmwandiringa/terraform-aws-security-group.git&quot;<br>  sg_name = &quot;eks_nodes_security_group&quot;<br>  vpc_id = &quot;vpc-yourvpcid&quot;<br>  sg_rules_egress    = [<br>    {<br>      from_port   = 0<br>      to_port     = 0<br>      protocol    = &quot;-1&quot;<br>      cidr_blocks = &quot;0.0.0.0/0&quot;<br>    },<br>  ]<br>  sg_rules_ingress   = [<br>    {<br>      description = &quot;HTTPS&quot;<br>      from_port   = 0<br>      to_port     = 65535<br>      protocol    = &quot;all&quot;<br>      cidr_blocks = &quot;0.0.0.0/0&quot;<br>    }<br>  ]<br>  global_tags = {<br>    &quot;Name&quot; = &quot;eks securitygroup&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br>}<br><br><br>##################### eks nodegroup #################<br>module &quot;eks_node_group&quot; {<br>  source = &quot;git::https://github.com/leonmwandiringa/eks-nodegroup.git&quot;<br><br>  subnet_ids         = [&quot;subnet1&quot;, &quot;subnet2&quot;]<br>  cluster_name       = module.eks_cluster.eks_cluster_id<br>  instance_types     = [&quot;t2.medium&quot;]<br>  desired_size       = 2<br>  min_size           = 1<br>  max_size           = 3<br>  kubernetes_version = [&quot;1.21&quot;]<br>  node_role_arn = module.eks_node_group_service_iam.role_arn<br>  associated_security_group_ids = [module.eks_nodes_security_group.security_group_id]<br><br>  ami_type            = &quot;AL2_x86_64&quot;<br><br>  tags = {<br>    &quot;Name&quot; = &quot;eks node group&quot;,<br>    &quot;Project&quot; = &quot;e-spark-ling-data-on-k8&quot;,<br>    &quot;Environment&quot; = &quot;Dev&quot;<br>    &quot;Author&quot; = &quot;LTM&quot;<br>  }<br><br>  depends_on = [<br>    module.eks_cluster, <br>    module.eks_cluster.kubernetes_config_map_id,<br>    module.eks_node_group_service_iam<br>  ]<br><br><br>  node_group_terraform_timeouts = [{<br>    create = &quot;40m&quot;<br>    update = null<br>    delete = &quot;20m&quot;<br>  }]<br>}</pre><p>Step 3: Run “terraform init” inside the folder with main.tf file created<br>Step 4: Run “terraform apply” the type yes to prompt</p><p>Now that we have our infrastructure set up, we can now authenticate to the cluster using our AWS CLI and test using kubectl.<br><em>aws eks — region af-south-1 update-kubeconfig — name </em>e-spark-ling-eks<br><em>kubectl get all</em></p><p>It is time to start installing some prerequisites for the cluster to function and run our spark operator. We are going to be using helm for that<br><em>helm repo add spark-operator </em><a href="https://googlecloudplatform.github.io/spark-on-k8s-operator"><em>https://googlecloudplatform.github.io/spark-on-k8s-operator</em></a><em><br>helm install spark-operator spark-operator/spark-operator — namespace spark-operator — create-namespace — set sparkJobNamespace=default</em></p><p>It&#39;s about time now that we write our spark code, in this example we are doing some ETL using Pyspark which is a spark API for Python, we will package our job application in a docker image, push it to AWS ECR then deploy it to EKS as a docker container inside a Spark Application type of wrapper. Below is a Pyspark script that reads and adds data to a list of dates, this could be from a CSV or parquet file but because of time we will make it simple by just outputting the results</p><pre># sparkling.py<br>from pyspark.sql import SparkSession<br>spark = SparkSession.builder.appName(&#39;ESparkLing&#39;).getOrCreate()<br><br>from pyspark.sql.functions import col,expr<br>data=[(&quot;2023-01-23&quot;,1),(&quot;2022-06-24&quot;,2),(&quot;2022-09-20&quot;,3)]<br>spark.createDataFrame(data).toDF(&quot;date&quot;,&quot;increment&quot;) \<br>    .select(col(&quot;date&quot;),col(&quot;increment&quot;), \<br>      expr(&quot;add_months(to_date(date,&#39;yyyy-MM-dd&#39;),cast(increment as int))&quot;).alias(&quot;inc_date&quot;)) \<br>    .show()</pre><p>Below is a docker file to run this build.</p><pre>FROM amazon/aws-glue-libs:glue_libs_1.0.0_image_01<br>EXPOSE 8888<br>EXPOSE 4040<br><br>RUN mkdir /app<br>COPY . /app<br>WORKDIR /app</pre><pre># esparkling.yaml<br>apiVersion: “sparkoperator.k8s.io/v1beta2”<br>kind: SparkApplication<br>metadata:<br> name: espark-ling<br> namespace: default<br>spec:<br> type: Python<br> pythonVersion: “3”<br> mode: cluster<br> image: “{{IMAGE_REGISTRY}}/{{SERVICE_NAME}}:{{IMAGE_VERSION}}”<br> imagePullPolicy: Always<br> mainApplicationFile: local:///app/sparkling.py<br> sparkVersion: “3.1.1”<br> restartPolicy:<br> type: OnFailure<br> onFailureRetries: 3<br> onFailureRetryInterval: 10<br> onSubmissionFailureRetries: 5<br> onSubmissionFailureRetryInterval: 20<br> driver:<br> cores: 1<br> coreLimit: “1200m”<br> memory: “512m”<br> labels:<br> version: 3.1.1<br> serviceAccount: spark<br> executor:<br>   cores: 1<br>   instances: 2<br>   memory: “1000m”<br>   labels:<br>   version: 3.1.1</pre><p>now that we have the code to run our pipeline we can build the application and push it to a docker registry using the commands below.<br><em>docker build -t esparkling ./application-source<br>docker push {ecr_host}/esparkling:{tag}<br></em>Then deploy to Kubernetes by running the YAML file<br><em>kubectl apply -f ./esparkling.yaml</em></p><p>If we run “<em>kubectl get all -n dev” </em>we should be able to get the running deployment.<br>Now that we have everything running, it&#39;s now easy and straightforward for us to run the job by doing a spark-submit to the cluster and spark application using the command below.<br><em>./bin/spark-submit \<br> — master k8s://https://&lt;k8s-apiserver-host&gt;:&lt;k8s-apiserver-port&gt; \<br> — deploy-mode cluster \<br> — name esparkling\<br> — class org.apache.spark.examples.SparkPi \<br> — conf spark.executor.instances=5</em></p><p><strong>Conclusion<br></strong>It is worth noting that Spark operators-on-k8 is the best option when it comes to running cloud-agnostic pipelines either in AWS, GCP, Azure, and even on-prem deployed on bare metal servers.<br>It&#39;s not always the case that we prefer using managed services in the cloud because of certain reasons like cloud fees, compliance, business decisions, security, etc. This differs for other businesses while some see it as a good option to use public cloud providers to serve their services.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2db6aefd526" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>