diff --git a/kubernetes/nodeport.yaml b/kubernetes/nodeport.yaml new file mode 100644 index 0000000..ccf291e --- /dev/null +++ b/kubernetes/nodeport.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: nodejs-service +spec: + selector: + app: nodejs + ports: + - protocol: TCP + port: 3000 # Port exposed by the Service + targetPort: 3000 # Port that the application is listening on inside the Pods + nodePort: 30000 # Port exposed on all nodes in the cluster + type: NodePort diff --git a/kubernetes/prometheus_config.yml b/kubernetes/prometheus_config.yml new file mode 100644 index 0000000..d23f1ff --- /dev/null +++ b/kubernetes/prometheus_config.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-config +data: + prometheus.yml: | + global: + scrape_interval: 15s + + scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: ['localhost:9090'] # Prometheus self-monitoring + + - job_name: 'nodejs-app' + static_configs: + - targets: ['nodejs-service.default.svc.cluster.local:3000'] # Service endpoint for the Node.js application diff --git a/kubernetes/prometheus_service.yml b/kubernetes/prometheus_service.yml new file mode 100644 index 0000000..4211baa --- /dev/null +++ b/kubernetes/prometheus_service.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: prometheus-service +spec: + selector: + app: prometheus + ports: + - protocol: TCP + port: 9090 # Port exposed by the Service + targetPort: 9090 # Port that Prometheus is listening on inside the Pods + type: ClusterIP