use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project kubernetes-client by fabric8io.
the class CustomResourceDefinitionIT method get.
@Test
public void get() {
// When
final CustomResourceDefinition result = client.apiextensions().v1().customResourceDefinitions().withName(name).get();
// Then
assertThat(result).isNotNull();
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project kubernetes-client by fabric8io.
the class CustomResourceDefinitionIT method load.
@Test
public void load() {
// When
final CustomResourceDefinition result = client.apiextensions().v1().customResourceDefinitions().load(getClass().getResourceAsStream("/test-crd.yml")).get();
// Then
assertThat(result).isNotNull();
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project kubernetes-client by fabric8io.
the class V1CustomResourceDefinitionTest method testList.
@Test
void testList() {
server.expect().get().withPath("/apis/apiextensions.k8s.io/v1/customresourcedefinitions").andReturn(HttpURLConnection.HTTP_OK, new KubernetesListBuilder().withItems(customResourceDefinition).build()).once();
CustomResourceDefinitionList crdList = client.apiextensions().v1().customResourceDefinitions().list();
assertNotNull(crdList);
assertEquals(1, crdList.getItems().size());
assertEquals("sparkclusters.radanalytics.io", crdList.getItems().get(0).getMetadata().getName());
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project kubernetes-client by fabric8io.
the class CustomResourceDefinitionProcessor method process.
public void process(String path, String crdString, boolean delete) {
CustomResourceDefinitionContext context = null;
if (path.startsWith(V1BETA1_PATH)) {
io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition crd = Serialization.unmarshal(crdString, io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition.class);
context = CustomResourceDefinitionContext.fromCrd(crd);
} else if (path.startsWith(V1_PATH)) {
CustomResourceDefinition crd = Serialization.unmarshal(crdString, CustomResourceDefinition.class);
context = CustomResourceDefinitionContext.fromCrd(crd);
} else {
return;
}
if (delete) {
extractor.removeCrdContext(context);
} else {
extractor.addCrdContext(context);
}
}
use of io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition in project jkube by eclipse.
the class ApplyService method applyEntity.
/**
* Applies the given DTOs onto the Kubernetes master
*/
private void applyEntity(Object dto, String sourceName) {
if (dto instanceof Pod) {
applyPod((Pod) dto, sourceName);
} else if (dto instanceof ReplicationController) {
applyReplicationController((ReplicationController) dto, sourceName);
} else if (dto instanceof Service) {
applyService((Service) dto, sourceName);
} else if (dto instanceof Route) {
applyRoute((Route) dto, sourceName);
} else if (dto instanceof BuildConfig) {
applyBuildConfig((BuildConfig) dto, sourceName);
} else if (dto instanceof DeploymentConfig) {
DeploymentConfig resource = (DeploymentConfig) dto;
OpenShiftClient openShiftClient = getOpenShiftClient();
if (openShiftClient != null) {
applyResource(resource, sourceName, openShiftClient.deploymentConfigs());
} else {
log.warn("Not connected to OpenShift cluster so cannot apply entity %s", dto);
}
} else if (dto instanceof RoleBinding) {
applyRoleBinding((RoleBinding) dto, sourceName);
} else if (dto instanceof Role) {
applyResource((Role) dto, sourceName, kubernetesClient.rbac().roles());
} else if (dto instanceof ImageStream) {
applyImageStream((ImageStream) dto, sourceName);
} else if (dto instanceof OAuthClient) {
applyOAuthClient((OAuthClient) dto, sourceName);
} else if (dto instanceof Template) {
applyTemplate((Template) dto, sourceName);
} else if (dto instanceof ServiceAccount) {
applyServiceAccount((ServiceAccount) dto, sourceName);
} else if (dto instanceof Secret) {
applySecret((Secret) dto, sourceName);
} else if (dto instanceof ConfigMap) {
applyResource((ConfigMap) dto, sourceName, kubernetesClient.configMaps());
} else if (dto instanceof DaemonSet) {
applyResource((DaemonSet) dto, sourceName, kubernetesClient.apps().daemonSets());
} else if (dto instanceof Deployment) {
applyResource((Deployment) dto, sourceName, kubernetesClient.apps().deployments());
} else if (dto instanceof ReplicaSet) {
applyResource((ReplicaSet) dto, sourceName, kubernetesClient.apps().replicaSets());
} else if (dto instanceof StatefulSet) {
applyResource((StatefulSet) dto, sourceName, kubernetesClient.apps().statefulSets());
} else if (dto instanceof Ingress) {
applyResource((Ingress) dto, sourceName, kubernetesClient.extensions().ingresses());
} else if (dto instanceof PersistentVolumeClaim) {
applyPersistentVolumeClaim((PersistentVolumeClaim) dto, sourceName);
} else if (dto instanceof CustomResourceDefinition) {
applyCustomResourceDefinition((CustomResourceDefinition) dto, sourceName);
} else if (dto instanceof Job) {
applyJob((Job) dto, sourceName);
} else if (dto instanceof NetworkPolicy) {
applyResource((NetworkPolicy) dto, sourceName, kubernetesClient.network().networkPolicies());
} else if (dto instanceof Namespace) {
applyNamespace((Namespace) dto);
} else if (dto instanceof Project) {
applyProject((Project) dto);
} else if (dto instanceof GenericKubernetesResource) {
applyGenericKubernetesResource((GenericKubernetesResource) dto, sourceName);
} else if (dto instanceof HasMetadata) {
HasMetadata entity = (HasMetadata) dto;
try {
log.info("Applying %s %s from %s", getKind(entity), getName(entity), sourceName);
kubernetesClient.resource(entity).inNamespace(applicableNamespace((HasMetadata) dto, namespace, fallbackNamespace)).createOrReplace();
} catch (Exception e) {
onApplyError("Failed to create " + getKind(entity) + " from " + sourceName + ". " + e, e);
}
} else {
throw new IllegalArgumentException("Unknown entity type " + dto);
}
}
Aggregations