Skip to content

Commit 7f9939f

Browse files
authored
Merge pull request #348 from JamesMcNee/kubernetes-client-620
Upgrade to the latest Kubernetes Client
2 parents a74f4a4 + d8b0c4f commit 7f9939f

12 files changed

+114
-52
lines changed

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ apply from: "https://raw.githubusercontent.com/gocd/gocd-plugin-gradle-task-help
2020

2121
gocdPlugin {
2222
id = 'cd.go.contrib.elasticagent.kubernetes'
23-
pluginVersion = '3.8.4'
23+
pluginVersion = '3.9.0'
2424
goCdVersion = '20.9.0'
2525
name = 'Kubernetes Elastic Agent Plugin'
2626
description = 'Kubernetes Based Elastic Agent Plugins for GoCD'
@@ -55,6 +55,7 @@ java {
5555
ext {
5656
deps = [
5757
gocdPluginApi: 'cd.go.plugin:go-plugin-api:23.1.0',
58+
kubernetesClientApi: 'io.fabric8:kubernetes-client-api:6.5.1',
5859
]
5960

6061
versions = project.ext.deps.collectEntries { lib, libGav -> [lib, libGav.split(':').last()] }
@@ -63,7 +64,8 @@ ext {
6364
dependencies {
6465
compileOnly project.deps.gocdPluginApi
6566
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
66-
implementation group: 'io.fabric8', name: 'kubernetes-client', version: '5.12.4'
67+
implementation project.deps.kubernetesClientApi
68+
runtimeOnly group: 'io.fabric8', name: 'kubernetes-client', version: project.versions.kubernetesClientApi
6769
implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.9.10'
6870
implementation group: 'org.freemarker', name: 'freemarker', version: '2.3.32'
6971

src/main/java/cd/go/contrib/elasticagent/KubernetesClientFactory.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package cd.go.contrib.elasticagent;
1818

1919
import io.fabric8.kubernetes.client.ConfigBuilder;
20-
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
2120
import io.fabric8.kubernetes.client.KubernetesClient;
21+
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
2222

2323
import java.util.concurrent.TimeUnit;
2424

@@ -75,12 +75,13 @@ private void clearOutClientOnTimer() {
7575

7676
private KubernetesClient createClientFor(PluginSettings pluginSettings) {
7777
final ConfigBuilder configBuilder = new ConfigBuilder()
78+
.withAutoConfigure(false)
7879
.withOauthToken(pluginSettings.getSecurityToken())
7980
.withMasterUrl(pluginSettings.getClusterUrl())
8081
.withCaCertData(pluginSettings.getCaCertData())
8182
.withNamespace(pluginSettings.getNamespace());
8283

83-
return new DefaultKubernetesClient(configBuilder.build());
84+
return new KubernetesClientBuilder().withConfig(configBuilder.build()).build();
8485
}
8586

8687
public void clearOutExistingClient() {

src/main/java/cd/go/contrib/elasticagent/KubernetesInstanceFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private static void setAnnotations(Pod pod, CreateAgentRequest request) {
148148

149149
private KubernetesInstance createKubernetesPod(KubernetesClient client, Pod elasticAgentPod) {
150150
LOG.info(format("[Create Agent] Creating K8s pod with spec: {0}.", elasticAgentPod.toString()));
151-
Pod pod = client.pods().create(elasticAgentPod);
151+
Pod pod = client.pods().resource(elasticAgentPod).create();
152152
return fromKubernetesPod(pod);
153153
}
154154

src/main/java/cd/go/contrib/elasticagent/model/reports/agent/KubernetesPodDetails.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import static java.text.MessageFormat.format;
1010

1111
public class KubernetesPodDetails {
12+
1213
private String name;
13-
private String clusterName;
1414
private String nodeName;
1515
private String namespace;
1616
private String createdAt;
@@ -24,7 +24,6 @@ public static KubernetesPodDetails fromPod(Pod pod) {
2424
KubernetesPodDetails podDetails = new KubernetesPodDetails();
2525

2626
podDetails.name = pod.getMetadata().getName();
27-
podDetails.clusterName = pod.getMetadata().getClusterName();
2827
podDetails.nodeName = pod.getSpec().getNodeName();
2928
podDetails.namespace = pod.getMetadata().getNamespace();
3029

@@ -50,10 +49,6 @@ public String getName() {
5049
return name;
5150
}
5251

53-
public String getClusterName() {
54-
return clusterName;
55-
}
56-
5752
public String getNodeName() {
5853
return nodeName;
5954
}

src/main/resources/agent-status-report.template.ftlh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,6 @@
355355
<label>Pod name</label>
356356
<span>${ podDetails.name !}</span>
357357
</li>
358-
<li class="name-value_pair">
359-
<label>Cluster Name</label>
360-
<span>${ podDetails.clusterName !}</span>
361-
</li>
362358
<li class="name-value_pair">
363359
<label>Node Name</label>
364360
<span>${ podDetails.nodeName !}</span>

0 commit comments

Comments
 (0)