diff --git a/.kub/mystuff/templates/deployment.yaml b/.kub/mystuff/templates/deployment.yaml index b178b46..afdd594 100644 --- a/.kub/mystuff/templates/deployment.yaml +++ b/.kub/mystuff/templates/deployment.yaml @@ -93,6 +93,22 @@ spec: - name: back containerPort: 9000 protocol: TCP + readinessProbe: + httpGet: + path: /health + port: 9000 + initialDelaySeconds: 40 + timeoutSeconds: 2 + periodSeconds: 3 + failureThreshold: 2 + livenessProbe: + httpGet: + path: /health + port: 9000 + initialDelaySeconds: 100 + timeoutSeconds: 2 + periodSeconds: 8 + failureThreshold: 1 {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/back/src/main/java/org/webtree/mystuff/boot/SecurityConfig.java b/back/src/main/java/org/webtree/mystuff/boot/SecurityConfig.java index d0f4bf6..185d228 100644 --- a/back/src/main/java/org/webtree/mystuff/boot/SecurityConfig.java +++ b/back/src/main/java/org/webtree/mystuff/boot/SecurityConfig.java @@ -64,7 +64,7 @@ protected void configure(HttpSecurity httpSecurity) throws Exception { .authorizeRequests() //.antMatchers(HttpMethod.OPTIONS, "/**").permitAll() - .antMatchers("/rest/token/new", "/rest/user/register").permitAll() + .antMatchers("/rest/token/new", "/rest/user/register", "/health").permitAll() .anyRequest().authenticated(); // Custom JWT based security filter diff --git a/back/src/test/java/org/webtree/mystuff/controller/SpringActuatorTest.java b/back/src/test/java/org/webtree/mystuff/controller/SpringActuatorTest.java index fca47f6..11018d4 100644 --- a/back/src/test/java/org/webtree/mystuff/controller/SpringActuatorTest.java +++ b/back/src/test/java/org/webtree/mystuff/controller/SpringActuatorTest.java @@ -8,11 +8,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@WithMockCustomUser public class SpringActuatorTest extends AbstractControllerTest { - @Test public void whenGetHealth_shouldReturnUP() throws Exception { mockMvc.perform(get("/health").contentType(APPLICATION_JSON)) diff --git a/pipeline/jenkins/validate.groovy b/pipeline/jenkins/validate.groovy index 1a52e3e..9a91ff5 100644 --- a/pipeline/jenkins/validate.groovy +++ b/pipeline/jenkins/validate.groovy @@ -41,7 +41,7 @@ pipeline { label 'mystuff-validate-maven' containerTemplate { name 'maven' - image 'maven:3.5.4-jdk-11-slim' + image 'webtree/build-images:maven-jdk-11' ttyEnabled true command 'cat' } @@ -116,7 +116,6 @@ pipeline { dir('web') { script { withDockerRegistry(credentialsId: 'docker-hub') { - def image = docker.build("webtree/mystuff:${webTag}") image.push(webTag) } @@ -237,8 +236,9 @@ private void deployDevEnv(buildVersion, webTag, backTag, projectName, tier) { def deployName = "${projectName}-${tier}-${buildVersion}" def webUrl = "${projectName}-${buildVersion}.dev.webtree.org" def backUrl = "back.${deployName}.webtree.org" + def pass = sh(script:"head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''", returnStdout: true).trim() sh "helm delete ${deployName} --purge || true" - sh "helm install --wait --name=${deployName} --namespace=webtree-${tier} --set nameOverride=${deployName},ingress.web.host=${webUrl},ingress.back.host=${backUrl},images.web.tag=${webTag},images.back.tag=${backTag} -f values.${tier}.yaml ." + sh "helm install --wait --name=${deployName} --namespace=webtree-${tier} --set nameOverride=${deployName},ingress.web.host=${webUrl},ingress.back.host=${backUrl},images.web.tag=${webTag},images.back.tag=${backTag},neo4j.neo4jPassword=${pass} -f values.${tier}.yaml ." def message = "Test system provisioned on url https://${webUrl}. Backend: https://${backUrl}" sendPrComment("mystuff", env.CHANGE_ID, message) @@ -257,4 +257,4 @@ private void sendPrComment(repo, issueId, message) { url: "https://api.github.com/repos/Web-tree/${repo}/issues/${issueId}/comments", authentication: 'github-repo-token', validResponseCodes: '201') -} \ No newline at end of file +}