Sayfalar

7 Mart 2025 Cuma

Bir ekip lideri nelere dikkat etmeli

 1. Dijital Dönüşüm Süreçlerine Katkı

Dijital dönüşüm süreçlerine katkı sağlamak, beni heyecanlandıran bir konu. Bu süreçlerde, özellikle verimlilik artırıcı çözümler geliştirmek ve dijital altyapıyı güçlendirmek için yenilikçi fikirler sunuyorum. Hem yazılım geliştirme hem de kullanıcı deneyimi üzerine yapılan iyileştirmelerle bu süreçlerin hızlanmasını sağlıyorum. Örneğin, micro hizmet mimarisi ve container teknolojileri gibi modern yazılım yaklaşımlarıyla dijital dönüşümü hızlandırmayı hedefliyorum.


2. Yazılım Geliştirme Süreçlerindeki Deneyim

Yazılım geliştirme süreçlerinde, Agile ve Scrum metodolojilerini tercih ediyorum. Bu metodolojilerin esnekliği, projelere hız katmak ve işbirliği içinde çalışan takımlar oluşturmak adına önemli bir avantaj sağlıyor. Süreç boyunca sürekli iletişim ve düzenli geri bildirim alarak projeleri daha verimli bir şekilde yönettim.


3. Scrum ve Kanban Arasındaki Farklar

Scrum ve Kanban arasındaki farkları, projelerin gereksinimlerine göre değerlendiriyorum. Scrum, daha çok değişime açık ve modüler projeler için uygundur. Kanban ise daha az değişkenlik olan, sabit zaman çizelgeleri belirli projeler için uygundur. Scrum, her sprint sonunda teslimat ve geribildirim alırken, Kanban sürekli akışla çalışır.


4. Karşılaşılan Zorluklarla Başa Çıkma

Proje süreçlerinde karşılaşılan zorlukları, ekip arkadaşlarımla birlikte çözüme kavuştururum. Takım üyelerinin güçlü yönlerini bilerek görevleri dağıtmak ve açık iletişimle çözüm aramak, bu zorluklarla başa çıkmada çok önemli bir strateji. Ayrıca, teknik anlamda derinlemesine çözümleme yaparak, probleme özgü yaratıcı çözümler geliştiririm.


5. Liderlik Tarzı

Liderlik tarzım, empati ve işbirliği odaklıdır. Takım üyelerinin güçlü yönlerine göre görev dağılımı yaparak, onların işlerinden keyif almalarını ve projeye sahiplenmelerini sağlarım. Bununla birlikte, her zaman geri bildirim alarak ekip dinamiklerine uygun yönlendirmeler yaparım.


6. Proje Yönetimindeki En Önemli Faktörler

Proje yönetiminde, her şeyden önce planlama, iletişim ve esneklik çok önemli. Proje başlangıcında iyi bir analiz yaparak yol haritası oluştururum. Ayrıca, projelerdeki değişikliklere hızlıca uyum sağlamak için esnek olmanın ve sürekli iletişimde kalmanın başarıyı artırdığını düşünüyorum.


7. Yeni Teknolojilerle İlgili Takip Stratejisi

Yeni teknolojileri sürekli olarak araştırırım. Bloglar, LinkedIn ve teknoloji seminerleri bu konuda takip ettiğim başlıca kaynaklardır. Öne çıkan isimler ve şirketler hakkında içerikler okuyarak, dijital dünyadaki gelişmeleri yakından takip ederim. Bu sayede teknolojik yenilikleri projelere entegre ederek verimliliği artırırım.


8. Ekipte Etkili İletişim Sağlama Yolları

Ekip içindeki iletişimi, açık ve dürüst bir şekilde yönetmeye özen gösteririm. Düzenli toplantılar yaparak her ekip üyesinin görüşünü alır, ihtiyaç duydukları konularda onlara destek olurum. Ayrıca, başarıların kutlanması ve karşılaşılan sorunların hızlıca çözülmesi de etkili iletişimi güçlendirir.


9. Takımınızın Yetenekleri ve Güçlü Yönleri

Takımımda, farklı disiplinlerden gelen ve farklı yeteneklere sahip bireyler bulunuyor. Bu çeşitlilik, projelerde daha yaratıcı ve yenilikçi çözümler üretilmesini sağlıyor. Her bireyin güçlü yönlerini göz önünde bulundurarak görev dağılımı yapar ve takımın potansiyelini en verimli şekilde kullanırım.


10. Yazılım Geliştirme Araçları ve Teknolojileri

C#, .Net Core, Redis, RabbitMQ ve Docker gibi teknolojilerle geniş bir yelpazeye sahip bir deneyimim var. Ayrıca, test araçları ve CI/CD süreçleri hakkında da derinlemesine bilgi sahibiyim. Bu araçlar sayesinde yazılım geliştirme süreçlerini hızlandırarak, yüksek kaliteli çözümler üretiyorum.


11. Agile Metodolojisi Uygulama

Agile metodolojisiyle çalışırken, sprintlere dayalı bir yaklaşım benimsiyorum. Her sprint sonunda, takımın ve projenin gelişim durumunu değerlendirir, gerektiğinde yön değişiklikleri yaparız. Sürekli geri bildirim almak, projelerin hızlıca gelişmesini sağlar ve her sprint sonunda yeni özellikler veya güncellemelerle ilerleriz.


12. Yazılım Mimarisi ile İlgili Konular

Yazılım mimarisi, projelerin sürdürülebilirliğini ve ölçeklenebilirliğini doğrudan etkiler. Modüler yapılar, yüksek test edilebilirlik ve esneklik, benim için önemli kriterlerdir. Ayrıca, mikro servisler ve container teknolojileri ile yazılımın daha dayanıklı ve kolay yönetilebilir olmasını sağlıyorum.


13. Performans Optimizasyonu

Performans optimizasyonu yaparken, öncelikle bottleneck noktalarını analiz ederim. Sonrasında bu bölgelerde yapılan iyileştirmelerle, yazılımın hızını ve verimliliğini artırırım. Ayrıca, yazılımın her aşamasında testler yaparak, optimizasyonların etkisini izlerim.


14. Liderlik Zorlukları ile Başa Çıkma

Ekip içinde liderlik yaparken zorluklarla karşılaştığımda, herkesi dinler ve ortak bir çözüm yolu bulmaya çalışırım. Çeşitli görüşleri dikkate alarak ve empati yaparak en uygun çözümü geliştirmeye özen gösteririm. Çözüm odaklı yaklaşım ve açık iletişim bu süreçte büyük rol oynar.


15. Projelerde En Büyük Başarıyı Tanımlama

Projelerdeki en büyük başarı, kullanıcıların ve takımın ihtiyaçlarını karşılayan, çözüm odaklı bir sonuç elde etmektir. Başarı, tüm paydaşların memnuniyetini sağlamaktan geçer. Kullanıcı dostu çözümler ve kaliteli yazılımlar ortaya koymak bu başarıyı tanımlar.


16. Geliştirilen Yazılımların Fonksiyonları

Geliştirdiğimiz yazılımlar, kullanıcı deneyimini iyileştirmeyi hedefleyen özelliklerle donatılmıştır. Performans optimizasyonları, hızlı veri işleme ve kullanıcı dostu arayüzler gibi özellikler yazılımlarımızda ön planda yer alır. Ayrıca, yüksek güvenlik önlemleri ve veri koruma çözümleri de sağlanır.


17. İleri Düzey Yazılım Dillerinde Bilgi Kullanımı

İleri düzey yazılım dillerindeki bilgimi, modüler ve sürdürülebilir yazılım çözümleri üretmek için kullanıyorum. C# ve .Net Core gibi dillerde, verimli ve sürdürülebilir kod yapıları geliştirerek projelerin kalitesini artırırım. Ayrıca yeni yazılım dillerine olan ilgimle sürekli öğrenmeye devam ederim.


18. Takım İletişimini Güçlendirmek İçin Yöntemler

Etkili iletişim için düzenli toplantılar yapar ve her takım üyesinin görüşlerine değer veririm. Ayrıca, takım üyelerinin başarılarını kutlayarak moral artırıcı bir ortam oluştururum. Açık iletişim ve karşılıklı saygı, ekip içindeki güveni pekiştirir.


19. Yeni Teknolojilerle Araştırma Yapma Yöntemleri

Yeni teknolojilerle ilgili araştırmalarımı, sektördeki lider isimleri takip ederek ve yayınlanan makaleleri okuyarak yapıyorum. Ayrıca uygulamalı çalışmalara katılarak yeni teknolojileri test ediyorum ve projelere entegre ediyorum. Bu sayede, yazılım süreçlerindeki yenilikçi çözümleri sürekli olarak takip ediyorum.


20. Proje Süreci ve Organizasyon Yapısı

Proje sürecinde, başlangıçta detaylı bir planlama yaparak, her modül için açık görev tanımları belirliyorum. Ekip üyeleriyle birlikte her hafta düzenli toplantılar yaparak ilerlememizi takip ediyor ve gerektiğinde yön değişiklikleri yapıyoruz.


21. Takımın Yetenekleri ve Güçlü Yönleri

Takımımda her bireyin farklı bir yeteneği ve güçlü yönü bulunuyor. Bu çeşitlilik, projelerde daha yaratıcı ve yenilikçi çözümler üretilmesini sağlıyor. Her bireyin güçlü yönlerini göz önünde bulundurarak görev dağılımı yapar ve takımın potansiyelini en verimli şekilde kullanırım.


22. Hedeflere Ulaşırken Karşılaşılan Engelleri Aşma

Engelleri aşarken çözüm odaklı düşünmeye özen gösteririm. Her bir engeli, detaylı analiz ederek ve takım arkadaşlarımın görüşlerini dikkate alarak çözmeye çalışırım. Takım ruhu içinde her engel, birlikte aşılabilecek bir zorluktur.


23. Yazılımda Performans İyileştirmeleri

Performans iyileştirmeleri yaparken, öncelikle hangi modüllerin daha fazla kaynak tükettiğini tespit ederim. Bu analizlerden sonra, yazılımın hızını artıracak optimizasyonlar yaparak, performansı daha verimli hale getiririm.


24. Yeni Teknolojilerle İlgili Takip Edilen Kaynaklar

Yeni teknolojilerle ilgili bloglar, LinkedIn grupları, seminerler ve online kurslar gibi kaynakları düzenli olarak takip ederim. Bu kaynaklar sayesinde sektördeki yenilikleri hızlıca öğreniyor ve projelerime entegre ediyorum.

6 Mart 2025 Perşembe

SCRUM VE KANBAN ARASINDAKİ FARKLAR

Scrum ve Kanban yaklaşımlarından hangisinin daha uygun olduğunu belirleyen faktörler şunlardır:

Projenin türü: Bazı projeler, belirgin başlangıç ve bitiş tarihlerine sahipken, diğerleri sürekli olarak değişen gereksinimlere sahiptir. Scrum, sürekli olarak değişen gereksinimlere sahip projeler için daha uygundur. Kanban, belirgin başlangıç ve bitiş tarihlerine sahip projeler için daha uygundur.

Projenin karmaşıklığı: Bazı projeler, basit ve anlaşılması kolaydır. Diğerleri karmaşık ve çok yönlüdür. Scrum, karmaşık ve çok yönlü projeler için daha uygundur. Kanban, basit ve anlaşılması kolay projeler için daha uygundur.

Projenin ekibi: Scrumda önerilen ekip kapasitesi 3 ile 9 kişi arasındadır. Kanban da ise herhangi bir kişi sayısı limiti yoktur.

Genellikle, Scrum’ı daha büyük, çok yönlü ve nitelikli projeler için tercih ederim çünkü bu tür projelerde sürekli değişim, revizyon ve iterasyon gereklidir. Scrum, modüler yapısı sayesinde esneklik sunar ve takımın her sprintte daha verimli bir şekilde çalışmasına olanak tanır. Örneğin, proje modüllerinde sık değişiklikler olabileceği durumlarda Scrum oldukça etkili olur. Kanban ise daha basit ve başlangıç/bitiş tarihleri net olan projeler için ideal bir yaklaşımdır. Genellikle, sabit süreçlerin olduğu projelerde Kanban’ı tercih ederim çünkü süreçlerin daha öngörülebilir ve zaman yönetiminin net olması gerekmektedir. Her iki metodolojiyi de projenin gereksinimlerine göre en verimli şekilde uygulayarak, takımların verimliliğini artırmayı hedeflerim

4 Mart 2025 Salı

Understanding Kubernetes Autoscaling

 Table of contents

Kubernetes provides a series of features to ensure your clusters have the right size to handle any type of load. In this blog post, we will look into the different auto-scaling tools provided by Kubernetes and learn the difference between the horizontal pod autoscaler, the vertical pod autoscaler and Kubernetes Nodes autoscaler.

Developers use Kubernetes to ship faster to their users and respond to their requests as quickly as possible. You design the capacity of your cluster on the estimated load your users will generate on it. But imagine your service went viral, and the number of requests grows faster than you ever imagined. You risk running out of compute resources, your service might slow down, and users may get frustrated.

When you allocate resources manually, your responses may not be as quick as required by your application's changing needs. This is were Kubernetes Autoscaling comes in: Kubernetes provides multiple layers of autoscaling functionality: Pod-based scaling with the Horizontal Pod Autoscaler and the Vertical Pod Autoscaler, as well as node-based with the Cluster Autoscaler. It automatically scales up your cluster as soon as you need it and scales it back down to its regular size when the load is lower. These layers ensure that each pod and cluster has the right performance to serve your current needs.

Kubernetes Architecture

In Kubernetes, a set of machines for running containerized applications is called Cluster. A cluster contains, at minimum, a Control Plane and one or several Nodes. The control plane maintains the clusters' desired state, such as which applications run on them and which images they use. The nodes are either virtual or physical machines that run the applications and workloads, called Pods. Pods consist of containers that request compute resources such as CPU, Memory, or GPU.


Kubernetes Cluster Architecture

For more information to the different Kubernetes components, refer to our dedicated blog post: An introduction to Kubernetes

Horizontal vs. Vertical Scaling

Horizontal

Vertical

Pod

Adds or removes Pods

Modifies CPU and/or RAM resources allocated to the Pod

Node

Adds or removes Nodes

Modifies CPU and/or RAM resources allocated to the Node

  • Horizontal Scaling means modifying the compute resources of an existing cluster, for example, by adding new nodes to it or by adding new pods by increasing the replica count of pods (Horizontal Pod Autoscaler).

  • Vertical Scaling means to modify the attributed resources (like CPU or RAM) of each node in the cluster. In most cases, this means creating an entirely new node pool using machines that have different hardware configurations. Vertical scaling on pods means dynamically adjusting the resource requests and limits based on the current application requirements (Vertical Pod Autoscaler).

Horizontal Pod Autoscaler

The Horizontal Pod Autoscaler (HPA) is able to scale the number of pods available in a cluster to handle the current computational workload requirements of an application. It determines the number of pods needed based on metrics set by you and applies the creation or deletion of pods based on threshold sets. In most cases, these metrics are CPU and RAM usage, but it is also possible to specify your custom metrics. The HPA checks continuously the CPU and memory metrics generated by the metrics-server installed in the Kubernetes cluster.

If one of the specified thresholds is met, it updates the number of pod replicas inside the deployment controller. Following the updated number of pod replicas, the deployment controller will scale up or down the number of pods until the number of replicas matches the desired number. In case you want to use custom metrics to define rules on how the HPA handles scaling your pods, your cluster needs to be linked to a time-series database holding the metrics you want to use. Please note that Horizontal Pod Autoscaling can not be applied to objects that can not be scaled like, for example, DaemonSets.

Vertical Pod Autoscaler

The Vertical Pod Autoscaler (VPA) can allocate more (or less) CPU and memory resources to existing pods to modify the available compute resources for an application. This feature can be useful to monitor and adjust the allocated resources of each pod over its lifetime. The VPA comes with a tool called VPA Recommender, which monitors the current and past resource consumption and use this data to provide recommended CPU and memory resources to be allocated for the containers. The Vertical Pod Autoscaler does not update resource configurations for existing pods. It checks which pods have the correct resource configuration and kills the ones that are not having the recommended configuration so that their controllers can recreate them with the updated configuration.

When you want to use the HPA and VPA both at the same time to manage your container resources, you may put them in a conflict which each other when using the same metrics (CPU and memory). Both of them will try to solve the situation simultaneously, resulting in a wrong allocation of resources. However, it is possible to use them both if they rely on different metrics. The VPA uses CPU and memory consumption as unique sources to gather the perfect resource allocation, but the HPA can be used with custom metrics so both tools can be used in parallel.

Kubernetes Nodes Autoscaler

The Kubernetes Nodes Autoscaler adds or removes nodes in a cluster based on all pods' requested resources. It is possible to define a minimum and a maximum number of nodes available to the cluster from the Scaleway Elements console.

While the Horizontal and Vertical Pod Autoscalers allow you to scale pods, the Kubernetes Node Autoscaler scales your clusters nodes, based on the number of pending pods. The CA checks to see whether there are any pending pods and increases the cluster's size so that these pods can be created. It also deallocates idle nodes to keep the cluster at the optimal size. The Nodes Autoscaler can request to deploy new nodes directly in your pool, within the given resource limits (if any).

Cluster upscaling
If pods are scheduled for execution, the Kubernetes Autoscaler can increase the number of machines in the cluster to avoid resource shortage. The diagram below illustrates how a cluster can be automatically upscaled:


Kubernetes Nodes Autoscaler upscaling

As illustrated, two pods are scheduled for execution but the current node's compute capacity is reached. The cluster autoscaler automatically scans all nodes for scheduled pods. It requests provision of a new node if three conditions are met:

  • Some pods failed to schedule on any of the existing nodes due to insufficient available resources.

  • Adding a node with the same specifications as the current ones help to redistribute the load.

  • The cluster has not reached the user-defined maximum node count.

Once the node is deployed and detected by the Kubernetes Control Plane, the scheduler allocates the pending pods to the cluster's new node. In case there are still some pending pods, the autoscaler repeats these steps as often as required.

Cluster downscaling
The Kubernetes Cluster Autoscaler decreases the number of nodes in a cluster when some are considered not necessary for a pre-defined amount of time. To be considered unnecessary, a node must have low utilization, and all of its important pods can be moved elsewhere without resource shortage. The node scaledown check takes into account the resource requests made by the pods, and if the Kubernetes scheduler decides that the pods can be moved somewhere else, it removes the node from the cluster to optimize resource usage and to reduce costs. If you have defined a minimum number of active nodes in the cluster, the autoscaler will not reduce the number of nodes below this threshold.

Configuring Autoscaling

You can configure Cluster Autoscaling directly from your Scaleway Elements console.

During Cluster creation:
To enable Kubernetes Cluster Autoscaling during the creation of a new cluster, head to step 5 in the cluster creation form, toggle the switch, and set the minimum and maximum resources available for your cluster:

On an existing Cluster:

  1. From your cluster information page, click on the Pools tab and select the pool to modify. Click Edit in the pools drop-down menu to configure the pool:

  2. Toggle on the Autoscale the number of nodes switch and set the desired number of minimum and maximum resources available for the pool:

  1. Confirm the the modification of the pool by clicking on Update pool.

Conclusion

You now understand the basics of Kubernetes Autoscaling features and how you can use them to configure your cluster for maximum performances.

For more information about the Kubernetes Cluster Autoscaler, please refer to the official documentation.

You can also deploy your first Kubernetes Kapsule Cluster directly from your Scaleway console and try out the Autoscaling feature yourself!



Auto-Scaling in Kubernetes: A Step-by-Step Guide

Kubernetes is a powerful container orchestration tool that simplifies the deployment, scaling, and management of containerized applications. One of the key features of Kubernetes is its ability to automatically scale applications based on demand. This guide will walk you through the process of setting up auto-scaling in Kubernetes using the Horizontal Pod Autoscaler (HPA).

Prerequisites

Before we dive in, make sure you have the following:

  • A Kubernetes cluster (you can use Minikube for local development).

  • kubectl installed and configured to communicate with your cluster.

  • The Metrics Server installed on your cluster.

Step 1: Setting Up the Environment

  1. Install Minikube and kubectl:

  2. Start Minikube: [ minikube start ]

Step 2: Install Metrics Server

The Metrics Server is essential for HPA as it provides the resource usage metrics.

Deploy the Metrics Server:

kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

Verify Metrics Server Installation:

kubectl get deployment metrics-server -n kube-system

Step 3: Deploy a Sample Application

We’ll use a simple Nginx deployment as our sample application.

Create an Nginx Deployment:

kubectl create deployment nginx --image=nginx

Expose the Deployment:

kubectl expose deployment nginx --port=80 --type=NodePort

Verify the Deployment:

kubectl get pods

Step 4: Create a Horizontal Pod Autoscaler (HPA)

Now, we will create an HPA that scales the Nginx deployment based on CPU utilization.

Create the HPA:

kubectl autoscale deployment nginx --cpu-percent=50 --min=1 --max=10

Verify the HPA:

kubectl get hpa

You should see output similar to this:

NAME    REFERENCE          TARGETS    MINPODS   MAXPODS     REPLICAS       AGE
nginx   Deployment/nginx   <unknown>/50%   1          10        1          1m

Step 5: Generate Load to Test Auto-Scaling

To observe auto-scaling in action, we need to generate some load on the Nginx application.

Run a Load Generator:

We’ll create a temporary pod that continuously sends requests to the Nginx service.

kubectl run -i --tty load-generator --image=busybox /bin/sh
# Inside the busybox shell
while true; do wget -q -O- http://nginx.default.svc.cluster.local; done

This command will create a load on the Nginx service by continuously making HTTP requests.

Observe Auto-Scaling:

After a few minutes, the HPA should detect the increased CPU load and start scaling the number of Nginx pods. You can monitor this by running:

kubectl get hpa
kubectl get pods    

You should see the number of Nginx pods increase based on the load.

Step 6: Clean Up

Once you are done testing, you can clean up the resources to avoid unnecessary costs and resource usage.

Delete the Nginx Deployment and Service:

kubectl delete deployment nginx
kubectl delete svc nginx

Delete the HPA:

kubectl delete hpa nginx

Delete the Load Generator Pod:

kubectl delete pod load-generator

Conclusion

Auto-scaling in Kubernetes is a powerful feature that helps ensure your applications can handle varying levels of traffic efficiently. By following this guide, you should be able to set up and test auto-scaling for your applications using the Horizontal Pod Autoscaler. Additionally, you can explore advanced auto-scaling configurations using custom metrics and the Vertical Pod Autoscaler for more dynamic resource management.



2 Mart 2025 Pazar

Ocelot Detaylı Anlatım

 Ocelot, .NET ekosisteminde kullanılan popüler bir API Gateway çözümüdür ve mikroservislerin yönetilmesini kolaylaştırır. Reverse Proxy (Ters Proxy) gibi çalışarak gelen HTTP isteklerini yönlendirme, yük dengeleme, kimlik doğrulama, yetkilendirme, rate limiting gibi işlemleri yapar.

Şimdi Ocelot’un API Gateway yönlendirmesi nasıl çalışır adım adım detaylandıralım.


1. Ocelot’un Temel Yapısı

Ocelot, yönlendirme işlemlerini ocelot.json adlı bir konfigürasyon dosyası üzerinden yapar. İstekleri alır ve ilgili mikroservise yönlendirir.

Temel Yapı:

  • ClientAPI Gateway (Ocelot)Mikro Servisler
  • API Gateway, gelen isteği inceler ve konfigürasyon dosyasına göre yönlendirme yapar.

2. Ocelot Konfigürasyonu ile Yönlendirme (Routing)

Bir örnek üzerinden inceleyelim:

Senaryo:

  • Kullanıcı API’yi çağırıyor: https://api.example.com/users/1
  • Ocelot, isteği ilgili mikro servise yönlendiriyor: http://user-service/api/users/1

Bunu Ocelot’ta nasıl konfigüre ederiz?

ocelot.json dosyasında yönlendirme ayarları:

json
{ "Routes": [ { "DownstreamPathTemplate": "/api/users/{id}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "user-service", "Port": 5001 } ], "UpstreamPathTemplate": "/users/{id}", "UpstreamHttpMethod": [ "Get" ] } ] }

Bu Yapı Ne Anlama Geliyor?

  • UpstreamPathTemplate: Kullanıcıdan gelen API isteği https://api.example.com/users/{id} olacak.
  • DownstreamPathTemplate: Ocelot bu isteği http://user-service:5001/api/users/{id} adresine yönlendirecek.
  • DownstreamHostAndPorts: Mikroservisin bulunduğu host ve port bilgisi.
  • UpstreamHttpMethod: Sadece GET isteklerine izin verildiğini belirtiyor.

3. Ocelot’un Çalışma Mantığı

  1. Client (Örneğin bir frontend uygulaması), API Gateway’e istek atar:
    nginx
    GET https://api.example.com/users/1
  2. Ocelot, ocelot.json dosyasına bakar ve uygun yönlendirmeyi bulur.
  3. İsteği, ilgili mikro servisin endpoint’ine yönlendirir:
    bash
    GET http://user-service:5001/api/users/1
  4. Mikro servis yanıtı döner, Ocelot bu yanıtı alıp istemciye iletir.

Sonuç: API Gateway tek giriş noktası olur, istemciler mikro servislerin iç yapısını bilmeden onlara ulaşır.


4. Birden Fazla Servis ile Kullanım

Birden fazla mikro servisi Ocelot üzerinden yönlendirmek için farklı rotalar ekleyebiliriz.

Örnek: Hem Kullanıcı Servisi Hem de Ürün Servisi Olsun

json
{ "Routes": [ { "DownstreamPathTemplate": "/api/users/{id}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [{ "Host": "user-service", "Port": 5001 }], "UpstreamPathTemplate": "/users/{id}", "UpstreamHttpMethod": [ "Get" ] }, { "DownstreamPathTemplate": "/api/products/{id}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [{ "Host": "product-service", "Port": 5002 }], "UpstreamPathTemplate": "/products/{id}", "UpstreamHttpMethod": [ "Get" ] } ] }

Sonuç:

  • https://api.example.com/users/1http://user-service:5001/api/users/1
  • https://api.example.com/products/2http://product-service:5002/api/products/2

5. Ocelot ile Load Balancing (Yük Dengeleme)

Aynı mikro servisten birden fazla instance çalıştırıldığında yük dengeleme yapılabilir.

Örneğin, User Service’in birden fazla instance’ı varsa, aşağıdaki gibi bir yapı kurabiliriz:

json
{ "Routes": [ { "DownstreamPathTemplate": "/api/users/{id}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "user-service", "Port": 5001 }, { "Host": "user-service", "Port": 5002 } ], "UpstreamPathTemplate": "/users/{id}", "UpstreamHttpMethod": [ "Get" ], "LoadBalancerOptions": { "Type": "RoundRobin" } } ] }

Yük Dengeleme Çalışma Mantığı

  • Ocelot, gelen istekleri sırayla farklı instancelara yönlendirir.
  • Round Robin yöntemi ile her yeni istek farklı bir servise gider.
  • Böylece bir servis aşırı yüklenmez, tüm instance’lar dengeli çalışır.

6. Ocelot ile Authentication & Authorization (Kimlik Doğrulama ve Yetkilendirme)

Ocelot, JWT Token ile kimlik doğrulama (Authentication) ve yetkilendirme (Authorization) yapabilir.

Örneğin, yalnızca belirli yetkiye sahip kullanıcıların bir endpoint’e erişebilmesini sağlayabiliriz.

json
{ "Routes": [ { "DownstreamPathTemplate": "/api/orders", "DownstreamScheme": "http", "DownstreamHostAndPorts": [{ "Host": "order-service", "Port": 5003 }], "UpstreamPathTemplate": "/orders", "UpstreamHttpMethod": [ "Get" ], "AuthenticationOptions": { "AuthenticationProviderKey": "Bearer", "AllowedScopes": [ "order.read" ] } } ], "GlobalConfiguration": { "BaseUrl": "https://api.example.com", "AuthenticationProviders": [ { "Name": "Bearer", "Provider": "IdentityServer", "ProviderRootUrl": "https://auth.example.com" } ] } }

Kimlik Doğrulama Çalışma Mantığı

  1. Client önce bir kimlik doğrulama sunucusundan (IdentityServer) JWT token alır.
  2. API Gateway’e istek yaparken bu token’ı gönderir.
  3. Ocelot, token’ı kontrol eder ve yetkisi varsa isteği ilgili mikro servise yönlendirir.

Sonuç: Ocelot’un API Gateway Yönlendirmesi Ne Sağlar?

Merkezi API Yönetimi → Tüm mikro servisleri tek bir noktadan yönetmeyi sağlar.
Yük Dengeleme (Load Balancing) → Mikro servis instanceları arasında istekleri dengeler.
Kimlik Doğrulama (Authentication & Authorization) → JWT token veya OAuth ile güvenli erişim sunar.
Caching & Rate Limiting → Sık yapılan istekleri cache’leyerek performansı artırır.
Logging & Monitoring → Gelen/giden istekleri loglayarak hata takibi yapmayı kolaylaştırır.

Sonuç olarak, Ocelot, .NET tabanlı mikroservis mimarisinde güçlü ve esnek bir API Gateway çözümüdür. 🚀