Skip to content

Commit f7bb6b6

Browse files
committed
add import and secrets chapters
1 parent 35534cc commit f7bb6b6

File tree

6 files changed

+441
-13
lines changed

6 files changed

+441
-13
lines changed

docs/jenkinsx/java-native-prod/02-cloud-sql.md

+5
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ hero: Cloud SQL - 2/8
1515
## How To Connect To The Database
1616

1717
* https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine?hl=en_US
18+
19+
### Create Service Account
20+
21+
### Generate JSON Key
22+

docs/jenkinsx/java-native-prod/04-jx-import.md

+101-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: Jenkins X - Java Native Image Prod
2-
description: Creating a Java Native Image application and run it as Production with Jenkins X - Jenkins X Import - 1/8
2+
description: Creating a Java Native Image application and run it as Production with Jenkins X - Jenkins X Import - 4/8
33
hero: Jenkins X Import - 4/8
44

55
# Jenkins X Import
@@ -77,26 +77,118 @@ CMD ["./application", "-Dquarkus.http.host=0.0.0.0", "-Xmx64m"]
7777

7878
One of the most important aspects of your application running in Kubernetes, is giving Kubernetes enough information about the state of your application. Kubernetes does this via [Liveness and Readiness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/).
7979

80+
### What Are These Probes
81+
8082
If you don't know much about these probes, or want to understand them better, [read the Kubernetes docs](https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/). For the lazy, I've added quotes for this docs page.
8183

8284
> **livenessProbe**: Indicates whether the Container is running. If the liveness probe fails, the kubelet kills the Container, and the Container is subjected to its restart policy. If a Container does not provide a liveness probe, the default state is Success.
8385
8486
> **readinessProbe**: Indicates whether the Container is ready to service requests. If the readiness probe fails, the endpoints controller removes the Pod’s IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay is Failure. If a Container does not provide a readiness probe, the default state is Success.
8587
88+
We recommend servicing each probe with a distinct endpoint if you can.
8689

90+
### Quarkus Health Checks
8791

88-
```xml
89-
<dependency>
90-
<groupId>io.quarkus</groupId>
91-
<artifactId>quarkus-smallrye-health</artifactId>
92-
</dependency>
93-
```
92+
Luckily, Quarkus has a dependency that gives us exactly that: `quarkus-smallrye-health`.
93+
`quarkus-smallrye-health` is an implementation of MicroProfile's Health specification, and they [have a guide on using and extending it](https://quarkus.io/guides/microprofile-health).
94+
95+
For those wanting to skip the line, for the minimal implementation we add one dependency to our `pom.xml`, namely, the mentioned `quarkus-smallrye-health`. This dependency automatically gives us three endpoints for health checks:
9496

9597
* `/health/live`: The application is up and running.
9698
* `/health/ready`: The application is ready to serve requests.
9799
* `/health`: Accumulating all health check procedures in the application.
98100

99-
https://quarkus.io/guides/microprofile-health
100-
101+
### Add Dependency
101102

103+
```xml
104+
<dependency>
105+
<groupId>io.quarkus</groupId>
106+
<artifactId>quarkus-smallrye-health</artifactId>
107+
</dependency>
108+
```
102109

110+
### Update Our Kubernetes Configuration
111+
112+
We now have the ability to give Kubernetes the information it needs to understand the status of our application.
113+
We still have to ensure Kubernetes knows how to get this information.
114+
115+
To do so, we have two choices.
116+
117+
1. Update the `values.yaml` of our Chart, it has one entry for both checks, so not optimal, but minimal effort
118+
1. Update the `templates/deployment.yaml` of our Chart, where we have to set both endpoints
119+
120+
#### Update Values
121+
122+
By default, the Helm chart that is generated has one variable for both the liveness and readyness probes: `probePath`.
123+
124+
The value is specified between `resources` and `livenessProbe`:
125+
126+
We set the value of `probePath` to `/health`:
127+
128+
!!! example "charts/Name-Of-Your-App/values.yaml"
129+
130+
```yaml hl_lines="8"
131+
resources:
132+
limits:
133+
cpu: 250m
134+
memory: 64Mi
135+
requests:
136+
cpu: 250m
137+
memory: 64Mi
138+
probePath: /health
139+
livenessProbe:
140+
initialDelaySeconds: 60
141+
periodSeconds: 10
142+
successThreshold: 1
143+
timeoutSeconds: 1
144+
```
145+
146+
#### Update Deployment
147+
148+
The second way of make the required change, is to update our Deployment definition.
149+
You can choose to set the values directly in the template, or better, change the variables used in the probe paths and set the values of these variables in the `values.yaml`.
150+
151+
We will do the latter here:
152+
153+
!!! example "charts/Name-Of-Your-App/templates/deployment.yaml"
154+
155+
```yaml hl_lines="3 11"
156+
livenessProbe:
157+
httpGet:
158+
path: {{ .Values.livenessProbePath }}
159+
port: {{ .Values.service.internalPort }}
160+
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
161+
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
162+
successThreshold: {{ .Values.livenessProbe.successThreshold }}
163+
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
164+
readinessProbe:
165+
httpGet:
166+
path: {{ .Values.readinessProbePath }}
167+
port: {{ .Values.service.internalPort }}
168+
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
169+
successThreshold: {{ .Values.readinessProbe.successThreshold }}
170+
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
171+
```
172+
173+
!!! example "charts/Name-Of-Your-App/values.yaml"
174+
175+
```yaml hl_lines="8 9"
176+
resources:
177+
limits:
178+
cpu: 250m
179+
memory: 64Mi
180+
requests:
181+
cpu: 250m
182+
memory: 64Mi
183+
livenessProbePath: /health/live
184+
readinessProbePath: /health/ready
185+
livenessProbe:
186+
initialDelaySeconds: 60
187+
periodSeconds: 10
188+
successThreshold: 1
189+
timeoutSeconds: 1
190+
```
191+
192+
## Next Steps
193+
194+
We are going to do a lot more things, but this concludes the initial steps to import our application in Jenkins X. Our application still can't run, because it doesn't have the information to connect to the database. This is our next stop.

0 commit comments

Comments
 (0)