本文整理汇总了Java中io.fabric8.kubernetes.client.KubernetesClientException类的典型用法代码示例。如果您正苦于以下问题:Java KubernetesClientException类的具体用法?Java KubernetesClientException怎么用?Java KubernetesClientException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KubernetesClientException类属于io.fabric8.kubernetes.client包,在下文中一共展示了KubernetesClientException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
LOGGER.info("Listing all namespaces.");
try {
List<String> namespaces = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (namespaces.isEmpty()) {
return newResponse("No namespaces found.");
} else {
return newResponse("The available namespaces are: " + join(namespaces, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:21,代码来源:GetNamespaces.java
示例2: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
if (!getKubernetesClient().isAdaptable(OpenShiftClient.class)) {
return newFailureNotice("Your cluster is not Openshift!");
}
IntentContext<BaseOperation<DeploymentConfig, DeploymentConfigList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
LOGGER.info("Listing all deployment configs 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 deployment configs found.");
} else {
return newResponse("The available deployment configs are: " + join(deployments, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:26,代码来源:GetDeploymentConfigs.java
示例3: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Pod, PodList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
LOGGER.info("Listing all failing pods for namespace:" + namespace);
try {
List<String> pods = list(ctx)
.getItems()
.stream()
.filter(p -> FAILED_PHASE.equalsIgnoreCase(p.getStatus().getPhase()))
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (pods.isEmpty()) {
return newResponse("No failing pods found in namespace " + namespace);
} else {
return newResponse("The failing pods in namespace " + namespace + " are: " + join(pods, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:23,代码来源:GetFailingPods.java
示例4: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的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
示例5: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Pod, PodList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
LOGGER.info("Listing all pods for namespace:" + namespace);
try {
List<String> pods = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (pods.isEmpty()) {
return newResponse("No pods found in namespace " + namespace);
} else {
return newResponse("The available pods in namespace " + namespace + " are: " + join(pods, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetPods.java
示例6: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Namespace, NamespaceList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, null);
if (Utils.isNullOrEmpty(namespace)) {
throw new IllegalStateException("Namespace needs to be specified either via intent slots, or via session attributes.");
}
try {
LOGGER.info("Create namespace:" + namespace);
newOperation().create(new NamespaceBuilder()
.withNewMetadata()
.withName(namespace)
.endMetadata()
.build());
return newResponse("Successfully created namespace " + namespace);
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:23,代码来源:CreateNamespace.java
示例7: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
IntentContext<BaseOperation<Service, ServiceList, ?, ?>> ctx = createContext(request.getIntent(), session);
String namespace = ctx.getVariable(Variable.Namespace, getKubernetesClient().getNamespace());
LOGGER.info("Listing all services for namespace:" + namespace);
try {
List<String> services = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (services.isEmpty()) {
return newResponse("No services found in namespace " + namespace);
} else {
return newResponse("The available services in namespace " + namespace + " are: " + join(services, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:22,代码来源:GetServices.java
示例8: onRequest
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public SpeechletResponse onRequest(IntentRequest request, Session session) throws SpeechletException {
if (!getKubernetesClient().isAdaptable(OpenShiftClient.class)) {
return newFailureNotice("Your cluster is not Openshift!");
}
IntentContext<BaseOperation<Project, ProjectList, ?, ?>> ctx = createContext(request.getIntent(), session);
LOGGER.info("Listing all projects.");
try {
List<String> projects = list(ctx)
.getItems()
.stream()
.map(d -> d.getMetadata().getName()).collect(Collectors.toList());
if (projects.isEmpty()) {
return newResponse("No projects found.");
} else {
return newResponse("The available projects are: " + join(projects, ","));
}
} catch (KubernetesClientException e) {
return newFailureNotice(e.getStatus().getMessage());
}
}
开发者ID:fabric8io,项目名称:kubernetes-alexa,代码行数:25,代码来源:GetProjects.java
示例9: execute
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Override
public StatusUpdate execute(Integration integration) {
try {
openShiftService().scale(integration.getName(), 0);
logInfo(integration,"Deactivated");
} catch (KubernetesClientException e) {
// Ignore 404 errors, means the deployment does not exist for us
// to scale down
if( e.getCode() != 404 ) {
throw e;
}
}
Integration.Status currentStatus = openShiftService().isScaled(integration.getName(), 0)
? Integration.Status.Deactivated
: Integration.Status.Pending;
return new StatusUpdate(currentStatus);
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:20,代码来源:DeactivateHandler.java
示例10: getPodsByName
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
private KubernetesPod getPodsByName(String namespace, String name) throws VmidcException {
KubernetesPod resultPod = null;
try {
Pod pod = getKubernetesClient().pods().inNamespace(namespace).withName(name).get();
if (pod != null) {
resultPod = new KubernetesPod(pod.getMetadata().getName(), pod.getMetadata().getNamespace(), pod.getMetadata().getUid(),
pod.getSpec().getNodeName());
}
} catch (KubernetesClientException e) {
throw new VmidcException("Failed to get Pods");
}
return resultPod;
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:18,代码来源:KubernetesPodApi.java
示例11: deleteDeployment
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
/**
* Deletes the deployment with the given uid, namespace and name. If the targeted deployment is not found, no-op.
* <p>
* The additional parameters namespace and name are needed because K8s APIs
* do not support queries by uid
*
* @param uid the unique identifier of the deployment to be deleted
* @param namespace the namespace of the deployment to be deleted
* @param name the name of the deployment to be deleted
* @throws VmidcException if a K8s SDK specific exception is caught
*/
public void deleteDeployment(String uid, String namespace, String name) throws VmidcException {
if (uid == null) {
throw new IllegalArgumentException("Uid should not be null");
}
if (name == null) {
throw new IllegalArgumentException("Name should not be null");
}
if (namespace == null) {
throw new IllegalArgumentException("Namespace should not be null");
}
KubernetesDeployment deployment = getDeploymentById(uid, namespace, name);
if (deployment == null) {
LOG.info(String.format("The deployment with id %s, name %s and namespace %s was not found. Nothing to do.", uid, name, namespace));
return;
}
try {
getKubernetesClient().resource(deployment.getDeploymentResource()).delete();
} catch (KubernetesClientException e) {
throw new VmidcException("Failed to delete the deployment");
}
}
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:37,代码来源:KubernetesDeploymentApi.java
示例12: getDeploymentByName
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的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
示例13: stopWatching
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
private final void stopWatching(@Observes @BeforeDestroyed(ApplicationScoped.class) @Priority(LIBRARY_BEFORE) final Object event) throws Exception {
final Closeable watch = this.watch;
if (watch != null) {
KubernetesClientException closeException = this.closeException;
try {
watch.close();
} catch (final Exception everything) {
if (closeException != null) {
closeException.addSuppressed(everything);
throw closeException;
} else {
throw everything;
}
}
if (closeException != null) {
throw closeException;
}
}
}
开发者ID:microbean,项目名称:microbean-kubernetes-client-cdi,代码行数:20,代码来源:KubernetesClientExtension.java
示例14: savePodLog
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
public Path savePodLog(final Pod pod, final String phase) {
Path logFile = null;
try {
final Path logDir = getPodLogsDir().resolve(
TestParent.getCurrentTestClass());
logDir.toFile().mkdirs();
logFile = (phase == null) ? Files.createFile(logDir.resolve(String
.format("%s.log", pod.getMetadata().getName()))) : Files
.createFile(logDir.resolve(String.format("%s-%s.log",
phase, pod.getMetadata().getName())));
} catch (IOException | KubernetesClientException ex) {
LOGGER.debug("Unable to create log file", ex);
return null;
}
try {
List<String> podLog = Arrays.asList(getRuntimeLog(pod).split("\n"));
Files.write(logFile, podLog, Charset.defaultCharset());
return logFile;
} catch (Throwable t) {
LOGGER.warn("Unable to save logs for pod: {}", pod.getMetadata().getName());
LOGGER.debug("Stacktrace: ", t);
return null;
}
}
开发者ID:xtf-cz,项目名称:xtf,代码行数:25,代码来源:OpenshiftUtil.java
示例15: savePodLogWithObserver
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
public Path savePodLogWithObserver(final Pod pod, final String phase) {
Path logFile = null;
try {
final Path logDir = getPodLogsDir().resolve(
TestParent.getCurrentTestClass());
logDir.toFile().mkdirs();
logFile = (phase == null) ? Files.createFile(logDir.resolve(String
.format("%s.log", pod.getMetadata().getName()))) : Files
.createFile(logDir.resolve(String.format("%s-%s.log",
phase, pod.getMetadata().getName())));
} catch (IOException | KubernetesClientException ex) {
LOGGER.debug("Unable to create log file", ex);
return null;
}
try {
List<String> podLog = new ArrayList<>();
observeRuntimeLog(pod).forEach(podLog::add);
Files.write(logFile, podLog, Charset.defaultCharset());
return logFile;
} catch (Throwable t) {
LOGGER.warn("Unable to save logs for pod: {}", pod.getMetadata().getName());
LOGGER.debug("Stacktrace: ", t);
return null;
}
}
开发者ID:xtf-cz,项目名称:xtf,代码行数:26,代码来源:OpenshiftUtil.java
示例16: startNewInstance
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@NotNull
@Override
public CloudInstance startNewInstance(@NotNull CloudImage cloudImage, @NotNull CloudInstanceUserData cloudInstanceUserData) throws QuotaException {
final KubeCloudImage kubeCloudImage = (KubeCloudImage) cloudImage;
BuildAgentPodTemplateProvider podTemplateProvider = myPodTemplateProviders.get(kubeCloudImage.getPodSpecMode());
try {
final Pod podTemplate = podTemplateProvider.getPodTemplate(cloudInstanceUserData, kubeCloudImage, myKubeClientParams);
final Pod newPod = myApiConnector.createPod(podTemplate);
myCurrentError = null;
final KubeCloudInstance newInstance = new CachingKubeCloudInstance(new KubeCloudInstanceImpl(kubeCloudImage, newPod, myApiConnector), myCache);
kubeCloudImage.populateInstances();
return newInstance;
} catch (KubeCloudException | KubernetesClientException ex){
myCurrentError = new CloudErrorInfo("Failed to start pod", ex.getMessage(), ex);
throw ex;
}
}
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:18,代码来源:KubeCloudClient.java
示例17: shouldDeleteGCPKeysIfSecretAlreadyExists
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Test
public void shouldDeleteGCPKeysIfSecretAlreadyExists() throws IsClosedException, IOException {
when(serviceAccountKeyManager.serviceAccountExists(SERVICE_ACCOUNT)).thenReturn(true);
ServiceAccountKey jsonKey = new ServiceAccountKey();
jsonKey.setName("key.json");
jsonKey.setPrivateKeyData("json-private-key-data");
ServiceAccountKey p12Key = new ServiceAccountKey();
p12Key.setName("key.p12");
p12Key.setPrivateKeyData("p12-private-key-data");
when(serviceAccountKeyManager.createJsonKey(any(String.class))).thenReturn(jsonKey);
when(serviceAccountKeyManager.createP12Key(any(String.class))).thenReturn(p12Key);
when(k8sClient.secrets().create(any())).thenThrow(new KubernetesClientException(
"Already exists", 409, new Status()));
sut.ensureServiceAccountKeySecret(WORKFLOW_ID.toString(), SERVICE_ACCOUNT);
verify(serviceAccountKeyManager).createJsonKey(SERVICE_ACCOUNT);
verify(serviceAccountKeyManager).createP12Key(SERVICE_ACCOUNT);
verify(serviceAccountKeyManager).tryDeleteKey(jsonKey.getName());
verify(serviceAccountKeyManager).tryDeleteKey(p12Key.getName());
}
开发者ID:spotify,项目名称:styx,代码行数:23,代码来源:KubernetesGCPServiceAccountSecretManagerTest.java
示例18: testAddressesAreNotRecreated
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
@Test
public void testAddressesAreNotRecreated() throws Exception {
Address address = createAddress("addr1", StandardType.ANYCAST);
Address newAddress = createAddress("addr2", StandardType.ANYCAST);
KubernetesList resources = new KubernetesList();
when(mockGenerator.generateCluster(eq("addr1"), anySet())).thenReturn(new AddressCluster("addr1", resources));
when(mockGenerator.generateCluster(eq("addr2"), anySet())).thenReturn(new AddressCluster("addr2", resources));
doThrow(new KubernetesClientException("Unable to replace resource")).when(mockApi).replaceAddress(address);
try {
controller.resourcesUpdated(Sets.newSet(address, newAddress));
ArgumentCaptor<Address> addressArgumentCaptor = ArgumentCaptor.forClass(Address.class);
verify(mockApi, times(2)).replaceAddress(addressArgumentCaptor.capture());
List<Address> replaced = addressArgumentCaptor.getAllValues();
assertThat(replaced, hasItem(newAddress));
} catch (KubernetesClientException e) {
fail("Should not throw exception with multiple items");
}
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:23,代码来源:AddressControllerTest.java
示例19: retainAddressSpaces
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
public void retainAddressSpaces(Set<AddressSpace> desiredAddressSpaces) {
if (desiredAddressSpaces.size() == 1 && desiredAddressSpaces.iterator().next().getNamespace().equals(namespace)) {
return;
}
Set<NamespaceInfo> actual = kubernetes.listAddressSpaces();
Set<NamespaceInfo> desired = desiredAddressSpaces.stream()
.map(space -> new NamespaceInfo(space.getName(), space.getNamespace(), space.getCreatedBy()))
.collect(Collectors.toSet());
actual.removeAll(desired);
for (NamespaceInfo toRemove : actual) {
try {
log.info("Deleting address space {}", toRemove);
kubernetes.deleteNamespace(toRemove);
eventLogger.log(AddressSpaceDeleted, "Deleted address space", Normal, ControllerKind.AddressSpace, toRemove.getAddressSpace());
} catch (KubernetesClientException e) {
eventLogger.log(AddressSpaceDeleteFailed, e.getMessage(), Warning, ControllerKind.AddressSpace, toRemove.getAddressSpace());
log.info("Exception when deleting namespace (may already be in progress): " + e.getMessage());
}
}
}
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:23,代码来源:ControllerHelper.java
示例20: resolveServicesOffline
import io.fabric8.kubernetes.client.KubernetesClientException; //导入依赖的package包/类
private static void resolveServicesOffline(
Object bean, List<Field> serverNameFields, JsonObject env) throws KubernetesClientException {
serverNameFields.forEach(
serviceNameField -> {
final ServiceName serviceNameAnnotation =
serviceNameField.getAnnotation(ServiceName.class);
final String serviceName = serviceNameAnnotation.value();
final boolean withLabel = serviceNameField.isAnnotationPresent(WithLabel.class);
final boolean withLabels = serviceNameField.isAnnotationPresent(WithLabels.class);
if (isServiceNameOnly(withLabel, withLabels)) {
resolveOfflineByServiceName(bean, env, serviceNameField, serviceName);
} else {
resolveOfflineServiceByLabelOnly(bean, env, serviceNameField, withLabel, withLabels);
}
});
}
开发者ID:amoAHCP,项目名称:vxms,代码行数:17,代码来源:KubeDiscovery.java
注:本文中的io.fabric8.kubernetes.client.KubernetesClientException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论