-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
KubernetesCloud.java
649 lines (559 loc) · 23.9 KB
/
KubernetesCloud.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
package org.csanchez.jenkins.plugins.kubernetes;
import static java.nio.charset.StandardCharsets.*;
import java.io.IOException;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateEncodingException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.ServletException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.plaincredentials.StringCredentials;
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.QueryParameter;
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCertificateCredentials;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateMap;
import hudson.Extension;
import hudson.Util;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
import hudson.model.Computer;
import hudson.model.Descriptor;
import hudson.model.Label;
import hudson.model.Node;
import hudson.model.labels.LabelAtom;
import hudson.security.ACL;
import hudson.slaves.Cloud;
import hudson.slaves.NodeProvisioner;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.PodList;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientException;
import jenkins.model.Jenkins;
import jenkins.model.JenkinsLocationConfiguration;
/**
* Kubernetes cloud provider.
*
* Starts agents in a Kubernetes cluster using defined Docker templates for each label.
*
* @author Carlos Sanchez carlos@apache.org
*/
public class KubernetesCloud extends Cloud {
public static final int DEFAULT_MAX_REQUESTS_PER_HOST = 32;
private static final Logger LOGGER = Logger.getLogger(KubernetesCloud.class.getName());
private static final String DEFAULT_ID = "jenkins/slave-default";
public static final String JNLP_NAME = "jnlp";
/** label for all pods started by the plugin */
@Deprecated
public static final Map<String, String> DEFAULT_POD_LABELS = ImmutableMap.of("jenkins", "slave");
/** Default timeout for idle workers that don't correctly indicate exit. */
private static final int DEFAULT_RETENTION_TIMEOUT_MINUTES = 5;
private String defaultsProviderTemplate;
@Nonnull
private List<PodTemplate> templates = new ArrayList<>();
private String serverUrl;
@CheckForNull
private String serverCertificate;
private boolean skipTlsVerify;
private String namespace;
private String jenkinsUrl;
@CheckForNull
private String jenkinsTunnel;
@CheckForNull
private String credentialsId;
private int containerCap = Integer.MAX_VALUE;
private int retentionTimeout = DEFAULT_RETENTION_TIMEOUT_MINUTES;
private int connectTimeout;
private int readTimeout;
private Map<String, String> labels;
private transient KubernetesClient client;
private int maxRequestsPerHost;
@DataBoundConstructor
public KubernetesCloud(String name) {
super(name);
}
/**
* Copy constructor.
* Allows to create copies of the original kubernetes cloud. Since it's a singleton
* by design, this method also allows specifying a new name.
* @param name Name of the cloud to be created
* @param source Source Kubernetes cloud implementation
* @since 0.13
*/
public KubernetesCloud(@NonNull String name, @NonNull KubernetesCloud source) {
super(name);
this.defaultsProviderTemplate = source.defaultsProviderTemplate;
this.templates.addAll(source.templates);
this.serverUrl = source.serverUrl;
this.skipTlsVerify = source.skipTlsVerify;
this.namespace = source.namespace;
this.jenkinsUrl = source.jenkinsUrl;
this.jenkinsTunnel = source.jenkinsTunnel;
this.credentialsId = source.credentialsId;
this.containerCap = source.containerCap;
this.retentionTimeout = source.retentionTimeout;
this.connectTimeout = source.connectTimeout;
}
@Deprecated
public KubernetesCloud(String name, List<? extends PodTemplate> templates, String serverUrl, String namespace,
String jenkinsUrl, String containerCapStr, int connectTimeout, int readTimeout, int retentionTimeout) {
this(name);
setServerUrl(serverUrl);
setNamespace(namespace);
setJenkinsUrl(jenkinsUrl);
if (templates != null) {
this.templates.addAll(templates);
}
setContainerCapStr(containerCapStr);
setRetentionTimeout(retentionTimeout);
setConnectTimeout(connectTimeout);
setReadTimeout(readTimeout);
}
public int getRetentionTimeout() {
return retentionTimeout;
}
@DataBoundSetter
public void setRetentionTimeout(int retentionTimeout) {
this.retentionTimeout = retentionTimeout;
}
public String getDefaultsProviderTemplate() {
return defaultsProviderTemplate;
}
@DataBoundSetter
public void setDefaultsProviderTemplate(String defaultsProviderTemplate) {
this.defaultsProviderTemplate = defaultsProviderTemplate;
}
@Nonnull
public List<PodTemplate> getTemplates() {
return templates;
}
/**
* Returns all pod templates for this cloud including the dynamic ones.
* @return all pod templates for this cloud including the dynamic ones.
*/
@Nonnull
public List<PodTemplate> getAllTemplates() {
return PodTemplateSource.getAll(this);
}
@DataBoundSetter
public void setTemplates(@Nonnull List<PodTemplate> templates) {
this.templates = new ArrayList<>(templates);
}
public String getServerUrl() {
return serverUrl;
}
@DataBoundSetter
public void setServerUrl(@Nonnull String serverUrl) {
this.serverUrl = serverUrl;
}
public String getServerCertificate() {
return serverCertificate;
}
@DataBoundSetter
public void setServerCertificate(String serverCertificate) {
this.serverCertificate = Util.fixEmpty(serverCertificate);
}
public boolean isSkipTlsVerify() {
return skipTlsVerify;
}
@DataBoundSetter
public void setSkipTlsVerify(boolean skipTlsVerify) {
this.skipTlsVerify = skipTlsVerify;
}
@Nonnull
public String getNamespace() {
return namespace;
}
@DataBoundSetter
public void setNamespace(@Nonnull String namespace) {
Preconditions.checkArgument(!StringUtils.isBlank(namespace));
this.namespace = namespace;
}
@CheckForNull
public String getJenkinsUrl() {
return jenkinsUrl;
}
/**
* Returns Jenkins URL to be used by agents launched by this cloud. Always ends with a trailing slash.
*
* Uses in order:
* * cloud configuration
* * environment variable <b>KUBERNETES_JENKINS_URL</b>
* * Jenkins Location URL
*
* @return Jenkins URL to be used by agents launched by this cloud. Always ends with a trailing slash.
* @throws IllegalStateException if no Jenkins URL could be computed.
*/
@Nonnull
public String getJenkinsUrlOrDie() {
JenkinsLocationConfiguration locationConfiguration = JenkinsLocationConfiguration.get();
String locationConfigurationUrl = locationConfiguration != null ? locationConfiguration.getUrl() : null;
String url = StringUtils.defaultIfBlank(
getJenkinsUrl(),
StringUtils.defaultIfBlank(
System.getProperty("KUBERNETES_JENKINS_URL",System.getenv("KUBERNETES_JENKINS_URL")),
locationConfigurationUrl
)
);
if (url == null) {
throw new IllegalStateException("Jenkins URL for Kubernetes is null");
}
url = url.endsWith("/") ? url : url + "/";
return url;
}
@DataBoundSetter
public void setJenkinsUrl(String jenkinsUrl) {
this.jenkinsUrl = Util.fixEmptyAndTrim(jenkinsUrl);
}
public String getJenkinsTunnel() {
return jenkinsTunnel;
}
@DataBoundSetter
public void setJenkinsTunnel(String jenkinsTunnel) {
this.jenkinsTunnel = Util.fixEmpty(jenkinsTunnel);
}
public String getCredentialsId() {
return credentialsId;
}
@DataBoundSetter
public void setCredentialsId(String credentialsId) {
this.credentialsId = Util.fixEmpty(credentialsId);
}
public int getContainerCap() {
return containerCap;
}
@DataBoundSetter
public void setContainerCapStr(String containerCapStr) {
if (containerCapStr.equals("")) {
this.containerCap = Integer.MAX_VALUE;
} else {
this.containerCap = Integer.parseInt(containerCapStr);
}
}
public String getContainerCapStr() {
if (containerCap == Integer.MAX_VALUE) {
return "";
} else {
return String.valueOf(containerCap);
}
}
public int getReadTimeout() {
return readTimeout;
}
public void setReadTimeout(int readTimeout) {
this.readTimeout = readTimeout;
}
public int getConnectTimeout() {
return connectTimeout;
}
/**
* Labels for all pods started by the plugin
*/
public Map<String, String> getLabels() {
return labels == null ? Collections.emptyMap() : labels;
}
public void setLabels(Map<String, String> labels) {
this.labels = labels;
}
@DataBoundSetter
public void setMaxRequestsPerHostStr(String maxRequestsPerHostStr) {
try {
this.maxRequestsPerHost = Integer.parseInt(maxRequestsPerHostStr);
} catch (NumberFormatException e) {
maxRequestsPerHost = DEFAULT_MAX_REQUESTS_PER_HOST;
}
}
public String getMaxRequestsPerHostStr() {
return String.valueOf(maxRequestsPerHost);
}
public void setConnectTimeout(int connectTimeout) {
this.connectTimeout = connectTimeout;
}
/**
* Connects to Kubernetes.
*
* @return Kubernetes client.
*/
@SuppressFBWarnings({ "IS2_INCONSISTENT_SYNC", "DC_DOUBLECHECK" })
public KubernetesClient connect() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException,
IOException, CertificateEncodingException {
LOGGER.log(Level.FINE, "Building connection to Kubernetes {0} URL {1} namespace {2}",
new String[] { getDisplayName(), serverUrl, namespace });
client = new KubernetesFactoryAdapter(serverUrl, namespace, serverCertificate, credentialsId, skipTlsVerify,
connectTimeout, readTimeout, maxRequestsPerHost).createClient();
LOGGER.log(Level.FINE, "Connected to Kubernetes {0} URL {1}", new String[] { getDisplayName(), serverUrl });
return client;
}
private String getIdForLabel(Label label) {
if (label == null) {
return DEFAULT_ID;
}
return "jenkins/" + label.getName();
}
Map<String, String> getLabelsMap(Set<LabelAtom> labelSet) {
ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String> builder();
builder.putAll(getLabels());
if (!labelSet.isEmpty()) {
for (LabelAtom label: labelSet) {
builder.put(getIdForLabel(label), "true");
}
}
return builder.build();
}
@Override
public synchronized Collection<NodeProvisioner.PlannedNode> provision(@CheckForNull final Label label, final int excessWorkload) {
try {
Set<String> allInProvisioning = InProvisioning.getAllInProvisioning(label);
LOGGER.log(Level.FINE, () -> "In provisioning : " + allInProvisioning);
int toBeProvisioned = Math.max(0, excessWorkload - allInProvisioning.size());
LOGGER.log(Level.INFO, "Excess workload after pending Kubernetes agents: " + toBeProvisioned);
List<NodeProvisioner.PlannedNode> r = new ArrayList<NodeProvisioner.PlannedNode>();
for (PodTemplate t: getTemplatesFor(label)) {
LOGGER.log(Level.INFO, "Template: " + t.getDisplayName());
for (int i = 1; i <= toBeProvisioned; i++) {
if (!addProvisionedSlave(t, label)) {
break;
}
r.add(new NodeProvisioner.PlannedNode(t.getDisplayName(), Computer.threadPoolForRemoting
.submit(new ProvisioningCallback(this, t, label)), 1));
}
if (r.size() > 0) {
// Already found a matching template
return r;
}
}
return r;
} catch (KubernetesClientException e) {
Throwable cause = e.getCause();
if (cause instanceof SocketTimeoutException || cause instanceof ConnectException || cause instanceof UnknownHostException) {
LOGGER.log(Level.WARNING, "Failed to connect to Kubernetes at {0}: {1}",
new String[] { serverUrl, cause.getMessage() });
} else {
LOGGER.log(Level.WARNING, "Failed to count the # of live instances on Kubernetes",
cause != null ? cause : e);
}
} catch (ConnectException e) {
LOGGER.log(Level.WARNING, "Failed to connect to Kubernetes at {0}", serverUrl);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Failed to count the # of live instances on Kubernetes", e);
}
return Collections.emptyList();
}
/**
* Check not too many already running.
*
*/
private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull Label label) throws Exception {
if (containerCap == 0) {
return true;
}
KubernetesClient client = connect();
String templateNamespace = template.getNamespace();
// If template's namespace is not defined, take the
// Kubernetes Namespace.
if (Strings.isNullOrEmpty(templateNamespace)) {
templateNamespace = client.getNamespace();
}
PodList slaveList = client.pods().inNamespace(templateNamespace).withLabels(getLabels()).list();
List<Pod> slaveListItems = slaveList.getItems();
Map<String, String> labelsMap = getLabelsMap(template.getLabelSet());
PodList namedList = client.pods().inNamespace(templateNamespace).withLabels(labelsMap).list();
List<Pod> namedListItems = namedList.getItems();
if (slaveListItems != null && containerCap <= slaveListItems.size()) {
LOGGER.log(Level.INFO,
"Total container cap of {0} reached, not provisioning: {1} running or errored in namespace {2} with Kubernetes labels {3}",
new Object[] { containerCap, slaveListItems.size(), client.getNamespace(), getLabels() });
return false;
}
if (namedListItems != null && slaveListItems != null && template.getInstanceCap() <= namedListItems.size()) {
LOGGER.log(Level.INFO,
"Template instance cap of {0} reached for template {1}, not provisioning: {2} running or errored in namespace {3} with label \"{4}\" and Kubernetes labels {5}",
new Object[] { template.getInstanceCap(), template.getName(), slaveListItems.size(),
client.getNamespace(), label == null ? "" : label.toString(), labelsMap });
return false; // maxed out
}
return true;
}
@Override
public boolean canProvision(@CheckForNull Label label) {
return getTemplate(label) != null;
}
/**
* Gets {@link PodTemplate} that has the matching {@link Label}.
* @param label label to look for in templates
* @return the template
*/
public PodTemplate getTemplate(@CheckForNull Label label) {
return PodTemplateUtils.getTemplateByLabel(label, getAllTemplates());
}
/**
* Gets all PodTemplates that have the matching {@link Label}.
* @param label label to look for in templates
* @return list of matching templates
* @deprecated Use {@link #getTemplatesFor(Label)} instead.
*/
@Deprecated
public ArrayList<PodTemplate> getMatchingTemplates(@CheckForNull Label label) {
return new ArrayList<>(getTemplatesFor(label));
}
/**
* Gets all PodTemplates that have the matching {@link Label}.
* @param label label to look for in templates
* @return list of matching templates
*/
public List<PodTemplate> getTemplatesFor(@CheckForNull Label label) {
return PodTemplateFilter.applyAll(this, getAllTemplates(), label);
}
/**
* Add a new template to the cloud
* @param t docker template
*/
public void addTemplate(PodTemplate t) {
this.templates.add(t);
// t.parent = this;
}
/**
* Remove a
*
* @param t docker template
*/
public void removeTemplate(PodTemplate t) {
this.templates.remove(t);
}
/**
* Add a dynamic pod template. Won't be displayed in UI, and persisted separately from the cloud instance.
* @param t the template to add
*/
public void addDynamicTemplate(PodTemplate t) {
PodTemplateMap.get().addTemplate(this, t);
}
/**
* Remove a dynamic pod template.
* @param t the template to remove
*/
public void removeDynamicTemplate(PodTemplate t) {
PodTemplateMap.get().removeTemplate(this, t);
}
@Extension
public static class DescriptorImpl extends Descriptor<Cloud> {
@Override
public String getDisplayName() {
return "Kubernetes";
}
@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void addAliases() {
Jenkins.XSTREAM2.addCompatibilityAlias(
"org.csanchez.jenkins.plugins.kubernetes.OpenShiftBearerTokenCredentialImpl",
org.jenkinsci.plugins.kubernetes.credentials.OpenShiftBearerTokenCredentialImpl.class);
Jenkins.XSTREAM2.addCompatibilityAlias(
"org.csanchez.jenkins.plugins.kubernetes.OpenShiftTokenCredentialImpl",
StringCredentialsImpl.class);
Jenkins.XSTREAM2.addCompatibilityAlias("org.csanchez.jenkins.plugins.kubernetes.ServiceAccountCredential",
org.jenkinsci.plugins.kubernetes.credentials.FileSystemServiceAccountCredential.class);
}
public FormValidation doTestConnection(@QueryParameter String name, @QueryParameter String serverUrl, @QueryParameter String credentialsId,
@QueryParameter String serverCertificate,
@QueryParameter boolean skipTlsVerify,
@QueryParameter String namespace,
@QueryParameter int connectionTimeout,
@QueryParameter int readTimeout) throws Exception {
if (StringUtils.isBlank(name))
return FormValidation.error("name is required");
try {
KubernetesClient client = new KubernetesFactoryAdapter(serverUrl, namespace,
Util.fixEmpty(serverCertificate), Util.fixEmpty(credentialsId), skipTlsVerify,
connectionTimeout, readTimeout).createClient();
// test listing pods
client.pods().list();
return FormValidation.ok("Connection test successful");
} catch (KubernetesClientException e) {
LOGGER.log(Level.FINE, String.format("Error testing connection %s", serverUrl), e);
return FormValidation.error("Error testing connection %s: %s", serverUrl, e.getCause() == null
? e.getMessage()
: String.format("%s: %s", e.getCause().getClass().getName(), e.getCause().getMessage()));
} catch (Exception e) {
LOGGER.log(Level.FINE, String.format("Error testing connection %s", serverUrl), e);
return FormValidation.error("Error testing connection %s: %s", serverUrl, e.getMessage());
}
}
public ListBoxModel doFillCredentialsIdItems(@QueryParameter String serverUrl) {
return new StandardListBoxModel().withEmptySelection() //
.withMatching( //
CredentialsMatchers.anyOf(
CredentialsMatchers.instanceOf(StandardUsernamePasswordCredentials.class),
CredentialsMatchers.instanceOf(TokenProducer.class),
CredentialsMatchers.instanceOf(
org.jenkinsci.plugins.kubernetes.credentials.TokenProducer.class),
CredentialsMatchers.instanceOf(StandardCertificateCredentials.class),
CredentialsMatchers.instanceOf(StringCredentials.class)), //
CredentialsProvider.lookupCredentials(StandardCredentials.class, //
Jenkins.getInstance(), //
ACL.SYSTEM, //
serverUrl != null ? URIRequirementBuilder.fromUri(serverUrl).build()
: Collections.EMPTY_LIST //
));
}
public FormValidation doCheckMaxRequestsPerHostStr(@QueryParameter String value) throws IOException, ServletException {
try {
Integer.parseInt(value);
return FormValidation.ok();
} catch (NumberFormatException e) {
return FormValidation.error("Please supply an integer");
}
}
}
@Override
public String toString() {
return String.format("KubernetesCloud name: %s serverUrl: %s", name, serverUrl);
}
private Object readResolve() {
if ((serverCertificate != null) && !serverCertificate.trim().startsWith("-----BEGIN CERTIFICATE-----")) {
serverCertificate = new String(Base64.decodeBase64(serverCertificate.getBytes(UTF_8)), UTF_8);
LOGGER.log(Level.INFO, "Upgraded Kubernetes server certificate key: {0}",
serverCertificate.substring(0, 80));
}
if (maxRequestsPerHost == 0) {
maxRequestsPerHost = DEFAULT_MAX_REQUESTS_PER_HOST;
}
if (labels == null) {
labels = DEFAULT_POD_LABELS;
}
return this;
}
@Extension
public static class PodTemplateSourceImpl extends PodTemplateSource {
@Nonnull
@Override
public List<PodTemplate> getList(@Nonnull KubernetesCloud cloud) {
return cloud.getTemplates();
}
}
}