本文整理汇总了Java中io.fabric8.kubernetes.api.model.extensions.Deployment类的典型用法代码示例。如果您正苦于以下问题:Java Deployment类的具体用法?Java Deployment怎么用?Java Deployment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Deployment类属于io.fabric8.kubernetes.api.model.extensions包,在下文中一共展示了Deployment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRequest
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Deployment, DeploymentList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
LOGGER.info("Listing all deployments for namespace:" + namespace);
try {
List<String> deployments = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (deployments.isEmpty()) {
return newResponse("No deployments found.");
} else {
return newResponse("The available deployments are: " + join(deployments, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetDeployments.java
示例2: getDeploymentReport
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
/**
* Returns a simple report of the deployments.
* @return A string containing the text of the report.
*/
private String getDeploymentReport() {
StringBuilder sb = new StringBuilder();
List<Deployment> all = kubernetesClient.extensions().deployments().list().getItems();
List<Deployment> pending = all.stream()
.filter(d -> !Readiness.isDeploymentReady(d))
.collect(Collectors.toList());
try {
sb.append(createDeploymentReport(all.size(), all.size() - pending.size()));
sb.append(createPendingReportForDeployment(pending));
} catch (Throwable t) {
//ignore
}
return sb.toString();
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:21,代码来源:Launch.java
示例3: createDeployment
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
protected Deployment createDeployment(String namespace,
final String deploymentName,
Map<String, String> labels,
final String serviceAccountName,
final String imageName,
final ImagePullPolicy imagePullPolicy,
final boolean hostNetwork,
final boolean tls,
final boolean verifyTls) {
namespace = normalizeNamespace(namespace);
labels = normalizeLabels(labels);
final Deployment deployment = new Deployment();
final ObjectMeta metadata = new ObjectMeta();
metadata.setNamespace(namespace);
metadata.setName(normalizeDeploymentName(deploymentName));
metadata.setLabels(labels);
deployment.setMetadata(metadata);
deployment.setSpec(this.createDeploymentSpec(labels, serviceAccountName, imageName, imagePullPolicy, namespace, hostNetwork, tls, verifyTls));
return deployment;
}
开发者ID:microbean,项目名称:microbean-helm,代码行数:24,代码来源:TillerInstaller.java
示例4: getDeploymentByName
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
private KubernetesDeployment getDeploymentByName(String namespace, String name) throws VmidcException {
KubernetesDeployment resultDeployment = null;
try {
Deployment deployment = getKubernetesClient().extensions().deployments().inNamespace(namespace).withName(name).get();
if (deployment != null) {
resultDeployment = new KubernetesDeployment(
deployment.getMetadata().getName(),
deployment.getMetadata().getNamespace(),
deployment.getMetadata().getUid(),
deployment.getSpec().getReplicas(),
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage(),
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImagePullPolicy());
resultDeployment.setDeploymentResource(deployment);
Integer availableReplicas = deployment.getStatus().getAvailableReplicas();
resultDeployment.setAvailableReplicaCount(availableReplicas == null ? 0 : availableReplicas.intValue());
}
} catch (KubernetesClientException e) {
throw new VmidcException("Failed to get the deployment");
}
return resultDeployment;
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:26,代码来源:KubernetesDeploymentApi.java
示例5: testGetDeploymentById_WhenK8sReturnsDeploymentWithMatchingId_ReturnsDeployment
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Test
public void testGetDeploymentById_WhenK8sReturnsDeploymentWithMatchingId_ReturnsDeployment() throws Exception {
// Arrange.
String name = UUID.randomUUID().toString();
String namespace = UUID.randomUUID().toString();
String uid = UUID.randomUUID().toString();
Deployment deployment = newDeployment(uid, namespace, name, 1, "image-sample-name");
mockDeploymentByName(namespace, name, deployment);
// Act.
KubernetesDeployment result = this.deploymentApi.getDeploymentById(uid, namespace, name);
// Assert.
assertNotNull("The result should not be null.", result);
assertDeploymentFields(deployment, result);
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:17,代码来源:KubernetesDeploymentApiTest.java
示例6: testUpdateDeploymentReplicaCount_WhenK8sReturnsDeploymentWithMatchingId_DeploymentUpdated
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Test
public void testUpdateDeploymentReplicaCount_WhenK8sReturnsDeploymentWithMatchingId_DeploymentUpdated() throws Exception {
// Arrange.
String name = UUID.randomUUID().toString();
String namespace = UUID.randomUUID().toString();
String uid = UUID.randomUUID().toString();
Deployment deployment = newDeployment(uid, namespace, name, 1, "image-sample-name");
ScalableResource<Deployment, DoneableDeployment> resourceMock = mockDeploymentByName(namespace, name, deployment);
int newReplicaCount = 10;
// Act.
this.deploymentApi.updateDeploymentReplicaCount(uid, namespace, name, newReplicaCount);
// Assert.
verify(resourceMock, times(1)).scale(newReplicaCount);
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:18,代码来源:KubernetesDeploymentApiTest.java
示例7: matches
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Override
public boolean matches(Object object) {
if (object == null || !(object instanceof Deployment)) {
return false;
}
Deployment deployment = (Deployment)object;
ObjectMeta metadata = deployment.getMetadata();
DeploymentSpec spec = deployment.getSpec();
PodTemplateSpec podTemplateSpec = spec.getTemplate();
String podLabel = podTemplateSpec.getMetadata().getLabels().get("osc-deployment");
Container container = podTemplateSpec.getSpec().getContainers().get(0);
return this.name.equals(metadata.getName()) &&
this.name.equals(podLabel) &&
this.replicaCount == spec.getReplicas() &&
this.imageName.equals(container.getImage()) &&
this.name.equals(container.getName());
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:22,代码来源:KubernetesDeploymentApiTest.java
示例8: testExists
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
public void testExists() throws ResourceException {
// Check that the deployment doesn't exist already
Deployment deployment = KubernetesClientUtil.retrieveDeployment(kubernetesClient, deploymentResourceV1);
assertNull(deployment);
// Test exists method
assertFalse(deploymentResourceV1.exists());
// Create deployment
deploymentResourceV1.create();
// Check that the deployment exists
deployment = KubernetesClientUtil.retrieveDeployment(kubernetesClient, deploymentResourceV1);
assertNotNull(deployment);
// Test exists method
assertTrue(deploymentResourceV1.exists());
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:20,代码来源:DeploymentResourceIntegrationTest.java
示例9: testCreate
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
public void testCreate() throws ResourceException {
// Check that the deployment doesn't exist already
Deployment deployment = KubernetesClientUtil.retrieveDeployment(kubernetesClient, deploymentResourceV1);
assertNull(deployment);
// Create deployment
deploymentResourceV1.create();
// Check that the deployment exists
deployment = KubernetesClientUtil.retrieveDeployment(kubernetesClient, deploymentResourceV1);
assertNotNull(deployment);
// Check if the pods were created
assertEquals(3, KubernetesClientUtil.retrievePods(kubernetesClient, deploymentResourceV1).getItems().size());
// Check if the replica set was created
List<ReplicaSet> replicaSets = KubernetesClientUtil.retrieveReplicaSets(kubernetesClient, deploymentResourceV1).getItems();
assertEquals(1, replicaSets.size());
assertEquals(deploymentResourceV1.getId(), replicaSets.get(0).getMetadata().getLabels().get(DEPLOYMENT_MARKER_LABEL));
// Compare deployments
assertEquals(deployment.getMetadata().getName(), deploymentResourceV1.getId());
assertEquals(deployment.getApiVersion(), deploymentResourceV1.getResourceConfig().getResourceVersion());
assertEquals(deployment.getKind(), deploymentResourceV1.getResourceConfig().getResourceType());
}
开发者ID:qaware,项目名称:gradle-cloud-deployer,代码行数:27,代码来源:DeploymentResourceIntegrationTest.java
示例10: addMissingResources
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Override
public void addMissingResources(KubernetesListBuilder builder) {
log.info("addMissingResources");
List<HasMetadata> items = builder.getItems();
for (HasMetadata item : items) {
if (item instanceof Deployment) {
Deployment deployment = (Deployment)item;
List<Container> containers = getCandidateContainers(deployment);
for (Container container : containers) {
if (container.getResources() == null) {
ResourceRequirements resourceRequirements = buildResourceRequirements();
log.info(describe(resourceRequirements));
container.setResources(resourceRequirements);
}
}
}
}
builder.withItems(items);
}
开发者ID:garethahealy,项目名称:kube-dsl-defaults,代码行数:24,代码来源:LimitEnricher.java
示例11: getFailedEvents
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
public static List<Event> getFailedEvents(KubernetesClient client, Deployment deployment) {
List<Event> result = new ArrayList<>();
for (Pod pod : podsOf(client, deployment).getItems()) {
result.addAll(getFailedEvents(client, pod));
}
return result;
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:8,代码来源:FeedbackUtils.java
示例12: findMatching
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
/**
* Returns the {@link PodList} that match the specified {@link Deployment}.
*
* @param deployment The {@link Deployment}
*/
public static PodList findMatching(KubernetesClient client, Deployment deployment) {
FilterWatchListDeletable<Pod, PodList, Boolean, Watch, Watcher<Pod>> podLister =
client.pods().inNamespace(deployment.getMetadata().getNamespace());
if (deployment.getSpec().getSelector().getMatchLabels() != null) {
podLister.withLabels(deployment.getSpec().getSelector().getMatchLabels());
}
if (deployment.getSpec().getSelector().getMatchExpressions() != null) {
for (LabelSelectorRequirement req : deployment.getSpec().getSelector().getMatchExpressions()) {
switch (req.getOperator()) {
case "In":
podLister.withLabelIn(req.getKey(), req.getValues().toArray(new String[]{}));
break;
case "NotIn":
podLister.withLabelNotIn(req.getKey(), req.getValues().toArray(new String[]{}));
break;
case "DoesNotExist":
podLister.withoutLabel(req.getKey());
break;
case "Exists":
podLister.withLabel(req.getKey());
break;
}
}
}
return podLister.list();
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:32,代码来源:FeedbackUtils.java
示例13: podsOf
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
/**
* Finds the pod that correspond to the specified resource.
*
* @param resource The resource.
* @return The podList with the matching pods.
*/
public static <T extends HasMetadata> PodList podsOf(KubernetesClient client, T resource) {
if (resource instanceof Pod) {
return new PodListBuilder().withItems((Pod) resource).build();
} else if (resource instanceof Endpoints) {
return podsOf(client, client.services()
.inNamespace(resource.getMetadata().getNamespace())
.withName(resource.getMetadata().getName())
.get());
} else if (resource instanceof Service) {
return client.pods()
.inNamespace(resource.getMetadata().getNamespace())
.withLabels(((Service) resource).getSpec().getSelector())
.list();
} else if (resource instanceof ReplicationController) {
return client.pods()
.inNamespace(resource.getMetadata().getNamespace())
.withLabels(((ReplicationController) resource).getSpec().getSelector())
.list();
} else if (resource instanceof Deployment) {
return findMatching(client, (Deployment) resource);
} else if (resource instanceof DeploymentConfig) {
return client.pods().inNamespace(resource.getMetadata().getNamespace()).withLabel("deploymentconfig",
resource.getMetadata().getName()).list();
} else {
return new PodListBuilder().build();
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:34,代码来源:FeedbackUtils.java
示例14: createPendingReportForDeployment
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
private String createPendingReportForDeployment(List<Deployment> pending) {
if (pending == null || pending.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append("Failed deployments are: ");
for (Deployment p : pending) {
sb.append(p.getMetadata().getName()).append(" ");
List<Event> events = FeedbackUtils.getFailedEvents(kubernetesClient, p);
if (!events.isEmpty()) {
sb.append(" , due to:" + FeedbackUtils.normalize(events.get(0).getMessage()));
}
}
return sb.toString();
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:16,代码来源:Launch.java
示例15: createDeployment
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
/**
* Creates a Kubernetes deployment.
*
* @param deployment the deployment to be created
* @return the unique identifier of the deployment
* @throws VmidcException if a K8s SDK specific exception is caught
*/
public String createDeployment(KubernetesDeployment deployment) throws VmidcException {
if (deployment == null) {
throw new IllegalArgumentException("The deployment should not be null");
}
try {
Deployment newDeployment = new DeploymentBuilder()
.withKind("Deployment")
.withNewMetadata()
.withName(deployment.getName())
.endMetadata()
.withNewSpec()
.withReplicas(deployment.getDesiredReplicaCount())
.withNewTemplate()
.withNewMetadata()
.addToLabels(OSC_DEPLOYMENT_LABEL_NAME, deployment.getName())
.endMetadata()
.withNewSpec()
.addNewContainer()
.withName(deployment.getName()).withImage(deployment.getContainerImageName())
.endContainer()
.endSpec()
.endTemplate()
.endSpec()
.build();
Deployment result = getKubernetesClient().extensions().deployments().inNamespace(deployment.getNamespace()).create(newDeployment);
return result.getMetadata().getUid();
} catch (KubernetesClientException e) {
throw new VmidcException(String.format("Failed to create a deployment %s", e));
}
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:42,代码来源:KubernetesDeploymentApi.java
示例16: testInitialize
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Before
public void testInitialize() throws Exception{
MockitoAnnotations.initMocks(this);
when(this.kubernetesClient.getClient()).thenReturn(this.fabric8Client);
this.deploymentApi = new KubernetesDeploymentApi(this.kubernetesClient);
when(this.fabric8Client.extensions()).thenReturn(this.extensionsApiMock);
when(this.fabric8Client.resource(Mockito.any(Deployment.class))).thenReturn(this.deploymentMock);
when(this.extensionsApiMock.deployments()).thenReturn(this.mixedOperationMock);
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:11,代码来源:KubernetesDeploymentApiTest.java
示例17: testDelete_WhenK8sReturnsDeploymentWithMatchingId_ResourceDeleted
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Test
public void testDelete_WhenK8sReturnsDeploymentWithMatchingId_ResourceDeleted() throws Exception {
// Arrange.
String name = UUID.randomUUID().toString();
String namespace = UUID.randomUUID().toString();
String uid = UUID.randomUUID().toString();
Deployment deployment = newDeployment(uid, namespace, name, 1, "image-sample-name");
mockDeploymentByName(namespace, name, deployment);
// Act.
this.deploymentApi.deleteDeployment(uid, namespace, name);
// Assert.
verify(this.deploymentMock, times(1)).delete();
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:16,代码来源:KubernetesDeploymentApiTest.java
示例18: testCreateDeployment_WithValidDeployment_DeploymentCreated
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
@Test
public void testCreateDeployment_WithValidDeployment_DeploymentCreated() throws Exception {
// Arrange.
KubernetesDeployment deployment =
new KubernetesDeployment("name", "namespace", "uid", 2, "imageName", null);
String deploymentUid = UUID.randomUUID().toString();
Deployment createdDeployment = new Deployment();
ObjectMeta metadata = new ObjectMeta();
metadata.setUid(deploymentUid);
createdDeployment.setMetadata(metadata);
when(
this.extensionsApiMock
.deployments()
.inNamespace(deployment.getNamespace()))
.thenReturn(this.nonNamespaceOperationMock);
when(
this.nonNamespaceOperationMock
.create(Mockito.argThat(
new DeploymentMatcher(
deployment.getName(),
deployment.getDesiredReplicaCount(),
deployment.getContainerImageName()))))
.thenReturn(createdDeployment);
// Act.
String uid = this.deploymentApi.createDeployment(deployment);
// Assert.
assertEquals("The returned uid was different than expected.", deploymentUid, uid);
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:35,代码来源:KubernetesDeploymentApiTest.java
示例19: mockDeploymentByName
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
private ScalableResource<Deployment, DoneableDeployment> mockDeploymentByName(String namespace, String name, Deployment deployment) {
when(this.extensionsApiMock.deployments().inNamespace(namespace)).thenReturn(this.nonNamespaceOperationMock);
@SuppressWarnings("unchecked")
ScalableResource<Deployment, DoneableDeployment> deploymentResource = Mockito.mock(ScalableResource.class);
when(deploymentResource.get()).thenReturn(deployment);
when(this.nonNamespaceOperationMock.withName(name)).thenReturn(deploymentResource);
return deploymentResource;
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:11,代码来源:KubernetesDeploymentApiTest.java
示例20: newDeployment
import io.fabric8.kubernetes.api.model.extensions.Deployment; //导入依赖的package包/类
private Deployment newDeployment(String uid, String namespace, String name, int desiredReplicaCount, String containerImageName) {
Deployment deployment = new Deployment();
ObjectMeta objMeta = new ObjectMeta();
objMeta.setName(name);
objMeta.setNamespace(namespace);
objMeta.setUid(uid);
DeploymentSpec spec = new DeploymentSpec();
spec.setReplicas(desiredReplicaCount);
Container container = new Container();
container.setImage(containerImageName);
PodSpec podSpec = new PodSpec();
podSpec.setContainers(Arrays.asList(container));
PodTemplateSpec podTemplateSpec = new PodTemplateSpec();
podTemplateSpec.setSpec(podSpec);
spec.setTemplate(podTemplateSpec);
deployment.setMetadata(objMeta);
deployment.setSpec(spec);
DeploymentStatus deploymentStatus = new DeploymentStatus();
deploymentStatus.setAvailableReplicas(3);
deployment.setStatus(deploymentStatus);
return deployment;
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:31,代码来源:KubernetesDeploymentApiTest.java
注:本文中的io.fabric8.kubernetes.api.model.extensions.Deployment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论