0

I've installed apisix and apisix-dashboard with helm on my k8s cluster. I used all defaults except APIKEY for admin and viewer acc., and custom username/password for dashboard. So I'm currently running the 2.15 version.

My installation steps

helm repo add apisix https://charts.apiseven.com 
helm repo update 
# installing apisix/apisix
helm install --set-string admin.credentials.admin="new_api_key"
    --set-string admin.credentials.viewer="new_api_key" apisix apisix/apisix --create-namespace  --namespace my-apisix
# installing apisix/apisix-dashboard, where values.yaml contains username/password
helm install -f values.yaml apisix-dashboard apisix/apisix-dashboard --create-namespace --namespace my-apisix

I'm unable to configure the mocking plugin, I've been following the docs. In the provided example I'm unable to call the API on route with ID 1, so I've created a custom route and after that used the VIEW json, where I've changed the configuration accordingly to the sample provided. All calls on this routes are returning 502 errors, in the logs i can see the route is routing traffic to a non existing server. All of that leads me to believe that the mocking plugin is disabled.

Example of my route:

{
  "uri": "/mock-test.html",
  "name": "mock-sample-read",
  "methods": [
    "GET"
  ],
  "plugins": {
    "mocking": {
      "content_type": "application/json",
      "delay": 1,
      "disable": false,
      "response_schema": {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "properties": {
          "a": {
            "type": "integer"
          },
          "b": {
            "type": "integer"
          }
        },
        "required": [
          "a",
          "b"
        ],
        "type": "object"
      },
      "response_status": 200,
      "with_mock_header": true
    }
  },
  "upstream": {
    "nodes": [
      {
        "host": "127.0.0.1",
        "port": 1980,
        "weight": 1
      }
    ],
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "https",
    "pass_host": "node",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}

Can anyone provide me with an actual working example or point out what I'm missing? Any suggestions are welcomed.

EDIT:

Looking at the logs of the apache/apisix:2.15.0-alpine it looks like this mocking plugin is disabled. Looking at the docs The mocking Plugin is used for mocking an API. When executed, it returns random mock data in the format specified and the request is not forwarded to the Upstream. Error logs where I've changed the domain and IP addr. suggest that the traffic is being redirected to the upstream:

10.10.10.24 - - [23/Sep/2022:11:33:16 +0000] my.domain.com "GET /mock-test.html HTTP/1.1" 502 154 0.001 "-" "PostmanRuntime/7.29.2" 127.0.0.1:1980 502 0.001 "http://my.domain.com"

Globally plugins are enabled, I've tested using the Keycloak plugin.

EDIT 2: Could this be a bug in version 2.15 of apisix? There is currently no open issue on the github repo.

namokarm
  • 668
  • 1
  • 7
  • 20

1 Answers1

0

yes, mocking plugin is not enabled.

you can just add it here. https://github.com/apache/apisix-helm-chart/blob/7ddeca5395a2de96acd06bada30f3ab3580a6252/charts/apisix/values.yaml#L219-L269

You can also submit a PR directly to fix it

Jintao Zhang
  • 778
  • 5
  • 9