use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project spring-cloud-kubernetes by spring-cloud.
the class Fabric8ClientLoadbalancerIT method deployMockManifests.
private static void deployMockManifests() {
try {
Deployment deployment = client.apps().deployments().load(getMockDeployment()).get();
client.apps().deployments().inNamespace(NAMESPACE).create(deployment);
mockDeploymentName = deployment.getMetadata().getName();
Service service = client.services().load(getMockService()).get();
mockServiceName = service.getMetadata().getName();
client.services().inNamespace(NAMESPACE).create(service);
Ingress ingress = client.network().v1().ingresses().load(getMockIngress()).get();
mockIngressName = ingress.getMetadata().getName();
Fabric8Utils.waitForDeployment(client, "servicea-wiremock-deployment", NAMESPACE, 2, 600);
Fabric8Utils.waitForEndpoint(client, "servicea-wiremock", NAMESPACE, 2, 600);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project spring-cloud-kubernetes by spring-cloud.
the class Fabric8ClientLoadbalancerIT method deployPodManifests.
private static void deployPodManifests() {
try {
Deployment deployment = client.apps().deployments().load(getPodDeployment()).get();
String version = K8SUtils.getPomVersion();
String currentImage = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(currentImage + ":" + version);
client.apps().deployments().inNamespace(NAMESPACE).create(deployment);
deploymentName = deployment.getMetadata().getName();
Service service = client.services().load(getService()).get();
serviceName = service.getMetadata().getName();
client.services().inNamespace(NAMESPACE).create(service);
Ingress ingress = client.network().v1().ingresses().load(getIngress()).get();
ingressName = ingress.getMetadata().getName();
client.network().v1().ingresses().inNamespace(NAMESPACE).create(ingress);
Fabric8Utils.waitForDeployment(client, "spring-cloud-kubernetes-fabric8-client-loadbalancer-deployment", NAMESPACE, 2, 600);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project spring-cloud-kubernetes by spring-cloud.
the class Fabric8ClientLoadbalancerIT method deployServiceManifests.
private static void deployServiceManifests() {
try {
Deployment deployment = client.apps().deployments().load(getServiceDeployment()).get();
String version = K8SUtils.getPomVersion();
String currentImage = deployment.getSpec().getTemplate().getSpec().getContainers().get(0).getImage();
deployment.getSpec().getTemplate().getSpec().getContainers().get(0).setImage(currentImage + ":" + version);
client.apps().deployments().inNamespace(NAMESPACE).create(deployment);
deploymentName = deployment.getMetadata().getName();
Service service = client.services().load(getService()).get();
serviceName = service.getMetadata().getName();
client.services().inNamespace(NAMESPACE).create(service);
Ingress ingress = client.network().v1().ingresses().load(getIngress()).get();
ingressName = ingress.getMetadata().getName();
client.network().v1().ingresses().inNamespace(NAMESPACE).create(ingress);
Fabric8Utils.waitForDeployment(client, "spring-cloud-kubernetes-fabric8-client-loadbalancer-deployment", NAMESPACE, 2, 600);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project che-server by eclipse-che.
the class IngressTlsProvisioner method provision.
@Override
public void provision(KubernetesEnvironment k8sEnv, RuntimeIdentity identity) throws KubernetesInfrastructureException {
if (!isTlsEnabled) {
return;
}
String wsTlsSecretName = tlsSecretName;
if (!isNullOrEmpty(tlsCert) && !isNullOrEmpty(tlsKey)) {
wsTlsSecretName = identity.getWorkspaceId() + '-' + tlsSecretName;
provisionTlsSecret(k8sEnv, wsTlsSecretName);
}
for (Ingress ingress : k8sEnv.getIngresses().values()) {
useSecureProtocolForIngressServers(ingress);
enableTLS(ingress, wsTlsSecretName);
}
}
use of com.marcnuri.yakc.model.io.k8s.api.networking.v1.Ingress in project che-server by eclipse-che.
the class KubernetesEnvironmentFactory method doCreate.
@Override
protected KubernetesEnvironment doCreate(@Nullable InternalRecipe recipe, Map<String, InternalMachineConfig> machines, List<Warning> sourceWarnings) throws InfrastructureException, ValidationException {
checkNotNull(recipe, "Null recipe is not supported by kubernetes environment factory");
List<Warning> warnings = new ArrayList<>();
if (sourceWarnings != null) {
warnings.addAll(sourceWarnings);
}
final List<HasMetadata> recipeObjects = recipeParser.parse(recipe);
Map<String, Pod> pods = new HashMap<>();
Map<String, Deployment> deployments = new HashMap<>();
Map<String, Service> services = new HashMap<>();
Map<String, ConfigMap> configMaps = new HashMap<>();
Map<String, PersistentVolumeClaim> pvcs = new HashMap<>();
Map<String, Secret> secrets = new HashMap<>();
boolean isAnyIngressPresent = false;
for (HasMetadata object : recipeObjects) {
checkNotNull(object.getKind(), "Environment contains object without specified kind field");
checkNotNull(object.getMetadata(), "%s metadata must not be null", object.getKind());
checkNotNull(object.getMetadata().getName(), "%s name must not be null", object.getKind());
if (object instanceof Pod) {
putInto(pods, object.getMetadata().getName(), (Pod) object);
} else if (object instanceof Deployment) {
putInto(deployments, object.getMetadata().getName(), (Deployment) object);
} else if (object instanceof Service) {
putInto(services, object.getMetadata().getName(), (Service) object);
} else if (object instanceof Ingress) {
isAnyIngressPresent = true;
} else if (object instanceof PersistentVolumeClaim) {
putInto(pvcs, object.getMetadata().getName(), (PersistentVolumeClaim) object);
} else if (object instanceof Secret) {
putInto(secrets, object.getMetadata().getName(), (Secret) object);
} else if (object instanceof ConfigMap) {
putInto(configMaps, object.getMetadata().getName(), (ConfigMap) object);
} else {
throw new ValidationException(format("Found unknown object type in recipe -- name: '%s', kind: '%s'", object.getMetadata().getName(), object.getKind()));
}
}
if (deployments.size() + pods.size() > 1) {
mergePods(pods, deployments, services);
}
if (isAnyIngressPresent) {
warnings.add(new WarningImpl(Warnings.INGRESSES_IGNORED_WARNING_CODE, Warnings.INGRESSES_IGNORED_WARNING_MESSAGE));
}
KubernetesEnvironment k8sEnv = KubernetesEnvironment.builder().setInternalRecipe(recipe).setMachines(machines).setWarnings(warnings).setPods(pods).setDeployments(deployments).setServices(services).setPersistentVolumeClaims(pvcs).setIngresses(new HashMap<>()).setSecrets(secrets).setConfigMaps(configMaps).build();
envValidator.validate(k8sEnv);
return k8sEnv;
}
Aggregations