Skip to content

Instantly share code, notes, and snippets.

Topic: first_topic TopicId: D9zBaINRQ6O3QUjnan4_0A PartitionCount: 3 ReplicationFactor: 2 Configs: min.insync.replicas=2
Topic: first_topic Partition: 0 Leader: 2 Replicas: 2,1 Isr: 2,1 Offline:
Topic: first_topic Partition: 1 Leader: 1 Replicas: 1,2 Isr: 1,2 Offline:
Topic: first_topic Partition: 2 Leader: 2 Replicas: 2,1 Isr: 2,1 Offline:
@badri
badri / README.md
Last active June 9, 2023 15:46
Kafka exercise

Create a web service using your preferred programming language and framework (e.g., Python with Flask).

Implement two endpoints:

  1. /orders (POST): Accepts JSON payload representing a product order and publishes it to the Kafka topic "product_orders".
  2. /orders (GET): Retrieves all product orders from the PostgreSQL database and returns them as JSON.

Implement a DB sink connector which reads "product_orders" topic and writes the data to a table called orders in Postgres DB.

Write a Kafka consumer which consumes from "product_orders" and writes to a respective city topic. For ex, in the below order payload:

@badri
badri / docker-compose.yml
Created May 6, 2023 05:17
kong getting started
version: '3'
networks:
demo-net:
name: demo-net
driver: bridge
services:
postgres:
@badri
badri / postgres.yml
Created April 3, 2023 07:37
Postgres client image
apiVersion: v1
kind: Pod
metadata:
name: postgresql-client
namespace: postgresql-client
labels:
app: postgresql-client
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
spec:
@badri
badri / Dockerfile
Created March 16, 2023 10:18
RHEL8 kong
FROM kong/kong-gateway:2.8-rhel
USER root
# -- BEGIN custom stuff
RUN yum install -q -y autoconf automake libtool m4 make
RUN mkdir /expat /rocks
# Can be downloaded here: https://github.com/libexpat/libexpat/releases/tag/R_2_5_0
COPY R_2_5_0.tar.gz /expat
# Rock files can be downloaded from https://luarocks.org/
@badri
badri / terraform for_each based aks change
Created February 25, 2023 07:05
terraform apply for_each aks
$ terraform apply
random_id.cluster_name[0]: Refreshing state... [id=l6NFpxOl]
azurerm_resource_group.rg[0]: Refreshing state... [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/resourceGroups/K8sRG1]
data.azurerm_kubernetes_service_versions.current[0]: Reading...
data.azurerm_kubernetes_service_versions.current[0]: Read complete after 1s [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/providers/Microsoft.ContainerService/locations/southindia]
azurerm_kubernetes_cluster.aks[0]: Refreshing state... [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/resourceGroups/K8sRG1/providers/Microsoft.ContainerService/managedClusters/k8s-97a345a713a5]
azurerm_public_ip.public_ip[0]: Refreshing state... [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/resourceGroups/MC_K8sRG1_k8s-97a345a713a5_southindia/providers/Microsoft.Network/publicIPAddresses/k8s-public-ip-97a345a713a5]
local_file.kubeconfigaks[0]: Refreshing state... [id=d3b4d0d008bb4e373b42f22171bda5321281bf65]
azurerm_kubernetes_cluster_
@badri
badri / node_pools.tf
Created February 25, 2023 06:23
node pools tf using for_each
resource "azurerm_kubernetes_cluster_node_pool" "aks_node_pool" {
for_each = {
for index, node_pool in local.node_pools :
node_pool.name => node_pool
}
name = each.value.name
kubernetes_cluster_id = azurerm_kubernetes_cluster.aks.id
vm_size = each.value.vm_size
node_count = each.value.node_count
@badri
badri / terraform apply
Created February 25, 2023 05:56
Terraform count based resource management
$ terraform apply
random_id.cluster_name[0]: Refreshing state... [id=26Ak6SRX]
azurerm_resource_group.rg[0]: Refreshing state... [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/resourceGroups/K8sRG1]
data.azurerm_kubernetes_service_versions.current[0]: Reading...
data.azurerm_kubernetes_service_versions.current[0]: Read complete after 1s [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/providers/Microsoft.ContainerService/locations/southindia]
azurerm_kubernetes_cluster.aks[0]: Refreshing state... [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/resourceGroups/K8sRG1/providers/Microsoft.ContainerService/managedClusters/k8s-dba024e92457]
azurerm_public_ip.public_ip[0]: Refreshing state... [id=/subscriptions/104e4289-6059-4afb-885a-982ba31991ee/resourceGroups/MC_K8sRG1_k8s-dba024e92457_southindia/providers/Microsoft.Network/publicIPAddresses/k8s-public-ip-dba024e92457]
local_file.kubeconfigaks[0]: Refreshing state... [id=6d63d7a3898cbab172185eb9d0d1d56b753f4d3b]
azurerm_kubernetes_cluster_
@badri
badri / node_pools.tf
Created February 25, 2023 05:33
YAML config based node pools
locals {
node_pools = yamldecode(file("${path.module}/node-pool.yaml"))
}
resource "azurerm_kubernetes_cluster_node_pool" "aks_node_pool" {
count = length(local.node_pools)
name = local.node_pools[count.index].name
kubernetes_cluster_id = azurerm_kubernetes_cluster.aks.id
vm_size = local.node_pools[count.index].vm_size
@badri
badri / aks.tf
Created February 25, 2023 05:23
Azure Kubernetes cluster
resource "random_id" "cluster_name" {
byte_length = 6
}
resource "azurerm_resource_group" "rg" {
name = "K8sRG1"
location = var.aks_region
}
data "azurerm_kubernetes_service_versions" "current" {