Posts

Showing posts from June, 2025

azure fleet manager managing multiple aks cluster version/image upgrades

Image
 You can use fleet manager to upgrade your aks cluster version and node image. First you need fleet manager and a member. Member can resides in different regions.  You can see that a new AKS cluster gets created on top of the 2 we're trying to configured. Go to Setting -> Multi-Cluster update -> Create manual run.  Then under the page, specify the following options that you wanted. Once it is created, click on the run and select "Start". This is pretty straight forward.  It gets tricky when we get to create stage. Before you can create a stage, you need to assign / create an update group - as shown here.  Once you have this defined, you can easily create a stage for your strategy. For example,  Let's say you have 2 clusters, primary and secondary and you want to create a stage upgrade - upgrade secondary and then primary cluster.  This is where you can use stages.  Create a manual run, this time use "Stage", then click on "Create stage". The...

kafka creating message producer and client consumer

  To create a message producer that publishes message to a kafka, we can do the follow:-  import os from kafka import KafkaProducer def main ():     kafka_host = os . getenv ( 'KAFKA_HOST' )     # Connect to Kafka broker     producer = KafkaProducer( bootstrap_servers = f ' { kafka_host } :9092' )     # Send a message to a topic     producer .send( 'my-topic' , b 'Hello, Kafka!' )     # Optional: wait for all messages to be sent and close the producer     producer .flush()     producer .close() if __name__ == "__main__" :     main () And if you trying to create a message producer, you can use the simple code here: import os from kafka import KafkaConsumer kafka_host = os . getenv ( 'KAFKA_HOST' ) # Connect to Kafka and subscribe to a topic consumer = KafkaConsumer(     'my-topic' ,     bootstrap_servers = f ' { kafka_host } :9092' ,     auto...

github action Error: buildx failed with: ERROR: denied: permission_denied: write_package

Encounter this error while trying to get my dockerfile build going.  To fix this ensure, you have configure write permission like this:- name : python-client-prometheus on :   push :     branches : [ "main" ]   pull_request :     branches : [ "main" ] permissions :   packages : write   And then, also ensure you are using and pushing to the right (current) repository. In my case, my current build  repository is called  prometheus-monitoring-hello     - name : Build and Push Docker image       uses : docker/build-push-action@v5       with :         context : .         push : true         tags : ghcr.io/${{ github.repository_owner }}/prometheus-monitoring-hello:latest That's it.

minimax - running minimax model on a google colab - crash out with memory issue.

To run minimax llm model on a google colab we can open google colab and change the runtime type to T4/GPU. Then use the following scripts ! pip install -U transformers Next, we specify the model. A 32  billion parameter and takes up about 4.9G of space. Unfortunately, when trying to run this on a free Google Colab it crashes out. 😀 # Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline( "text-generation" , model= "MiniMaxAI/SynLogic-32B" ) messages = [     { "role" : "user" , "content" : "Who are you?" }, ] pipe(messages) Then tried using vllm to run the same model, got crashed out as well. Seems like it does requires quite abit of memory.  # Install vLLM from pip: ! pip install vllm # Load and run the model: ! vllm serve "MiniMaxAI/SynLogic-32B"

kafka setup in k8s cluster using strimizi

Image
To setup a kafka cluster in k8s is pretty easy with Strimizi.  We can start by creating a namespace call kafka using the following command kubectl create namespace kafka Then we setup stirmizi CRDs kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka And finally installing the cluster kubectl apply -f https://strimzi.io/examples/latest/kafka/kafka-single-node.yaml -n kafka  If everything goes well, then you should have the followings  You can run the following command to check for your kakfa instance k get KafkaNodePool -A k get Kafka -A Send and receive messages To test out the consumer, run the following command and you can keep on entering messages by pressing enter. It will continuously accept inputs until you press Ctrl+break kubectl -n kafka run kafka-producer -ti --image=quay.io/strimzi/kafka:0.46.0-kafka-4.0.0 --rm=true --restart=Never -- bin/kafka-console-producer.sh --bootstrap-server my-cluster-kafka-bootstrap:9092 --topic my-topic To ...

stirmizi kafka setting up with the docs command issue

If you're trying to setup stirmizi kafka using the default command in the documentation page using powershell windows environment, you maybe asked to run the followings:   kubectl create -f 'https://strimzi.io/install/latest?namespace=kafka' -n kafka the above will error out.  The fix - remove the quotes  kubectl create -f  https://strimzi.io/install/latest?namespace=kafka -n kafka

langchain tool - how to create a lang chain tool

There are 3 options to create lang chain tool.  The first option is using  1. @tool decorator. Let's say we are creating a simple tool and all we need to do is use tool decorator like this from langchain_core . tools import tool from pydantic import BaseModel , Field class CalculatorInput ( BaseModel ):     a : int = Field ( description = "first number" )     b : int = Field ( description = "second number" ) @ tool ( "multiplication tool", args_schema = CalculatorInput) def multiply ( a : int , b : int ) -> int :     """Multiply two numbers."""     return a * b Then you can start binding the agent to this tool: from cal import multiply tools = [ multiply ] model_with_tools = model . bind_tools ( tools ) response = model_with_tools . invoke ([ HumanMessage ( content = "multiply 2 * 2" )]) print ( f "ContentString: { response . content } " ) print ( f "ToolCalls: { response...

langchain agent hello world

We can start building LLM agents using Langchain. Similiar to MCP, you would require a LLM engine such as Gemini, Chatgpt or Claude.  Please note this is only a agent - not a tool. To get started, you can register one for Gemini for free here https://aistudio.google.com/ and lets have it tested with the code sample.  In this example, we going to use gemini as the LLM and then ask it to do some search via Tavily tool.  So you get your LLM, get your agent tool in this case it is Tavily and then you bring it together.  from langchain_community . tools . tavily_search import TavilySearchResults search = TavilySearchResults ( max_results = 2 ) search_results = search . invoke ( "what is the weather in SF" ) print ( search_results ) # If we want, we can create other tools. # Once we have all the tools we want, we can put them in a list that we will reference later. tools = [ search ] Setting up your weapon of choice - LLM import getpass import os if not os . e...

google gemini getting api key for your model

Image
When using tools like Langchain, you might be using Gemini as your model and this means you need to create an API key for integration.  You can goto https://aistudio.google.com/apikey and sign in using your google account. Then  Then click on "Create API Key". And that's it. 

dockerfile for uv python apps

This is a dockerfile that I find useful when my python app uses uv as the env manager. # Use official Python base image FROM python:3.12-slim # Install curl (used to install uv) and some system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \     curl gcc build-essential ca-certificates \     && rm -rf /var/lib/apt/lists/* # Install uv and move it to a directory in PATH RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \     mv  /root/.local/bin/uv /usr/local/bin/ # Install uv RUN curl -LsSf https://astral.sh/uv/install.sh | sh # Set working directory WORKDIR /app # Copy pyproject.toml and optionally poetry.lock/pdm.lock if you use them COPY pyproject.toml ./ # Install dependencies using uv RUN uv pip install --system --no-deps . # Copy the rest of the code COPY . . # Command to run your app (adjust as needed) CMD [ "python" , "main.py" ]

python unit testing

To use plain old python without installing any additional packages, we can use the following code setup ad run our unit tests. test_simple.py import unittest def add ( x , y ):     return x + y class TestMath ( unittest . TestCase ):     def test_add ( self ):         self . assertEqual ( add ( 2 , 3 ), 5 )         def test_add_success ( self ):         self . assertEqual ( add ( 2 , 3 ), 5 )           def test_add_success_with_extra ( self ):         self . assertEqual ( add ( 2 , 3 ), 5 ) if __name__ == '__main__' :     unittest . main () To run the unit test we can use: python -m unittest discover  or  python -m unittest discover -s tests  (if we have our tests in a tests subfolder) To setup Mocking  With python, we can use the Mock from unittest package. Let's say we have the following classes. A simple Animal class an...

a2a tutorial link

Here is a good link about a2a  https://codelabs.developers.google.com/intro-a2a-purchasing-concierge#1