I have usecase to have 2 micro services 1st Frontend 2nd Backend where frontend pod is exposed to outer world and rendering page from backend pod
While access the frontend service i am getting 403 error
below are the yaml for respective pods and config map
frontend pod
apiVersion: v1
kind: Pod
metadata:
name: frontend
labels:
run: frontend
spec:
volumes:
- name: webpage
hostPath:
path: /home/vagrant/html
type: Directory
- name: nginx-config-volume
configMap:
name: nginx-config
containers:
- image: nginx
name: frontend
volumeMounts:
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
- name: webpage
mountPath: /var/www/html
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
backend pod
apiVersion: v1
kind: Pod
metadata:
name: backend
labels:
run: backend
spec:
volumes:
- name: webpage
hostPath:
path: /home/vagrant/html
type: Directory
containers:
- image: php:7.2-fpm
name: backend
volumeMounts:
- name: webpage
mountPath: /app
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
operator: Exists
Config Map for Nginx
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
data:
nginx.conf: |
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
# Set nginx to serve files from the shared volume!
root /var/www/html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass backend:9000;
}
}
}
Services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
backend ClusterIP 10.102.90.23 <none> 9000/TCP 60m
frontend NodePort 10.111.88.172 <none> 80:30054/TCP 9h