Skip to content
This repository was archived by the owner on Feb 24, 2022. It is now read-only.

Commit fd75054

Browse files
Merge pull request #93 from Web-tree/#91-healthchecks
mystuff-91 Integrate k8s healthcheck with backend
2 parents 0a0c902 + 39d8f3a commit fd75054

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

.kub/mystuff/templates/deployment.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,22 @@ spec:
9393
- name: back
9494
containerPort: 9000
9595
protocol: TCP
96+
readinessProbe:
97+
httpGet:
98+
path: /health
99+
port: 9000
100+
initialDelaySeconds: 40
101+
timeoutSeconds: 2
102+
periodSeconds: 3
103+
failureThreshold: 2
104+
livenessProbe:
105+
httpGet:
106+
path: /health
107+
port: 9000
108+
initialDelaySeconds: 100
109+
timeoutSeconds: 2
110+
periodSeconds: 8
111+
failureThreshold: 1
96112
{{- with .Values.nodeSelector }}
97113
nodeSelector:
98114
{{- toYaml . | nindent 8 }}

back/src/main/java/org/webtree/mystuff/boot/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected void configure(HttpSecurity httpSecurity) throws Exception {
6464
.authorizeRequests()
6565
//.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
6666

67-
.antMatchers("/rest/token/new", "/rest/user/register").permitAll()
67+
.antMatchers("/rest/token/new", "/rest/user/register", "/health").permitAll()
6868
.anyRequest().authenticated();
6969

7070
// Custom JWT based security filter

back/src/test/java/org/webtree/mystuff/controller/SpringActuatorTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
99
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
1010

11-
12-
@WithMockCustomUser
1311
public class SpringActuatorTest extends AbstractControllerTest {
1412

15-
1613
@Test
1714
public void whenGetHealth_shouldReturnUP() throws Exception {
1815
mockMvc.perform(get("/health").contentType(APPLICATION_JSON))

pipeline/jenkins/validate.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pipeline {
4141
label 'mystuff-validate-maven'
4242
containerTemplate {
4343
name 'maven'
44-
image 'maven:3.5.4-jdk-11-slim'
44+
image 'webtree/build-images:maven-jdk-11'
4545
ttyEnabled true
4646
command 'cat'
4747
}
@@ -116,7 +116,6 @@ pipeline {
116116
dir('web') {
117117
script {
118118
withDockerRegistry(credentialsId: 'docker-hub') {
119-
120119
def image = docker.build("webtree/mystuff:${webTag}")
121120
image.push(webTag)
122121
}
@@ -237,8 +236,9 @@ private void deployDevEnv(buildVersion, webTag, backTag, projectName, tier) {
237236
def deployName = "${projectName}-${tier}-${buildVersion}"
238237
def webUrl = "${projectName}-${buildVersion}.dev.webtree.org"
239238
def backUrl = "back.${deployName}.webtree.org"
239+
def pass = sh(script:"head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''", returnStdout: true).trim()
240240
sh "helm delete ${deployName} --purge || true"
241-
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 ."
241+
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 ."
242242
def message = "Test system provisioned on url https://${webUrl}. Backend: https://${backUrl}"
243243
sendPrComment("mystuff", env.CHANGE_ID, message)
244244

@@ -257,4 +257,4 @@ private void sendPrComment(repo, issueId, message) {
257257
url: "https://api.github.com/repos/Web-tree/${repo}/issues/${issueId}/comments",
258258
authentication: 'github-repo-token',
259259
validResponseCodes: '201')
260-
}
260+
}

0 commit comments

Comments
 (0)