-
大小: 5.09MB文件類型: .zip金幣: 2下載: 0 次發(fā)布日期: 2023-11-14
- 語言: 其他
- 標簽:
資源簡介
kubernetes-in-action書籍的各個章節(jié)的代碼示例,防止手敲產(chǎn)生錯誤,直接打開對應(yīng)章節(jié)復(fù)制代碼即可。

代碼片段和文件信息
package?kubia;
import?io.fabric8.kubernetes.api.model.Pod;
import?io.fabric8.kubernetes.api.model.PodList;
import?io.fabric8.kubernetes.client.DefaultKubernetesClient;
import?io.fabric8.kubernetes.client.KubernetesClient;
import?java.util.Arrays;
public?class?Fabric8ClientTest?{
????public?static?void?main(String[]?args)?throws?Exception?{
????????KubernetesClient?client?=?new?DefaultKubernetesClient();
????????
????????//?list?pods?in?the?default?namespace
????????PodList?pods?=?client.pods().inNamespace(“default“).list();
????????pods.getItems().stream().forEach(s?->?System.out.println(“Found?pod:?“?+?s.getmetadata().getName()));
????????
????????//?create?a?pod
????????System.out.println(“Creating?a?pod“);
????????Pod?pod?=?client.pods().inNamespace(“default“).createNew()
????????????????.withNewmetadata()
????????????????????.withName(“my-programmatically-created-pod“)
????????????????.endmetadata()
????????????????.withNewSpec()
????????????????????.addNewContainer()
????????????????????????.withName(“main“)
????????????????????????.withImage(“busybox“)
????????????????????????.withCommand(Arrays.asList(“sleep“?“99999“))
????????????????????.endContainer()
????????????????.endSpec()
????????????????.done();
????????System.out.println(“Created?pod:?“?+?pod);
????????//?edit?the?pod?(add?a?label?to?it)
????????client.pods().inNamespace(“default“).withName(“my-programmatically-created-pod“).edit()
????????????????.editmetadata()
????????????????????.addToLabels(“foo“?“bar“)
????????????????.endmetadata()
????????????????.done();
????????System.out.println(“Added?label?foo=bar?to?pod“);
????????System.out.println(“Waiting?1?minute?before?deleting?pod...“);
????????Thread.sleep(60000);
????????//?delete?the?pod
????????client.pods().inNamespace(“default“).withName(“my-programmatically-created-pod“).delete();
????????System.out.println(“Deleted?the?pod“);
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????5266102??2019-05-23?15:49??openssl-1.0.2g.tar.gz
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter02\
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter02\kubia\
?????文件??????????62??2019-01-10?14:45??kubernetes-in-action-master\Chapter02\kubia\Dockerfile
?????文件?????????361??2019-01-10?14:45??kubernetes-in-action-master\Chapter02\kubia\app.js
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter03\
?????文件??????????66??2019-01-10?14:45??kubernetes-in-action-master\Chapter03\custom-namespace.yaml
?????文件?????????144??2019-01-10?14:45??kubernetes-in-action-master\Chapter03\kubia-gpu.yaml
?????文件?????????202??2019-01-10?14:45??kubernetes-in-action-master\Chapter03\kubia-manual-custom-namespace.yaml
?????文件?????????227??2019-01-10?14:45??kubernetes-in-action-master\Chapter03\kubia-manual-with-labels.yaml
?????文件?????????172??2019-01-10?14:45??kubernetes-in-action-master\Chapter03\kubia-manual.yaml
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\
?????文件?????????239??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\batch-job.yaml
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\batch-job\
?????文件?????????107??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\batch-job\Dockerfile
?????文件?????????371??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\cronjob.yaml
?????文件?????????227??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-liveness-probe-initial-delay.yaml
?????文件?????????197??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-liveness-probe.yaml
?????文件?????????293??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-rc.yaml
?????文件?????????325??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-replicaset-matchex
?????文件?????????266??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-replicaset.yaml
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-unhealthy\
?????文件??????????62??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-unhealthy\Dockerfile
?????文件?????????527??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\kubia-unhealthy\app.js
?????文件?????????273??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\multi-completion-batch-job.yaml
?????文件?????????290??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\multi-completion-parallel-batch-job.yaml
?????文件?????????313??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\ssd-monitor-daemonset.yaml
?????目錄???????????0??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\ssd-monitor\
?????文件??????????69??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\ssd-monitor\Dockerfile
?????文件?????????280??2019-01-10?14:45??kubernetes-in-action-master\Chapter04\time-limited-batch-job.yaml
............此處省略200個文件信息
評論
共有 條評論