Java源码示例:org.springframework.cloud.deployer.spi.kubernetes.KubernetesClientFactory
示例1
@Test
public void deserializationTest() {
Map<String, KubernetesDeployerProperties> k8sAccounts = this.kubernetesPlatformProperties.getAccounts();
KubernetesClient devK8sClient = KubernetesClientFactory.getKubernetesClient(k8sAccounts.get("dev"));
KubernetesClient qaK8sClient = KubernetesClientFactory.getKubernetesClient(k8sAccounts.get("qa"));
assertThat(k8sAccounts).hasSize(2);
assertThat(k8sAccounts).containsKeys("dev", "qa");
assertThat(devK8sClient.getNamespace()).isEqualTo("dev1");
assertThat(devK8sClient.getMasterUrl().toString()).isEqualTo("https://192.168.0.1:8443");
assertThat(qaK8sClient.getMasterUrl().toString()).isEqualTo("https://192.168.0.2:8443");
assertThat(qaK8sClient.getNamespace()).isEqualTo("qaNamespace");
assertThat(k8sAccounts.get("dev").getImagePullPolicy()).isEqualTo(ImagePullPolicy.Always);
assertThat(k8sAccounts.get("dev").getEntryPointStyle()).isEqualTo(EntryPointStyle.exec);
assertThat(k8sAccounts.get("dev").getLimits().getCpu()).isEqualTo("4");
assertThat(k8sAccounts.get("qa").getNamespace()).isEqualTo("qaNamespace");
assertThat(k8sAccounts.get("qa").getImagePullPolicy()).isEqualTo(ImagePullPolicy.IfNotPresent);
assertThat(k8sAccounts.get("qa").getEntryPointStyle()).isEqualTo(EntryPointStyle.boot);
assertThat(k8sAccounts.get("qa").getLimits().getMemory()).isEqualTo("1024m");
}
示例2
@Override
public Launcher createLauncher(String account) {
KubernetesDeployerProperties kubernetesProperties = this.platformProperties.accountProperties(account);
ContainerFactory containerFactory = new DefaultContainerFactory(
this.platformProperties.accountProperties(account));
KubernetesClient kubernetesClient =
KubernetesClientFactory.getKubernetesClient(this.platformProperties.accountProperties(account));
KubernetesTaskLauncher kubernetesTaskLauncher = new KubernetesTaskLauncher(
kubernetesProperties, kubernetesClient, containerFactory);
Scheduler scheduler = getScheduler(schedulerProperties, kubernetesClient);
Launcher launcher = new Launcher(account, KUBERNETES_PLATFORM_TYPE, kubernetesTaskLauncher, scheduler);
launcher.setDescription(
String.format("master url = [%s], namespace = [%s], api version = [%s]",
kubernetesClient.getMasterUrl(), kubernetesClient.getNamespace(),
kubernetesClient.getApiVersion()));
return launcher;
}
示例3
@Test
public void deserializationTest() {
Map<String, KubernetesDeployerProperties> k8sAccounts = this.kubernetesPlatformProperties.getAccounts();
KubernetesClient devK8sClient = KubernetesClientFactory.getKubernetesClient(k8sAccounts.get("dev"));
KubernetesClient qaK8sClient = KubernetesClientFactory.getKubernetesClient(k8sAccounts.get("qa"));
assertThat(k8sAccounts).hasSize(2);
assertThat(k8sAccounts).containsKeys("dev", "qa");
assertThat(devK8sClient.getNamespace()).isEqualTo("dev1");
assertThat(devK8sClient.getMasterUrl().toString()).isEqualTo("https://192.168.0.1:8443");
assertThat(qaK8sClient.getMasterUrl().toString()).isEqualTo("https://192.168.0.2:8443");
assertThat(k8sAccounts.get("dev").getImagePullPolicy()).isEqualTo(ImagePullPolicy.Always);
assertThat(k8sAccounts.get("dev").getEntryPointStyle()).isEqualTo(EntryPointStyle.exec);
assertThat(k8sAccounts.get("dev").getLimits().getCpu()).isEqualTo("4");
assertThat(k8sAccounts.get("qa").getImagePullPolicy()).isEqualTo(ImagePullPolicy.IfNotPresent);
assertThat(k8sAccounts.get("qa").getEntryPointStyle()).isEqualTo(EntryPointStyle.boot);
assertThat(k8sAccounts.get("qa").getLimits().getMemory()).isEqualTo("1024m");
}
示例4
protected Deployer createAndSaveKubernetesAppDeployers(String account,
KubernetesDeployerProperties kubernetesProperties) {
KubernetesClient kubernetesClient = KubernetesClientFactory.getKubernetesClient(kubernetesProperties);
ContainerFactory containerFactory = new DefaultContainerFactory(
kubernetesProperties);
KubernetesAppDeployer kubernetesAppDeployer = new KubernetesAppDeployer(
kubernetesProperties, kubernetesClient, containerFactory);
Deployer deployer = new Deployer(account, "kubernetes", kubernetesAppDeployer);
deployer.setDescription(
String.format("master url = [%s], namespace = [%s], api version = [%s]",
kubernetesClient.getMasterUrl(), kubernetesClient.getNamespace(),
kubernetesClient.getApiVersion()));
return deployer;
}
示例5
@Bean
public KubernetesClient kubernetesClient() {
return KubernetesClientFactory.getKubernetesClient(this.properties);
}