io.fabric8.kubernetes.api.model.HTTPGetAction Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.HTTPGetAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractAddProbeDecorator.java From dekorate with Apache License 2.0 | 6 votes |
@Override public void andThenVisit(ContainerFluent<?> container) { if (probe == null) { return; } final ExecAction execAction = execAction(probe); final TCPSocketAction tcpSocketAction = tcpSocketAction(probe); final boolean defaultToHttpGetAction = (execAction == null) && (tcpSocketAction == null); final HTTPGetAction httpGetAction = defaultToHttpGetAction ? httpGetAction(probe, container) : null; if (defaultToHttpGetAction && (httpGetAction == null)) { return; } doCreateProbe(container, new Actions(execAction, tcpSocketAction, httpGetAction)); }
Example #2
Source File: ProbeHandler.java From jkube with Eclipse Public License 2.0 | 5 votes |
public Probe getProbe(ProbeConfig probeConfig) { if (probeConfig == null) { return null; } Probe probe = new Probe(); Integer initialDelaySeconds = probeConfig.getInitialDelaySeconds(); if (initialDelaySeconds != null) { probe.setInitialDelaySeconds(initialDelaySeconds); } Integer timeoutSeconds = probeConfig.getTimeoutSeconds(); if (timeoutSeconds != null) { probe.setTimeoutSeconds(timeoutSeconds); } Integer failureThreshold = probeConfig.getFailureThreshold(); if(failureThreshold != null) { probe.setFailureThreshold(failureThreshold); } Integer successThreshold = probeConfig.getSuccessThreshold(); if(successThreshold != null) { probe.setSuccessThreshold(successThreshold); } HTTPGetAction getAction = getHTTPGetAction(probeConfig.getGetUrl()); if (getAction != null) { probe.setHttpGet(getAction); return probe; } ExecAction execAction = getExecAction(probeConfig.getExec()); if (execAction != null) { probe.setExec(execAction); return probe; } TCPSocketAction tcpSocketAction = getTCPSocketAction(probeConfig.getGetUrl(), probeConfig.getTcpPort()); if (tcpSocketAction != null) { probe.setTcpSocket(tcpSocketAction); return probe; } return null; }
Example #3
Source File: ProbeHandler.java From jkube with Eclipse Public License 2.0 | 5 votes |
private HTTPGetAction getHTTPGetAction(String getUrl) { if (getUrl == null || !getUrl.subSequence(0,4).toString().equalsIgnoreCase("http")) { return null; } try { URL url = new URL(getUrl); return new HTTPGetAction(url.getHost(), null /* headers */, url.getPath(), new IntOrString(url.getPort()), url.getProtocol().toUpperCase()); } catch (MalformedURLException e) { throw new IllegalArgumentException("Invalid URL " + getUrl + " given for HTTP GET readiness check"); } }
Example #4
Source File: ThorntailOnKubernetesTest.java From dekorate with Apache License 2.0 | 5 votes |
@Test void shouldContainDeployment() { KubernetesList list = Serialization.unmarshalAsList(ThorntailOnKubernetesTest.class.getClassLoader().getResourceAsStream("META-INF/dekorate/kubernetes.yml")); assertNotNull(list); Optional<Deployment> deployment = findFirst(list, Deployment.class); assertTrue(deployment.isPresent()); Deployment d = deployment.get(); List<Container> containers = d.getSpec().getTemplate().getSpec().getContainers(); assertEquals(1, containers.size()); Container container = containers.get(0); assertEquals(1, container.getPorts().size()); assertEquals("http", container.getPorts().get(0).getName()); assertEquals(9090, container.getPorts().get(0).getContainerPort()); HTTPGetAction livenessProbe = container.getLivenessProbe().getHttpGet(); assertNotNull(livenessProbe); assertEquals("/health", livenessProbe.getPath()); assertEquals(9090, livenessProbe.getPort().getIntVal()); assertEquals(180, container.getLivenessProbe().getInitialDelaySeconds()); HTTPGetAction readinessProbe = container.getReadinessProbe().getHttpGet(); assertNotNull(readinessProbe); assertEquals("/health", readinessProbe.getPath()); assertEquals(9090, readinessProbe.getPort().getIntVal()); assertEquals(20, container.getReadinessProbe().getInitialDelaySeconds()); Optional<Service> service = findFirst(list, Service.class); assertTrue(service.isPresent()); ServiceSpec s = service.get().getSpec(); assertEquals(1, s.getPorts().size()); assertEquals("http", s.getPorts().get(0).getName()); assertEquals(9090, s.getPorts().get(0).getPort()); assertEquals(9090, s.getPorts().get(0).getTargetPort().getIntVal()); }
Example #5
Source File: AbstractAddProbeDecorator.java From dekorate with Apache License 2.0 | 5 votes |
private HTTPGetAction httpGetAction(Probe probe, ContainerFluent<?> container) { if (!container.hasPorts()) { return new HTTPGetAction(null, Collections.emptyList(), probe.getHttpActionPath(), new IntOrString(8080), "HTTP"); } return new HTTPGetAction(null, Collections.emptyList(), probe.getHttpActionPath(), new IntOrString(Ports.getHttpPort(container).get().getContainerPort()), "HTTP"); }
Example #6
Source File: ThorntailOnOpenshiftTest.java From dekorate with Apache License 2.0 | 4 votes |
@Test void shouldContainDeployment() { KubernetesList list = Serialization.unmarshalAsList(ThorntailOnOpenshiftTest.class.getClassLoader().getResourceAsStream("META-INF/dekorate/openshift.yml")); assertNotNull(list); Optional<DeploymentConfig> deploymentConfig = findFirst(list, DeploymentConfig.class); assertTrue(deploymentConfig.isPresent()); DeploymentConfig d = deploymentConfig.get(); List<Container> containers = d.getSpec().getTemplate().getSpec().getContainers(); assertEquals(1, containers.size()); Container container = containers.get(0); assertEquals(1, container.getPorts().size()); assertEquals("http", container.getPorts().get(0).getName()); assertEquals(8080, container.getPorts().get(0).getContainerPort()); HTTPGetAction livenessProbe = container.getLivenessProbe().getHttpGet(); assertNotNull(livenessProbe); assertEquals("/health", livenessProbe.getPath()); assertEquals(8080, livenessProbe.getPort().getIntVal()); assertEquals(180, container.getLivenessProbe().getInitialDelaySeconds()); HTTPGetAction readinessProbe = container.getReadinessProbe().getHttpGet(); assertNotNull(readinessProbe); assertEquals("/health", readinessProbe.getPath()); assertEquals(8080, readinessProbe.getPort().getIntVal()); assertEquals(20, container.getReadinessProbe().getInitialDelaySeconds()); Optional<Service> service = findFirst(list, Service.class); assertTrue(service.isPresent()); ServiceSpec s = service.get().getSpec(); assertEquals(1, s.getPorts().size()); assertEquals("http", s.getPorts().get(0).getName()); assertEquals(8080, s.getPorts().get(0).getPort()); assertEquals(8080, s.getPorts().get(0).getTargetPort().getIntVal()); Optional<Route> route = findFirst(list, Route.class); assertTrue(route.isPresent()); RouteSpec r = route.get().getSpec(); assertEquals(8080, r.getPort().getTargetPort().getIntVal()); assertEquals("/", r.getPath()); }
Example #7
Source File: AbstractAddProbeDecorator.java From dekorate with Apache License 2.0 | 4 votes |
protected Actions(ExecAction execAction, TCPSocketAction tcpSocketAction, HTTPGetAction httpGetAction) { this.execAction = execAction; this.tcpSocketAction = tcpSocketAction; this.httpGetAction = httpGetAction; }