Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
6b2d51f8
Commit
6b2d51f8
authored
3 years ago
by
Sören Henning
Browse files
Options
Downloads
Patches
Plain Diff
Increasing K8s logging
parent
c9ccd41f
No related branches found
No related tags found
3 merge requests
!159
Re-implementation of Theodolite with Kotlin/Quarkus
,
!157
Update Graal Image in CI pipeline
,
!83
WIP: Re-implementation of Theodolite with Kotlin/Quarkus
Pipeline
#2828
passed
3 years ago
Stage: build
Stage: test
Stage: check
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt
+10
-4
10 additions, 4 deletions
...lite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt
with
10 additions
and
4 deletions
theodolite-quarkus/src/main/kotlin/theodolite/k8s/K8sManager.kt
+
10
−
4
View file @
6b2d51f8
...
...
@@ -6,6 +6,9 @@ import io.fabric8.kubernetes.api.model.Service
import
io.fabric8.kubernetes.api.model.apps.Deployment
import
io.fabric8.kubernetes.api.model.apps.StatefulSet
import
io.fabric8.kubernetes.client.NamespacedKubernetesClient
import
mu.KotlinLogging
private
val
logger
=
KotlinLogging
.
logger
{}
/**
* This class is used to deploy or remove different Kubernetes resources.
...
...
@@ -42,7 +45,8 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
is
Deployment
->
{
val
label
=
resource
.
spec
.
selector
.
matchLabels
[
"app"
]
!!
this
.
client
.
apps
().
deployments
().
delete
(
resource
)
blockUntilDeleted
(
label
)
blockUntilPodDeleted
(
label
)
logger
.
info
{
"Deployment '$resource' deleted."
}
}
is
Service
->
this
.
client
.
services
().
delete
(
resource
)
...
...
@@ -51,7 +55,8 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
is
StatefulSet
->
{
val
label
=
resource
.
spec
.
selector
.
matchLabels
[
"app"
]
!!
this
.
client
.
apps
().
statefulSets
().
delete
(
resource
)
blockUntilDeleted
(
label
)
blockUntilPodDeleted
(
label
)
logger
.
info
{
"StatefulSet '$resource' deleted."
}
}
is
ServiceMonitorWrapper
->
resource
.
delete
(
client
)
else
->
throw
IllegalArgumentException
(
"Unknown Kubernetes resource."
)
...
...
@@ -59,13 +64,14 @@ class K8sManager(private val client: NamespacedKubernetesClient) {
}
private
fun
blockUntilDeleted
(
l
abel
:
String
)
{
private
fun
blockUntil
Pod
Deleted
(
podL
abel
:
String
)
{
var
deleted
=
false
do
{
val
pods
=
this
.
client
.
pods
().
withLabel
(
l
abel
).
list
().
items
val
pods
=
this
.
client
.
pods
().
withLabel
(
podL
abel
).
list
().
items
if
(
pods
.
isNullOrEmpty
())
{
deleted
=
true
}
logger
.
info
{
"Wait for pods with label '$podLabel' to be deleted."
}
Thread
.
sleep
(
1000
)
}
while
(!
deleted
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment