diff --git a/deployment_manifest.json b/deployment_manifest.json index 359d33a0..7bc918a5 100644 --- a/deployment_manifest.json +++ b/deployment_manifest.json @@ -37,7 +37,29 @@ "endpoint": "$SERVICE_ENDPOINT" } ], - "allowEgress": [] + "allowEgress": [], + "healthChecks": { + "readinessCheck": { + "type": "http", + "port": "serviceport", + "path": "/health", + "successThreshold": 1, + "initialDelaySeconds": 90, + "periodSeconds": 30, + "failureThreshold": 3, + "httpHeaders": [] + }, + "livenessCheck": { + "type": "http", + "port": "metrics", + "path": "/actuator/health", + "successThreshold": 1, + "initialDelaySeconds": 90, + "periodSeconds": 30, + "failureThreshold": 3, + "httpHeaders": [] + } + } }, "extraResources": { "environment": "$ENVIRONMENT", diff --git a/docker-compose.yml b/docker-compose.yml index 64fb016d..819bdcd1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,8 @@ services: depends_on: - postgres ports: - - 9090:9090 + - 8090:8080 + - 4001:4001 deployment_portal_frontend_service: build: ../deployment-portal-frontend diff --git a/pom.xml b/pom.xml index 424fb2e7..a478680d 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,32 @@ json-schema-validator 2.2.6 + + org.springframework.boot + spring-boot-starter-actuator + 2.2.4.RELEASE + + + io.micrometer + micrometer-core + 1.3.3 + + + io.micrometer + micrometer-registry-prometheus + 1.3.2 + + + lombok + org.projectlombok + true + + + + logstash-logback-encoder + net.logstash.logback + 6.2 + com.github.fge @@ -108,11 +134,6 @@ test - - org.springframework.boot - spring-boot-starter-security - - diff --git a/src/main/java/com/DeploymentPortal/api/LoginController.java b/src/main/java/com/DeploymentPortal/api/LoginController.java new file mode 100644 index 00000000..9f776c7e --- /dev/null +++ b/src/main/java/com/DeploymentPortal/api/LoginController.java @@ -0,0 +1,16 @@ +package com.DeploymentPortal.api; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@Slf4j +@RestController +public class LoginController { + + @GetMapping("/health") + public String health() { + log.info("Status is healthy"); + return "Healthy"; + } +} \ No newline at end of file diff --git a/src/main/java/com/DeploymentPortal/api/OktaOAuth2WebSecurityConfigurerAdapter.java b/src/main/java/com/DeploymentPortal/api/OktaOAuth2WebSecurityConfigurerAdapter.java index 3ce9b5e7..8992b43e 100644 --- a/src/main/java/com/DeploymentPortal/api/OktaOAuth2WebSecurityConfigurerAdapter.java +++ b/src/main/java/com/DeploymentPortal/api/OktaOAuth2WebSecurityConfigurerAdapter.java @@ -22,13 +22,11 @@ class OktaOAuth2WebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapte @Override protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable() - .cors() - .and() - .authorizeRequests() - .anyRequest().authenticated() - .and() - .oauth2ResourceServer().jwt(); + http.csrf().disable().cors() + .and().authorizeRequests() + .mvcMatchers("/actuator","/actuator/*","/health") + .permitAll() + .anyRequest().authenticated(); } } diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 125c02f4..18a754b8 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -7,7 +7,14 @@ spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true -server.port=9090 +server.port=8080 #security.oauth2.resource.jwk.key-set-uri=https://btech-christuniversity.okta.com/oauth2/v1/keys spring.main.allow.bean-definition-overriding=true -#okta.oauth2.localTokenValidation=false \ No newline at end of file +#okta.oauth2.localTokenValidation=false + +#Metrics related configurations +management.endpoint.metrics.enabled=true +management.endpoints.web.exposure.include=* +management.endpoint.prometheus.enabled=true +management.metrics.export.prometheus.enabled=true +management.server.port=4001 \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index dfa156c4..27faeeed 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -7,11 +7,18 @@ spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true -server.port=9090 +server.port=8080 #spring.main.allow.bean-definition-overriding=true #security.oauth2.resource.jwk.key-set-uri=https://btech-christuniversity.okta.com/oauth2/v1/keys #okta.oauth2.audience=http://localhost:8080 #okta.oauth2.groups-claim=groups #okta.oauth2.redirect-uri=/authorization-code/callback -#okta.oauth2.localTokenValidation=false \ No newline at end of file +#okta.oauth2.localTokenValidation=false + +#Metrics related configurations +management.endpoint.metrics.enabled=true +management.endpoints.web.exposure.include=* +management.endpoint.prometheus.enabled=true +management.metrics.export.prometheus.enabled=true +management.server.port=4001 \ No newline at end of file