<?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 Berker Narol on Medium]]></title>
        <description><![CDATA[Stories by Berker Narol on Medium]]></description>
        <link>https://medium.com/@berkern?source=rss-b988bfe26f92------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RCMG462Xv9xxbL1BXamDnQ.png</url>
            <title>Stories by Berker Narol on Medium</title>
            <link>https://medium.com/@berkern?source=rss-b988bfe26f92------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:28:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@berkern/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[Change Data Capture with Debezium Server on GKE from CloudSQL for PostgreSQL to Pub/Sub]]></title>
            <link>https://medium.com/google-cloud/change-data-capture-with-debezium-server-on-gke-from-cloudsql-for-postgresql-to-pub-sub-d1c0b92baa98?source=rss-b988bfe26f92------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1c0b92baa98</guid>
            <category><![CDATA[cdc]]></category>
            <category><![CDATA[cloud-pubsub]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Berker Narol]]></dc:creator>
            <pubDate>Fri, 15 Oct 2021 18:55:03 GMT</pubDate>
            <atom:updated>2021-10-27T12:34:11.019Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEGuCV59gA5SL7a2H0FGLQ.png" /></figure><p>Change Data Capture(CDC) is a design pattern that tracks changes data on a source system and streams these changes to other system.</p><p>In this article, we will capture changes on a table on CloudSQL for PostgreSQL and stream them on a Pub/Sub topic.</p><p>I assume that a PostgreSQL instance and a GKE cluster had already been created before. (Since these are managed services, you can easily create them.)</p><p>There are 3 different parts to achieve this goal. These are DB, Pub/Sub and Debezium Server.</p><h3>Database</h3><p>First of all we need to enable logical decoding by setting <strong><em>cloudsql.logical_decoding</em></strong> flag to <strong><em>on</em></strong>.</p><p>After that we create a DB user that has the REPLICATION attribute:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a05a3554d40fec75fe15c7038184bc7/href">https://medium.com/media/6a05a3554d40fec75fe15c7038184bc7/href</a></iframe><p>And finally, we create a test table to capture:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2376e8396fd6146908e36bd51042710d/href">https://medium.com/media/2376e8396fd6146908e36bd51042710d/href</a></iframe><h3>Pub/Sub</h3><p>We need to create a Pub/Sub topic named <strong><em>debezium-test-db.public.debezium-test</em></strong> that uses a pattern like <strong><em>&lt;server name&gt;.&lt;schema name&gt;.&lt;table name&gt;</em></strong>. We will set the server name below in the Debezium configuration.</p><p>We also need to create a subscription to get change messages in the related topic.</p><h3>Debezium Server</h3><p>To deploy Debezium Server on Kubernetes, we need to define some Kubernetes objects. Debezium Server needs to keep offset information in a file, so we will deploy it as a StatefulSet. We also create a Service for StatefulSet and a ConfigMap to keep Debezium configurations.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d586fb38fcdf3bde1eb289adb3ba1a4/href">https://medium.com/media/1d586fb38fcdf3bde1eb289adb3ba1a4/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2928a0b662abd2afd041241f70d53c5b/href">https://medium.com/media/2928a0b662abd2afd041241f70d53c5b/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39800e603ff3babb71fbcdf0f35524d8/href">https://medium.com/media/39800e603ff3babb71fbcdf0f35524d8/href</a></iframe><p><strong>Note:</strong> Debezium Server will push change events to Pub/Sub topic when it captures. To do that, it must have the required permission. Workload Identity is a good way to achieve this. You can create a GCP service account and give the required permissions. After that with Workload Identity you can bind it to a Kubernetes service account and this way Kubernetes service account acts as a GCP service account.</p><p>That’s it. You can insert, update or delete data on the table and events will be sent to related topic.</p><p><strong>References</strong></p><ul><li><a href="https://cloud.google.com/sql/docs/postgres/replication/configure-logical-replication">https://cloud.google.com/sql/docs/postgres/replication/configure-logical-replication</a></li><li><a href="https://debezium.io/documentation/reference/operations/debezium-server.html">https://debezium.io/documentation/reference/operations/debezium-server.html</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1c0b92baa98" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/change-data-capture-with-debezium-server-on-gke-from-cloudsql-for-postgresql-to-pub-sub-d1c0b92baa98">Change Data Capture with Debezium Server on GKE from CloudSQL for PostgreSQL to Pub/Sub</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Display GKE logs in a text format with kubectl]]></title>
            <link>https://medium.com/google-cloud/display-gke-logs-in-a-text-format-with-kubectl-db0169be0282?source=rss-b988bfe26f92------2</link>
            <guid isPermaLink="false">https://medium.com/p/db0169be0282</guid>
            <category><![CDATA[google-cloud-logging]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[google-kubernetes-engine]]></category>
            <category><![CDATA[kubectl]]></category>
            <dc:creator><![CDATA[Berker Narol]]></dc:creator>
            <pubDate>Wed, 24 Mar 2021 20:44:50 GMT</pubDate>
            <atom:updated>2021-03-25T18:11:29.372Z</atom:updated>
            <content:encoded><![CDATA[<p>If you use GKE and Cloud Logging for log monitoring, you need to print logs as JSON format to use more effective monitoring on Cloud Console. However if you use <strong>kubectl logs</strong> to see logs on CLI, logs won’t be seen readable. It prints each line as a JSON object.</p><p>For most cases it is best to use Google Cloud Console to filter logs and display details but sometimes you want to see logs quickly on CLI.</p><p>To see JSON based logs as a text format, I wrote a simple shell script. Basically this script uses <strong>jq </strong>to convert JSON object to text. You can access the script and installation details on Github: <a href="https://github.com/berker/kube-gke-logs">https://github.com/berker/kube-gke-logs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db0169be0282" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/display-gke-logs-in-a-text-format-with-kubectl-db0169be0282">Display GKE logs in a text format with kubectl</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Isomorphic Javascript]]></title>
            <link>https://medium.com/codable/isomorphic-javascript-dd7e7cd82da6?source=rss-b988bfe26f92------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd7e7cd82da6</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[obss-codable-turkish]]></category>
            <category><![CDATA[isomorphic-javascript]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[isomorphic-applications]]></category>
            <dc:creator><![CDATA[Berker Narol]]></dc:creator>
            <pubDate>Fri, 20 Apr 2018 09:54:43 GMT</pubDate>
            <atom:updated>2018-04-20T10:24:21.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*naqJ6bY5JBa25hvJx60DKA.png" /></figure><p>Isomorphic Javascript, hem client hem de server tarafında çalışan Javascript uygulamalarını ifade etmek için kullanılan bir kavramdır. Bu yaklaşım, dinamik web uygulamalarında ortaya çıkan problemleri ortadan kaldırmayı amaçlamaktadır.</p><p>Dinamik web uygulamaları geliştirirken genelde baz aldığımız 2 yaklaşım var. Bunlardan birincisi web sayfalarını sunucu tabanlı uygulamalar üzerinde oluşturmaktır. Statik HTML sayfaları, Java, .NET, PHP vb. diller ile geliştirilen uygulamalar üzerinden dinamik bir yapıya çevirilmektedir. Örneğin Java tarafında klasik olarak kullandığımız JSP, JSF, Spring MVC gibi frameworkler ile tam olarak bunu yapmaktayız.</p><p>Bu yaklaşımın dezavantajı bakım zorluğudur. Her ne kadar kullanılan frameworkler view katmanını diğer katmanlardan ayırmaya çalışsa da, view katmanında bir template engine yapısı kurulmakta ve bu engine’in sağladığı web standartları dışında bir yapı kullanılmaktadır. Örneğin Java’da Thymeleaf gibi bir engine kullanıyosanız HTML’i dinamik hale getirmek için Thymeleaf’in sağladığı attribute ve tag’leri kullanmanız gerekmektedir.</p><p>Bununla birlikte, günümüz web uygulamalarında Ajax istekleri de sıklıkla kullanılmaktadır. Ajax istekleri ile sunucu tarafından alınan bilgiler Javascript ile işlenip HTML manipüle edilmektedir. Bu durumda HTML’in render edildiği iki yapı ortaya çıkmakta ve önyüzün bakımı çok daha karmaşık hale gelmektedir.</p><p>Web uygulamaları geliştirirken kullandığımız 2. yaklaşım ise Single Page Application(SPA) mimarisine uygun frameworkler kullanarak web uygulamaları oluşturmaktır. Bu yapılar ile önyüz tamamen Javascript ile oluşturulmaktadır. Kullanıcı browser’ı ile yapılan ilk istekte Javascript dosyası browser tarafından yüklenir ve Javascript gerektiğinde Ajax ile sunucudan datayı alıp HTML’i render eder. Browser tarafından yapılan ilk istekten sonra sayfa yenilenmez.</p><p>SPA ile önyüz tamamen Javascript ile yönetildiği için bakım daha kolay hale gelmektedir. Bununla birlikte web standartları kullanıldığı için herhangi bir sunucu tabanlı uygulama bağımlılığı da olmamaktadır. Ancak SPA tarafında da 2 temel problem vardır. Bunlar performans ve SEO problemleridir.</p><p>SPA’larda genellikle uygulamanın önyüz tarafı tek bir Javascript dosyası halinde paketlenir. Uygulama büyüdükçe doğal olarak pakette büyür. Bu paketin browser’a inmesi ve browser tarafından render edilmesi çok uzun zaman alabilmektedir. Javascript render olup gerekli sayfayı oluşturana kadar, sunucudan gelen boş bir sayfa kullanıcıya gösterilmektedir. Bununla birlikte ilk istekte boş bir HTML sayfası geldiği için arama motorları da uygulamayı doğru bir şekilde indexleyememektedir. (Doğru bir şekilde diyorum çünkü bazı arama motorlarının Javascript rendering yaptığı ancak framework bazlı problemler olduğu ile ilgili çalışmalar var.(https://moz.com/blog/search-engines-ready-for-javascript-crawling))</p><p>2 yaklaşımın da kendi içinde dezavantajları bulunmaktadır. Isomorphic Javascript, bu dezavantajları ortadan kaldırmayı hedefleyen bir mimari yaklaşımdır. Isomorphic Javascript, hem önyüz geliştirmelerinde web standartlarını kullanarak uygulama yapmayı, hem de sunucu tarafında render edilmiş kullanıma hazır bir sayfa sunarak arama motorlarına indexleyecek bir içeriği ve kullanıcıların Javascript’in yüklenmesini beklemeden içeriğe erişimini sağlamaktadır. Bunu sağlamak için browser’da çalışan Javascript’in sunucu tarafında da çalışması gerekmektedir.</p><p>Isomorphic Javascript, Node.js ile birlikte sunucu tarafında Javascript çalıştırabilmenin mümkün olmasıyla ortaya çıkmıştır. Bu anlamda Isomorphic Javascript yaklaşımının temelinde Node.js yer alıyor diyebiliriz. Ben bu yazıda ise Node.js yerine farklı bir environment kullanacağım. Java 8 ile birlikte gelen ve JVM üzerinde Javascript çalıştırmayı sağlayan Nashorn engine ile bir örnek yapacağım. Ancak yazacağımız Javascript Node.js veya herhangi başka bir Javascript engine’de de çalışacaktır.</p><p>Bu kadar teorik bilgiden sonra artık uygulamaya başlayabiliriz.</p><p>Bilgisayarımızda JDK 8 ve Node.js kurulu olduğunu varsayıyorum.</p><p>Projemizin sunucu kısmı Spring Boot tabanlı bir uygulama olacak. Client tarafında ise bir React.js uygulaması yapacağız. Javascript paketlemek için Webpack, Javascript yazarken de EcmaScript 6 özelliklerini kullanabilmek için Babel.js kullanacağız.</p><p>İlk adım olarak projemizi oluşturuyoruz. Bunun için <a href="https://start.spring.io/">https://start.spring.io/</a> adresini kullanabiliriz. Ekran görüntüsünde gözüken şekilde bir web uygulaması oluşturuyoruz. (Dependency olarak web’i eklememiz gerekiyor.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I9eqjEkpDBgZ1vON." /></figure><p>Projeyi indirdikten sonra, zip’i bilgisayarımızdaki uygun bir yere açıyoruz ve proje içerisine client adında bir klasör oluşturuyoruz. Komut satırıyla client klasörü lokasyonuna gidiyoruz ve aşağıdaki komutları çalıştırıyoruz:</p><p><strong>npm init -y</strong></p><p><strong>npm install babel-core babel-loader babel-polyfill babel-preset-env babel-preset-react html-webpack-plugin webpack webpack-cli — save-dev</strong></p><p><strong>npm install react react-dom — save</strong></p><p>Client klasörü içerisinde .babelrc isimli bir dosya oluşturuyoruz ve aşağıdaki kodu yazıyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3027eb2a35a7f8c4af51e2802a0c334/href">https://medium.com/media/e3027eb2a35a7f8c4af51e2802a0c334/href</a></iframe><p>Yine client klasörü içerisinde webpack.config.js adında bir dosya oluşturuyoruz ve aşağıdaki içeriği yazıyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7359107dc3e6ac9f6e25d09c340f467/href">https://medium.com/media/c7359107dc3e6ac9f6e25d09c340f467/href</a></iframe><p>Client klasörü içerisinde src isimli bir klasör oluşturuyoruz ve bu klasör altında index.html isimli dosya oluşturuyoruz. Dosya içeriğini şu şekilde dolduruyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5807039c4d52d54c2a8952af772e78c/href">https://medium.com/media/d5807039c4d52d54c2a8952af772e78c/href</a></iframe><p>src klasörü altında App.js dosyası oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b96a8ab68703401ae53d4ffd4645f46d/href">https://medium.com/media/b96a8ab68703401ae53d4ffd4645f46d/href</a></iframe><p>src klasörü altında client.js dosyası oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4327b12e060dcf37f562ed544e1a1a3b/href">https://medium.com/media/4327b12e060dcf37f562ed544e1a1a3b/href</a></iframe><p>client klasörü altında bulunan packages.json dosyası içerisindeki scripts objesine yeni bir komut ekliyoruz:</p><p>“build”: “webpack -p”</p><p>client klasöründeyken aşağıdaki komutu çalıştırıyoruz:</p><p><strong>npm run build</strong></p><p>İşlem bittikten sonra client klasörü altında dist klasörü oluşacaktır. Dist klasörü içerisindeki index.html ‘i browser ile açtığımızda Hello, berker çıktısını göreceğiz.</p><p>Bu noktada browser’da çalışan bir ReactJS uygulamasını tamamlamış oluyoruz.</p><p>Şimdi sıra Javascript’i server tarafında render etmeye geldi. Spring tarafındaki konfigürasyonlarımızı yapmadan önce Javascript tarafında da birkaç düzenleme yapmamız gerekiyor.</p><p>client.js içerisinde App bileşenini oluşturup bunu DOM üzerindeki root id’li elementin içerisinde göstermesini kodladık. Bunu server tarafında çalıştıramayız çünkü server’da bir DOM yok ve bizim App bileşenini render edip Html dosyasındaki ilgili alana yerleştirmemiz ve clienta hazır bir şekilde göndermemiz gerekiyor. Bunun için server.js isimli bir dosya oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e2689b236b500c66178aa4491e1785e/href">https://medium.com/media/2e2689b236b500c66178aa4491e1785e/href</a></iframe><p>server.js içerisinde render isimli bir fonksyion oluşturuyoruz ve template ve model adında iki parametre alıyoruz. Bu parametrelerin ilki oluşturduğumuz statik Html sayfası, ikincisi ise server tarafında tuttuğumuz state bilgisini içermektedir. Fonksiyonun içerisinde App bileşenimizi render ediyoruz ve Html içerisine yerleştiriyoruz.</p><p>Bu noktada index.html dosyamızı tekrar düzenliyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ad29f3137e0ffab54fd1ae5451f8258/href">https://medium.com/media/5ad29f3137e0ffab54fd1ae5451f8258/href</a></iframe><p>Yeni oluşturduğumuz server.js’in de webpack tarafından derlenmesi için webpack.config.js tarafını aşağıdaki gibi değiştiriyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1c5b82109338edc2bc592b4708b85de/href">https://medium.com/media/e1c5b82109338edc2bc592b4708b85de/href</a></iframe><p>Browser üzerinde bulunan ancak server tarafındaki javascript ortamında olmayan objeler olabiliyor. Eğer javascript kodumuzda bu objeler kullanılıyorsa server tarafında hata alıyoruz. Bunu önlemek adına yapılan bir best practice var. Bu da polyfill.js adında bir javascript dosyası oluşturup bu objeleri onun içerisinde oluşturmak. Bu kapsamda biz de bir polyfill.js dosyası oluşturuyoruz ve içerisine aşağıdaki kodu yazıyoruz:</p><p>var window = this;</p><p>Şimdi Spring tarafındaki geliştirmeleri yapıyoruz. Öncelikle ScriptViewConfig isimli bir sınıf oluşturuyoruz:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e558d69580389d1b4b20ed40157f50b3/href">https://medium.com/media/e558d69580389d1b4b20ed40157f50b3/href</a></iframe><p>IndexController :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/854d3be6ebb065229cd8fd6ffd5e03c8/href">https://medium.com/media/854d3be6ebb065229cd8fd6ffd5e03c8/href</a></iframe><p>Geliştirmemiz bitti. Spring uygulamamızı çalıştırmadan önce client klasöründe tekrar npm run buil komutunu çalıştırıp javascriptlerimizi derliyoruz. Daha sonra Springboot uygulamamızı çalıştırıyoruz. Browser üzerinden <a href="http://localhost:8080/">http://localhost:8080</a> sayfasını açıyoruz. Developer console üzerinden network ile gelen isteğe baktığımızda serverdan render edilmiş içeriğin geldiğini görüyoruz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s0NRIoolmAeOkFWJ." /></figure><p>Sayfa yüklendikten sonra, “Hello, asd” yazısı “Hello, berker” olarak değişiyor. Bunun da nedeni sayfa yüklendikten sonra client.js’in çalışıp App bileşenini kendi değişkeni ile tekrar render etmesinden kaynaklanmaktadır. client.js’te de server’ın state’ini kullanacak şekilde değiştirmemiz gerekiyor:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01fea80dbd13d7c96a63c96b903ed00d/href">https://medium.com/media/01fea80dbd13d7c96a63c96b903ed00d/href</a></iframe><p>Daha sonra tekrar npm run build çalıştırıp uygulamayı restart ettiğimizde mesajın değişmediğini görebiliriz.</p><p>Isomorphic Javascript, özellikle büyük çaplı SPA tabanlı uygulamalarda değerlendirilmesi gereken önemli bir yaklaşımdır. Bu yazı ile önemli noktalarına değinip basit bir örnekle ReactJS uygulamasının sunucu tarafında nasıl çalıştığını göstermeye çalıştım.</p><p>Örnek uygulamanın tamamına <a href="https://github.com/berker/isomorphic">https://github.com/berker/isomorphic</a> üzerinden erişebilirsiniz.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd7e7cd82da6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codable/isomorphic-javascript-dd7e7cd82da6">Isomorphic Javascript</a> was originally published in <a href="https://medium.com/codable">Codable</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>