<?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 Müller Fourie on Medium]]></title>
        <description><![CDATA[Stories by Müller Fourie on Medium]]></description>
        <link>https://medium.com/@mullerfourie?source=rss-d27db5ba76c0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*igGz6W3MRzfZM29rb9qiUw.jpeg</url>
            <title>Stories by Müller Fourie on Medium</title>
            <link>https://medium.com/@mullerfourie?source=rss-d27db5ba76c0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 18:00:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mullerfourie/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[Run a local Kafka server on Linux]]></title>
            <link>https://mullerfourie.medium.com/run-a-local-kafka-server-on-linux-3f50b0bb7493?source=rss-d27db5ba76c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f50b0bb7493</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[kafka-ui]]></category>
            <dc:creator><![CDATA[Müller Fourie]]></dc:creator>
            <pubDate>Thu, 18 Feb 2021 13:34:36 GMT</pubDate>
            <atom:updated>2021-02-18T13:36:00.555Z</atom:updated>
            <content:encoded><![CDATA[<h3>Install Zookeeper</h3><p>Zookeeper keeps track of Kafka cluster nodes and keeps topics and partitions in order. Zookeeper allows multiple clients to perform read and writes simultaneously. Being able to perform instant failover migration.</p><p>Download the latest version of Zookeeper.</p><p><a href="https://www.apache.org/dyn/closer.cgi/zookeeper/">Apache Download Mirrors</a></p><p>Extract to a local directory (I use ~/Applications/)</p><pre>tar zxvf apache-zookeeper-3.6.2-bin.tar.gz -C ~/Applications/</pre><p>Navigate to the extracted directory and update the file name of zoo_sample.cfg to zoo.cfg in the config directory. You can also change the port if you do not want the default port to be 2181,clientPort=2181. Update the dataDir=/tmp/zookeeper to your directory where Zookeeper will keep the data.</p><h3>Install Kafka</h3><p>Download the latest version of Kafka, currently at 2.7.0.</p><p><a href="https://kafka.apache.org/downloads">Apache Kafka</a></p><p>Extract to a local directory (I use ~/Applications/)</p><pre>tar zxvf kafka-2.7.0-src.tgz -C ~/Applications/</pre><p>Open ~/Applications/kafka-2.7.0-src/config/server.properties and uncomment listeners=PLAINTEXT://:9092. Update the log dir, log.dirs=/home/&lt;my_user&gt;/Application/kafka-2.7.0-src to the directory of your extracted Kafka. Also, make sure that zookeeper.connect=localhost:2181 is set at the correct port that will be used by the Kafka broker.</p><h3>Run locally</h3><h4>Start Zookeeper</h4><pre>~/Applications/apache-zookeeper-3.6.2-bin/bin/zkServer.sh start # or stop</pre><h4>Start Kafka</h4><pre>~/Applications/kafka-2.7.0-src/bin/kafka-server-start.sh<br># or to stop<br>~/Applications/kafka-2.7.0-src/bin/kafka-server-stop.sh</pre><h3>Run using Docker and Kafka-UI</h3><p>Kafka-UI is a free web UI for Kafka and they provide this well bundled docker-compose definition (<a href="https://github.com/provectus/kafka-ui">https://github.com/provectus/kafka-ui</a>):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b436eec3dc43a8e3daa6f552dc764b4/href">https://medium.com/media/5b436eec3dc43a8e3daa6f552dc764b4/href</a></iframe><p>Deploy this by running docker-compose</p><pre>docker-compose up</pre><p>Check that all the images referenced in the docker-compose are running docker ps. If all seems up and running, visit localhost:8080 to view the Kafka clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFCAq_5vLDuoos89nUmp4A.png" /></figure><h3>Interact with the local cluster</h3><p>Let&#39;s send a message to the broker. The following scripts connect to the bootstrap servers, defined in the docker-compose, and then sends a basic message to the broker.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcdeeb9eb0f8056ee9cebe7ef533b029/href">https://medium.com/media/fcdeeb9eb0f8056ee9cebe7ef533b029/href</a></iframe><p>Visiting the json-topic at the Kafka-UI. The message should be shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C1SnXx45agP9On1AZDCSng.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f50b0bb7493" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Apache BEAM and AWS S3 storage I/O Transforms in Python]]></title>
            <link>https://python.plainenglish.io/using-apache-beam-and-aws-s3-storage-i-o-transforms-in-python-6cabe2a8d592?source=rss-d27db5ba76c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cabe2a8d592</guid>
            <category><![CDATA[apache-beam]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[beam]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Müller Fourie]]></dc:creator>
            <pubDate>Mon, 15 Feb 2021 15:48:37 GMT</pubDate>
            <atom:updated>2021-02-19T07:53:28.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ktu7mkt3EdaXlctnJNopCw.png" /></figure><p>A picture tells a thousand words. When it comes to software I personally feel that an example explains reading documentation a thousand times. Recently I wanted to make use of Apache BEAM’s I/O transform to write the processed data from a beam pipeline to an S3 bucket.</p><p>At first, I thought this would be as easy as the many WriteToText examples out there:</p><pre>with beam.Pipeline(options=pipeline_options) as p:<br>    ...<br>    p | &#39;Basic write&#39; &gt;&gt; WriteToText(file_path_to_write_to, append_trailing_newlines=False)</pre><p>This wasn’t the case though, on an inspection of the documentation <a href="https://beam.apache.org/releases/pydoc/2.19.0/apache_beam.io.aws.s3io.html">https://beam.apache.org/releases/pydoc/2.19.0/apache_beam.io.aws.s3io.html</a> there is an S3IO client, S3Downloader and an S3Uploader, but how do we actually use this in our pipeline using Python?</p><pre>with beam.Pipeline(options=pipeline_options) as p:<br>    ...<br>    p | &#39;Basic write&#39; &gt;&gt; S3Uploader(....).put(???)</pre><p>That did not work, the S3Uploader needs to be initialized and what happens when the PCollection is big and uploading requires streaming or batching using mime types over HTTP? On further inspection, the I/O transformation has already catered for this by using a create_multipart_upload() within S3 boto client found at <a href="https://github.com/apache/beam/blob/bfc858ac0805f8ec4ca89a5e97f346209c149733/sdks/python/apache_beam/io/aws/clients/s3/boto3_client.py">https://github.com/apache/beam/blob/bfc858ac0805f8ec4ca89a5e97f346209c149733/sdks/python/apache_beam/io/aws/clients/s3/boto3_client.py</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0372274e5c9b9b6da383c5886d8ab67e/href">https://medium.com/media/0372274e5c9b9b6da383c5886d8ab67e/href</a></iframe><p>The S3Uploader and S3Downloader are used inside the S3IO initialized the class.</p><h3>How do I use it🤔?</h3><p>Well, to be honest, I am not sure either but here is how I used it and it seems to be working 🤠. Here is a basic example of how I used the S3 transformation to write to an S3 destination.</p><h4>AWS user setup</h4><p>To get access to the bucket, authentication is required. To do this the user needs access. This can be done by logging in to the AWS console and setting up your IAM for that user.</p><p>In this example there are two options, you can run the pipeline from your local machine where the user credentials are usually placed at ~/.aws credentials file or you can pass the credentials directly in the pipeline options. I prefer the latter, especially when you deploying a pipeline to a remote runner.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8a7921c02bd9c44cdcf449d3fb92357/href">https://medium.com/media/b8a7921c02bd9c44cdcf449d3fb92357/href</a></iframe><h4>The Pipeline🦾</h4><p>I’m using a basic pipeline that creates a string of words, splits them up into words which are then written to S3 as rows.</p><p>On closer inspection of the S3 IO documentation we need to open the S3 location using open() supplying the s3 filepath and mode:</p><pre>S3IO(<em>options</em>=pipeline_options \</pre><pre>.S3Options([</pre><pre>“ — s3_region_name=your_region”,</pre><pre>“ — s3_access_key_id=your_user_access_key_id”,</pre><pre>“ — s3_secret_access_key=your_secret_access_key”</pre><pre>])) \</pre><pre>.open(‘s3://bucket_name/output_filename.txt’, <em>mode</em>=’w’)</pre><p>This sets us up for writing to the output_filename.txt , bear in mind that the IAM user requires PUT permissions. Finally, we would want to write the output to the S3 location but using .open(...).write but takes the only array of bytes so we rather make use of .open(...).writelines() which takes an array of byte arrays for each of our words.</p><p>Before we write the array of byte arrays to S3 we build up an array of byte arrays by using a ParDo ConvertToByteArray followed by a GroupBy. The GroupBy can be used to batch later but goes beyond this scope. The PCollection created by the GroupBy should look something like this:</p><pre>(Key(), [bytearray(b’this\n’), bytearray(b’is\n’), bytearray(b’a\n’), bytearray(b’test\n’), bytearray(b’to\n’), bytearray(b’write\n’), bytearray(b’to\n’), bytearray(b’S3\n’)])</pre><p>This output (index 1 of the tuple) can then be given to .writelines() using WriteToS3.</p><p>This outputs a text file in S3 with a word on a new line. The final pipeline is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01ca1d95f440a6e57aba529c10f4cfe5/href">https://medium.com/media/01ca1d95f440a6e57aba529c10f4cfe5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cabe2a8d592" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/using-apache-beam-and-aws-s3-storage-i-o-transforms-in-python-6cabe2a8d592">Using Apache BEAM and AWS S3 storage I/O Transforms in Python</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache BEAM + Flink Cluster + Kubernetes + Python]]></title>
            <link>https://python.plainenglish.io/apache-beam-flink-cluster-kubernetes-python-a1965f37b7cb?source=rss-d27db5ba76c0------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1965f37b7cb</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[flink]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Müller Fourie]]></dc:creator>
            <pubDate>Thu, 11 Feb 2021 09:17:41 GMT</pubDate>
            <atom:updated>2021-02-22T07:21:12.703Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AS4Saizr0Z3lZrLcM0NaWw.png" /></figure><p>Without going on about all the benefits of BEAM such as open-source and its APIs that alleviates some pain with an added level of abstraction we’ll get downright to implementation. If you have been working on GCP for a while, you would have found that running BEAM pipelines in python work nicely on GCP’s Dataflow runner. Switching over to other cloud environments such as AWS or local clusters causes some headaches. This is where the need for another runner came in, Flink was the one I went with, it seemed to have good support for Kubernetes and good documentation but there were some caveats when running specifically with Python’s SDK. I discuss my steps in the following article, hope it helps.</p><h3>Environment setup</h3><p>I used an AWS EKS cluster to deploy the Flink cluster but for sake of costs and local testing, Minikube was used. For more information on setting up an environment for Minikube check out <a href="https://minikube.sigs.k8s.io/docs/start/">https://minikube.sigs.k8s.io/docs/start/</a></p><p>First fire up the Minikube cluster</p><pre>minikube start</pre><p>Make sure you have kubectl installed (<a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">https://kubernetes.io/docs/tasks/tools/install-kubectl/</a>) and view your cluster</p><pre>kubectl get all</pre><p>You should have nothing running but kubernetes service.</p><p>Now use the yaml configurations for a session environment on the Flink Kubernetes help page <a href="https://ci.apache.org/projects/flink/flink-docs-stable/deployment/resource-providers/standalone/kubernetes.html">https://ci.apache.org/projects/flink/flink-docs-stable/deployment/resource-providers/standalone/kubernetes.html</a>.</p><p>The flink-configuration-configmap.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0092f837afa70680f3540e10dab96db1/href">https://medium.com/media/0092f837afa70680f3540e10dab96db1/href</a></iframe><p>Then the job manager service</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/abfbdf8b7d6eabf0635422993184c2fd/href">https://medium.com/media/abfbdf8b7d6eabf0635422993184c2fd/href</a></iframe><p>And the job manager session deployment</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9ab9626451edf70ac02753a9e4a3e48/href">https://medium.com/media/d9ab9626451edf70ac02753a9e4a3e48/href</a></iframe><p>This is the important part, we need to include the worker pools in the sidecar containers in the pod of the taskmanager shown in task-manager-session-deployment.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6de3217a39388e497df14e10cf2b98cd/href">https://medium.com/media/6de3217a39388e497df14e10cf2b98cd/href</a></iframe><p>The beam-worker-pool in is the addition to the original config</p><pre>- name: beam-worker-pool</pre><pre>image: apache/beam_python3.7_sdk</pre><pre>args: [&quot;--worker_pool&quot;]</pre><pre>ports:</pre><pre>- containerPort: 50000</pre><pre>name: pool</pre><pre>livenessProbe:</pre><pre>tcpSocket:</pre><pre>port: 50000</pre><pre>initialDelaySeconds: 30</pre><pre>periodSeconds: 60</pre><p>This ensures that another container is running in the task manager pod and will handle the job server. The job server runs apache/beam_python3.7_sdk image that is able to bundle our Apache BEAM pipelines written in python.</p><p>Something to note is that the port 50000 is used by the python pipeline options and used to communicate to the job server using the SDK Harness Configuration specified by BEAM <a href="https://beam.apache.org/documentation/runtime/sdk-harness-config/">https://beam.apache.org/documentation/runtime/sdk-harness-config/</a> which will allow the user code to be dispatched to an external service using the environment_type as EXTERNAL.</p><p>Lastly, we need to expose the Flink master. This is done in Minikube by port forwarding your local environment</p><pre>kubectl port-forward &lt;flink_master_container&gt; 8081:8081</pre><p>You can find your &lt;flink_master_container&gt; by running a kubectl get all and using the Flink master container name.</p><p>Visit your dashboard at localhost:8081:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*slL_sWqEhFWSPUYLqyPp3A.png" /></figure><h3>Running your pipeline</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69cf41bb6b1fbe8942920c5cf63aad14/href">https://medium.com/media/69cf41bb6b1fbe8942920c5cf63aad14/href</a></iframe><p>Finally, we run the pipeline</p><pre>python &lt;beam_pipeline_file&gt;.py</pre><p>The dashboard gives us some indication of when the job is running and finishing up</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2p4efMqJaCTvWpNMYtrCYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EK2M1SF9r9VCjQfCp5qxjg.png" /></figure><p>To make sure the write to file at the end of the beam pipeline ran, we can visit the worker pool to find the test.txt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rsMqgt3glhArBwhl9SnDmA.png" /></figure><p>In a real-world problem, this output would go to Redshift, BigQuery etc but for now, all I wanted was to test the execution of our Flink cluster and python SDK using BEAM.</p><h4>Library versions:</h4><p>apache_beam==2.26.0, flink 1.10</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1965f37b7cb" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/apache-beam-flink-cluster-kubernetes-python-a1965f37b7cb">Apache BEAM + Flink Cluster + Kubernetes + Python</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>