NandanSatheeshJupiter commented on issue #12150:
URL: https://github.com/apache/apisix/issues/12150#issuecomment-2811998656
Thanks for the reply @mikyll
I tried the above steps. Adding the YML - Not seeing any log printed.
```
apiVersion: v1
kind: Namespace
metadata:
name: apisix
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apisix-config
namespace: apisix
data:
config.yaml: |
apisix:
node_listen: 9080
enable_admin_cors: true
admin_key:
- name: "admin"
key: edd1c9f034335f136f87ad84b625c8f1
role: admin
deployment:
role: data_plane
role_data_plane:
config_provider: yaml
logger:
level: "info"
plugins:
- log
- jwt-auth-headers
- serverless-pre-function
- grpc-transcode
- limit-req
- limit-count
- proxy-rewrite
- ip-restriction
- response-rewrite
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apisix-routes
namespace: apisix
data:
apisix.yaml: |
routes:
- id: 100
uri: /health
plugins:
log:
serverless-pre-function:
phase: access
functions:
- |
return function(conf, ctx)
ngx.say('APISIX is healthy')
ngx.exit(200)
end
- id: 1
uri: /hello
upstream:
type: roundrobin
nodes:
"127.0.0.1:8080": 1
plugins:
jwt-auth-headers:
header: Authorization
query: token
cookie: jwt
hide_credentials: true
clock_skew: 60
claims_to_headers:
key: X-User-Id
username: X-User-Role
iss: X-User-Email
response-rewrite:
headers:
set:
X-Config-Version: "v1"
body: "Hello from APISIX v1\n"
#END
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apisix
namespace: apisix
annotations:
reloader.stakater.com/auto: "true"
configmap.reloader.stakater.com/reload: "apisix-config,apisix-routes"
spec:
replicas: 1
selector:
matchLabels:
app: apisix
template:
metadata:
labels:
app: apisix
spec:
containers:
- name: apisix
image: apache/apisix:3.12.0-debian
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 500m
memory: 1Gi
ports:
- containerPort: 9080
name: http
- containerPort: 9443
name: https
- containerPort: 9180
name: admin
livenessProbe:
httpGet:
path: /health
port: 9080
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 9080
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
volumeMounts:
- name: config
mountPath: /usr/local/apisix/conf/config.yaml
subPath: config.yaml
- name: routes
mountPath: /usr/local/apisix/conf/apisix.yaml
subPath: apisix.yaml
- name: custom-plugin-log
mountPath: /usr/local/apisix/apisix/plugins/log.lua
subPath: log.lua
volumes:
- name: config
configMap:
name: apisix-config
- name: routes
configMap:
name: apisix-routes
- name: custom-plugin-log
configMap:
name: apisix-custom-plugin-log
---
apiVersion: v1
kind: Service
metadata:
name: apisix
namespace: apisix
spec:
type: NodePort
ports:
- port: 80
targetPort: 9080
name: http
- port: 9180
targetPort: 9180
name: admin
selector:
app: apisix
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: hpa
namespace: apisix
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: apisix
maxReplicas: 10
minReplicas: 2
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 75
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 75
behavior:
scaleDown:
stabilizationWindowSeconds: 120
policies:
- type: Pods
value: 1
periodSeconds: 30
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apisix-custom-plugin-log
namespace: apisix
data:
log.lua: |
local core = require("apisix.core")
local plugin_name = "log"
local _M = {
version = 0.1,
priority = 0,
name = plugin_name,
}
_M.schema = {
type = "object",
properties = {},
}
function _M.access(conf, ctx)
core.log.info("log plugin triggered!")
end
return _M
---
```
Only once this is successful, I can try another custom plugin
jwt-auth-headers.
Logs from APISIX -
```
127.0.0.1 - - [17/Apr/2025:07:05:58 +0000] localhost:49203 "GET /health
HTTP/1.1" 200 29 0.000 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36" - - -
"http://localhost:49203"
```
TIA.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]