Hi,
I want to know how can I implement a caching mechanism in which we call a REST API and store the info in a PV. Is there any tool/library for that? The response payload if changes we should know have the new payload inside the PV. Therefore we might think of calling this REST API frequently and update PV.
From PV then the info will be fetched.
Thank you for your hint on this.
I have following two configs for now:
apiVersion: v1
kind: ConfigMap
metadata:
name: caching-config
data:
nginx.conf: |
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m;
server {
listen 8080;
location / {
proxy_pass http://example.com;
proxy_cache my_cache;
proxy_cache_valid 200 304 10m;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
}
}
apiVersion: v1
kind: Pod
metadata:
name: api-pod
spec:
containers:
- name: main-container
image: curlimages/curl:latest
command: ["sh", "-c", "while true; do curl http://example.com; sleep 10; done"]
- name: caching-proxy
image: nginx:latest
volumeMounts:
- name: cache-volume
mountPath: /var/cache/nginx
- name: caching-config
mountPath: /etc/nginx/conf.d
volumes:
- name: cache-volume
emptyDir: {}
- name: caching-config
configMap:
name: caching-config
These are for now my config. By port forward I see that proxy is active. But when I observe the calls to example.com from main container, then it shows headers from its server and not cached one.
How can I fix this in my config? What is missing?