Skip to content

Commit 6ff60b8

Browse files
committed
[PROD-13427][PROD-13433] Update k8s client to 21.0.0
1 parent dd70348 commit 6ff60b8

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ val springOauthVersion = "6.2.2"
161161
val servletApiVersion = "6.0.0"
162162
val oktaSpringBootVersion = "3.0.5"
163163
val tikaVersion = "2.9.1"
164-
val kubernetesClientVersion = "19.0.0"
164+
val kubernetesClientVersion = "21.0.0"
165165
val redisOMVersion = "0.9.1"
166166
val kotlinCoroutinesCoreVersion = "1.7.3"
167167

src/main/kotlin/com/cosmotech/api/utils/KubernetesService.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,19 @@ class KubernetesService(private val kubernetesApi: CoreV1Api?) : SecretManager {
3434
val secretNameLower = secretName.lowercase()
3535
val labelSelector = buildLabelSector(secretNameLower)
3636

37-
val secrets =
38-
api.listNamespacedSecret(
39-
namespace, null, null, null, null, labelSelector, null, null, null, null, null, true)
37+
val secrets = api.listNamespacedSecret(namespace).labelSelector(labelSelector).execute()
4038
if (secrets.items.isEmpty()) {
4139
logger.debug("Secret does not exists in namespace $namespace: cannot delete it")
4240
} else {
4341
logger.info("Secret exists in namespace $namespace: deleting it")
44-
api.deleteNamespacedSecret(secretNameLower, namespace, null, null, null, null, null, null)
42+
api.deleteNamespacedSecret(secretNameLower, namespace).execute()
4543
}
4644
}
4745

4846
private fun getSecretFromKubernetes(namespace: String, secretName: String): Map<String, String> {
4947
val api = checkKubernetesContext()
5048
val secretNameLower = secretName.lowercase()
51-
val result = api.readNamespacedSecret(secretNameLower, namespace, "")
49+
val result = api.readNamespacedSecret(secretNameLower, namespace).execute()
5250

5351
logger.debug("Secret retrieved for namespace $namespace")
5452
return result.data?.mapValues { Base64.getDecoder().decode(it.value).toString(Charsets.UTF_8) }
@@ -76,15 +74,13 @@ class KubernetesService(private val kubernetesApi: CoreV1Api?) : SecretManager {
7674
body.data = secretData.mapValues { Base64.getEncoder().encode(it.value.toByteArray()) }
7775
body.type = "Opaque"
7876

79-
val secrets =
80-
api.listNamespacedSecret(
81-
namespace, null, null, null, null, labelSelector, null, null, null, null, null, true)
77+
val secrets = api.listNamespacedSecret(namespace).labelSelector(labelSelector).execute()
8278
if (secrets.items.isEmpty()) {
8379
logger.debug("Secret does not exists in namespace $namespace: creating it")
84-
api.createNamespacedSecret(namespace, body, null, null, null, null)
80+
api.createNamespacedSecret(namespace, body).execute()
8581
} else {
8682
logger.debug("Secret already exists in namespace $namespace: replacing it")
87-
api.replaceNamespacedSecret(secretNameLower, namespace, body, null, null, null, null)
83+
api.replaceNamespacedSecret(secretNameLower, namespace, body).execute()
8884
}
8985
logger.info("Secret created/replaced")
9086
}

0 commit comments

Comments
 (0)