Skip to content

Commit

Permalink
feat (jkube-kit/config) : Support for Startup Probes via XML/DSL conf…
Browse files Browse the repository at this point in the history
…iguration (eclipse-jkube#1322)

Add new startup probe field in resource configuration which should be
available in XML maven plugin configuration/ Groovy DSL configuration in
maven and gradle plugins respectively.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
  • Loading branch information
rohanKanojia committed Apr 21, 2022
1 parent 72bf18b commit 7761690
Show file tree
Hide file tree
Showing 17 changed files with 1,039 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Usage:
* Fix #1310: Add documentation + gradle integration test for ImageChangeTriggerEnricher
* Fix #1311: Add documentation for OpenShift ProjectEnricher
* Fix #1312: Add documentation + gradle integration test for RouteEnricher
* Fix #1322: Support for Startup probes via XML/DSL configuration
* Fix #1325: `jkube.enricher.jkube-name.name` doesn't modify `.metadata.name` for generated manifests
* Fix #1336: Add documentation and quickstart for using custom generators with Gradle Plugins
* Fix #1362: VolumePermissionEnricher : Replace iteration with bulk Collection.addAll call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ kubernetes {
initialDelaySeconds = "3"
timeoutSeconds = "3"
}
volumes = [{ //<7>
startup { //<7>
periodSeconds = 30
failureThreshold = 1
getUrl = "http://:8080/actuator/health"
}
volumes = [{ //<8>
name = "scratch"
type = "emptyDir"
medium = "Memory"
Expand All @@ -243,8 +248,9 @@ kubernetes {
<3> Setting https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod[Security Context] of all application Pods.
<4> Configure how images would be updated. Can be one of `IfNotPresent`, `Always` or `Never`. Read https://kubernetes.io/docs/concepts/containers/images/#updating-images[Kubernetes Images docs] for more details.
<5> Number of replicas of pods we want to have in our application
<6> Define an HTTP liveness request, see https://kubernetes.io/docs/concepts/containers/images/#updating-images[Kubernetes Liveness/Readiness probes] for more details.
<7> Mounting an EmptyDir Volume to your application pods
<6> Define an HTTP liveness request, see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/[Kubernetes Liveness/Readiness probes] for more details.
<7> Define an HTTP startup request, see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/[Kubernetes Startup probes] for more details.
<8> Mounting an EmptyDir Volume to your application pods

See <<controller-resource-groovy-configuration, Kubernetes Controller Configuration>> for more details.

Expand Down
89 changes: 89 additions & 0 deletions gradle-plugin/it/src/it/probes-groovy-dsl-config/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
plugins {
id 'org.springframework.boot' version '2.6.6'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}"
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
id 'java'
}

group = 'org.eclipse.jkube.it.gradle.probes.groovy.dsl'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
}

kubernetes {
offline = true
if (probeConfigMode.contains("liveness-readiness")) {
resources {
liveness {
initialDelaySeconds = 0
timeoutSeconds = 10
periodSeconds = 30
failureThreshold = 1
successThreshold = 1
getUrl = "http://:8080/actuator/health"
httpHeaders = [Accept: "application/json", "User-agent": "MyUserAgent"]
}
readiness {
initialDelaySeconds = 0
timeoutSeconds = 10
periodSeconds = 30
failureThreshold = 1
successThreshold = 1
getUrl = "http://:8080/actuator/health"
httpHeaders = [Accept: "application/json", "User-agent": "MyUserAgent"]
}
}
}
if (probeConfigMode.equals("startup")) {
resources {
startup {
periodSeconds = 30
failureThreshold = 1
getUrl = "http://:8080/actuator/health"
}
}
}
}

openshift {
offline = true
if (probeConfigMode.equals("liveness-readiness")) {
resources {
liveness {
initialDelaySeconds = 0
timeoutSeconds = 10
periodSeconds = 30
failureThreshold = 1
successThreshold = 1
getUrl = "http://:8080/actuator/health"
httpHeaders = [Accept: "application/json", "User-agent": "MyUserAgent"]
}
readiness {
initialDelaySeconds = 0
timeoutSeconds = 10
periodSeconds = 30
failureThreshold = 1
successThreshold = 1
getUrl = "http://:8080/actuator/health"
httpHeaders = [Accept: "application/json", "User-agent": "MyUserAgent"]
}
}
}
if (probeConfigMode.equals("startup")) {
resources {
startup {
periodSeconds = 30
failureThreshold = 1
getUrl = "http://:8080/actuator/health"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/path: /metrics
jkube.io/git-branch: "@ignore@"
prometheus.io/port: "9779"
prometheus.io/scrape: "true"
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
labels:
expose: "true"
app: probes-groovy-dsl-config
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.it.gradle.probes.groovy.dsl
name: probes-groovy-dsl-config
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: probes-groovy-dsl-config
provider: jkube
group: org.eclipse.jkube.it.gradle.probes.groovy.dsl
- apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: probes-groovy-dsl-config
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.it.gradle.probes.groovy.dsl
name: probes-groovy-dsl-config
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: probes-groovy-dsl-config
provider: jkube
group: org.eclipse.jkube.it.gradle.probes.groovy.dsl
template:
metadata:
annotations:
jkube.io/git-url: "@ignore@"
jkube.io/git-commit: "@ignore@"
jkube.io/git-branch: "@ignore@"
labels:
app: probes-groovy-dsl-config
provider: jkube
version: "@ignore@"
group: org.eclipse.jkube.it.gradle.probes.groovy.dsl
name: probes-groovy-dsl-config
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
image: dsl/probes-groovy-dsl-config:latest
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 1
httpGet:
host: ""
httpHeaders:
- name: Accept
value: application/json
- name: User-agent
value: MyUserAgent
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 10
name: spring-boot
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
readinessProbe:
failureThreshold: 1
httpGet:
host: ""
httpHeaders:
- name: Accept
value: application/json
- name: User-agent
value: MyUserAgent
path: /actuator/health
port: 8080
scheme: HTTP
initialDelaySeconds: 0
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 10
securityContext:
privileged: false

0 comments on commit 7761690

Please sign in to comment.