smitmistry77 commented on issue #2486:
URL: 
https://github.com/apache/apisix-ingress-controller/issues/2486#issuecomment-3103134926

   Sure @juzhiyuan ,
   Let me explain you my usecase: I want to divide the traffic based on the 
lite customers (Consumers) and Premium Consumers.
   So firstly via Admin API,
   Step1: I am creating two consumer groups: LiteConsumerGroup and 
PremiumConsumerGroup.
   Step2: I am creating one consumer in lite group and associating the 
LiteConsumerGroup Id to it, one for PremiumConsumer and associating the 
PremiumConsumerGroup id to it.
   Step3: I am create a route for a simple call to Upstream.
   Step4: I am executing the API.
   Below are the API Curls:
   **Create lite Consumer Group:**
   curl --request PUT \
     --url https://localhost:9180/apisix/admin/consumer_groups/lite \
     --header 'X-API-KEY: {{Admin_Apikey}}' \
     --header 'content-type: application/json' \
     --data '{
     "plugins": {
       "ai-proxy-multi": {
         "fallback_strategy": "instance_health_and_rate_limiting",
         "instances": [
           {
             "name": "gemma3-instance",
             "provider": "openai-compatible",
             "priority": 2,
             "weight": 0,
             "auth": {
               "header": {
                 "Authorization": ""
               }
             },
             "options": {
               "model": "google/gemma-xxxx"
             },
             "override": {
               "endpoint": "http://abcd/v1/chat/completions";
             }
           },
           {
             "name": "llama4-instance",
             "provider": "openai-compatible",
             "priority": 1,
             "weight": 0,
             "auth": {
               "header": {
                 "Authorization": ""
               }
             },
             "options": {
               "model": "llama4"
             },
             "override": {
               "endpoint": "http://xyz/v1/chat/completions";
             }
           }
         ]
       },
       "ai-rate-limiting": {
         "instances": [
           {
             "name": "gemma3-instance",
             "limit": 20,
             "time_window": 60
           }
         ],
         "limit_strategy": "prompt_tokens"
       },
       "limit-count": {
         "count": 1,
         "time_window": 60,
         "rejected_code": 429,
         "key_type": "var",
         "key": "consumer_name"
       }
     }
   }'
   **Create a Premium Consumer Group**
   
   curl --request PUT \
     --url https://localhost:9180/apisix/admin/consumer_groups/premium \
     --header 'X-API-KEY: {{Admin_Apikey}}' \
     --header 'content-type: application/json' \
     --data '{
     "plugins": {
       "ai-proxy-multi": {
         "fallback_strategy": "instance_health_and_rate_limiting",
         "instances": [
           {
             "name": "gemma3-instance",
             "provider": "openai-compatible",
             "priority": 2,
             "weight": 0,
             "auth": {
               "header": {
                 "Authorization": ""
               }
             },
             "options": {
               "model": "google/gemma-xxxx"
             },
             "override": {
               "endpoint": "http://abcd/v1/chat/completions";
             }
           },
           {
             "name": "llama4-instance",
             "provider": "openai-compatible",
             "priority": 1,
             "weight": 0,
             "auth": {
               "header": {
                 "Authorization": ""
               }
             },
             "options": {
               "model": "meta-llama/Llama-xxxx"
             },
             "override": {
               "endpoint": "http://xyz/v1/chat/completions";
             }
           }
         ]
       },
       "ai-rate-limiting": {
         "instances": [
           {
             "name": "gemma3-instance",
             "limit": 30,
             "time_window": 60
           }
         ],
         "limit_strategy": "prompt_tokens"
       },
       "limit-count": {
         "count": 3,
         "time_window": 60,
         "rejected_code": 429,
         "key_type": "var",
         "key": "consumer_name"
       }
     }
   }'
   **Lite Consumer**
   curl --request PUT \
     --url https://localhost:9180/apisix/admin/consumers \
     --header 'X-API-KEY: {{Admin_Apikey}}' \
     --header 'content-type: application/json' \
     --data '{
     "username": "consumer-lite",
     "plugins": {
       "key-auth": {
         "key": "xxxxx"
       }
     },
     "group_id":"lite"
   }'
   **Premium Consumer**
   curl --request PUT \
     --url https://localhost:9180/apisix/admin/consumers \
     --header 'X-API-KEY: {{Admin_Apikey}}' \
     --header 'content-type: application/json' \
     --data '{
     "username": "consumer-premium",
     "plugins": {
       "key-auth": {
         "key": "xxxx"
       }
     },
     "group_id":"premium"
   }'
   **Create Route**
   curl --request PUT \
     --url https://localhost:9180/apisix/admin/routes \
     --header 'X-API-KEY: {{Admin_Apikey}}' \
     --header 'content-type: application/json' \
     --data '{
     "id": "route-consumer-category",
     "uri": "/consumercategory",
     "methods": [
       "POST"
     ],
     "plugins": {
       "key-auth": {}
     }
   }'
   **Execute Req with Lite Consumer**
   curl --request POST \
     --url https://localhost:9180/consumercategory \
     --header 'apikey: lite' \
     --header 'content-type: application/json' \
     --data '{
     "model": "google/gemma-xxxx",
     "messages": [
       {
         "role": "user",
         "content": "What is APISIX"
       }
     ]
   }'
   
   **Execute Req with Premium Consumer**
   curl --request POST \
     --url https://localhost:9180/consumercategory \
     --header 'apikey: lite' \
     --header 'content-type: application/json' \
     --data '{
     "model": "google/gemma-xxxx",
     "messages": [
       {
         "role": "user",
         "content": "What is APISIX"
       }
     ]
   }'
   
   Now my question is, can I do the above setup in ADC format with the 
apisix-ingress-controller 2.0.0-rc2 image?
   If yes, how? and if no, then why?
   In the github repo where the CRD yaml file is present, I don't see the 
Consumer_Groups CRD. correct me here if I am wrong.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to