当前位置: 首页>>代码示例>>Java>>正文


Java DeploymentSpecBuilder类代码示例

本文整理汇总了Java中io.fabric8.kubernetes.api.model.extensions.DeploymentSpecBuilder的典型用法代码示例。如果您正苦于以下问题:Java DeploymentSpecBuilder类的具体用法?Java DeploymentSpecBuilder怎么用?Java DeploymentSpecBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeploymentSpecBuilder类属于io.fabric8.kubernetes.api.model.extensions包,在下文中一共展示了DeploymentSpecBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetPodTemplate

import io.fabric8.kubernetes.api.model.extensions.DeploymentSpecBuilder; //导入依赖的package包/类
@Test
public void testGetPodTemplate() throws Exception {
    CloudInstanceUserData instanceTag = createInstanceTag();
    KubeCloudClientParameters clientParams = m.mock(KubeCloudClientParameters.class);
    KubeCloudImage image = m.mock(KubeCloudImage.class);
    Deployment deployment = new DeploymentBuilder()
            .withMetadata(new ObjectMetaBuilder()
                    .withLabels(CollectionsUtil.asMap("app", "nginx"))
                    .build())
            .withSpec(new DeploymentSpecBuilder()
                    .withTemplate(new PodTemplateSpecBuilder()
                            .withMetadata(new ObjectMeta())
                            .withSpec(new PodSpecBuilder()
                                    .withContainers(new ContainerBuilder()
                                            .withName("nginx")
                                            .withImage("nginx:1.7.9")
                                            .withPorts(new ContainerPortBuilder()
                                                    .withHostPort(80)
                                                    .build())
                                            .build())
                                    .build())
                            .build())
                    .build())
            .build();
    m.checking(new Expectations(){{
        allowing(clientParams).getNamespace(); will(returnValue("custom namespace"));
        allowing(clientParams).getAuthStrategy(); will(returnValue(UnauthorizedAccessStrategy.ID));
        allowing(image).getId(); will(returnValue("my image id"));
        allowing(image).getName(); will(returnValue("my image name"));
        allowing(image).getSourceDeploymentName(); will(returnValue("deploymentFoo"));
        allowing(image).getAgentName(with("agent name")); will(returnValue("prefix agent name"));
        allowing(myDeploymentContentProvider).findDeployment(with(any(String.class)), with(any(KubeCloudClientParameters.class))); will(returnValue(deployment));
    }});
    Pod podTemplate = myPodTemplateProvider.getPodTemplate(instanceTag, image, clientParams);
    assertNotNull(podTemplate);
    assertNotNull(podTemplate.getMetadata());
    assertNotNull(podTemplate.getSpec());
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:39,代码来源:DeploymentBuildAgentPodTemplateProviderTest.java

示例2: testShouldNotsetContainerName

import io.fabric8.kubernetes.api.model.extensions.DeploymentSpecBuilder; //导入依赖的package包/类
@Test
public void testShouldNotsetContainerName(){
    CloudInstanceUserData instanceTag = createInstanceTag();
    KubeCloudClientParameters clientParams = m.mock(KubeCloudClientParameters.class);
    KubeCloudImage image = m.mock(KubeCloudImage.class);
    Deployment deployment = new DeploymentBuilder()
            .withMetadata(new ObjectMetaBuilder()
                    .withLabels(CollectionsUtil.asMap("app", "nginx"))
                    .build())
            .withSpec(new DeploymentSpecBuilder()
                    .withTemplate(new PodTemplateSpecBuilder()
                            .withMetadata(new ObjectMeta())
                            .withSpec(new PodSpecBuilder()
                                    .withContainers(new ContainerBuilder()
                                            .withName("nginx")
                                            .withImage("nginx:1.7.9")
                                            .withPorts(new ContainerPortBuilder()
                                                    .withHostPort(80)
                                                    .build())
                                            .build())
                                    .build())
                            .build())
                    .build())
            .build();
    m.checking(new Expectations(){{
        allowing(clientParams).getNamespace(); will(returnValue("custom namespace"));
        allowing(image).getId(); will(returnValue("my image id"));
        allowing(image).getName(); will(returnValue("my image name"));
        allowing(image).getSourceDeploymentName(); will(returnValue("deploymentFoo"));
        allowing(image).getAgentName(with("agent name")); will(returnValue("prefix agent name"));
        allowing(myDeploymentContentProvider).findDeployment(with(any(String.class)), with(any(KubeCloudClientParameters.class))); will(returnValue(deployment));
    }});
    Pod podTemplate = myPodTemplateProvider.getPodTemplate(instanceTag, image, clientParams);
    for(Container container : podTemplate.getSpec().getContainers()){
        assertNotSame(container.getName(), "agent name");
    }
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:38,代码来源:DeploymentBuildAgentPodTemplateProviderTest.java

示例3: testDoNotLoseSpecAdditionalProperties

import io.fabric8.kubernetes.api.model.extensions.DeploymentSpecBuilder; //导入依赖的package包/类
@Test
public void testDoNotLoseSpecAdditionalProperties() throws Exception {
    CloudInstanceUserData instanceTag = createInstanceTag();
    KubeCloudClientParameters clientParams = m.mock(KubeCloudClientParameters.class);
    KubeCloudImage image = m.mock(KubeCloudImage.class);

    Deployment deployment = new DeploymentBuilder()
            .withMetadata(new ObjectMetaBuilder()
                    .withLabels(CollectionsUtil.asMap("app", "nginx"))
                    .build())
            .withSpec(new DeploymentSpecBuilder()
                    .withTemplate(new PodTemplateSpecBuilder()
                            .withMetadata(new ObjectMeta())
                            .withSpec(new PodSpecBuilder()
                                    .withContainers(new ContainerBuilder()
                                            .withName("nginx")
                                            .withImage("nginx:1.7.9")
                                            .withPorts(new ContainerPortBuilder()
                                                    .withHostPort(80)
                                                    .build())
                                            .build())
                                    .build())
                            .build())
                    .build())
            .build();

    deployment.getSpec().getTemplate().getSpec().setAdditionalProperty("affinity", "some value");

    m.checking(new Expectations(){{
        allowing(clientParams).getNamespace(); will(returnValue("custom namespace"));
        allowing(image).getId(); will(returnValue("my image id"));
        allowing(image).getName(); will(returnValue("my image name"));
        allowing(image).getSourceDeploymentName(); will(returnValue("deploymentFoo"));
        allowing(image).getAgentName(with("agent name")); will(returnValue("prefix agent name"));
        allowing(myDeploymentContentProvider).findDeployment(with(any(String.class)), with(any(KubeCloudClientParameters.class))); will(returnValue(deployment));
    }});

    Pod podTemplate = myPodTemplateProvider.getPodTemplate(instanceTag, image, clientParams);

    assertNotEmpty(podTemplate.getSpec().getAdditionalProperties().keySet());
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:42,代码来源:DeploymentBuildAgentPodTemplateProviderTest.java


注:本文中的io.fabric8.kubernetes.api.model.extensions.DeploymentSpecBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。