io.fabric8.kubernetes.api.model.HTTPHeader Java Examples
The following examples show how to use
io.fabric8.kubernetes.api.model.HTTPHeader.
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: VertxHealthCheckEnricherTest.java From jkube with Eclipse Public License 2.0 | 6 votes |
@Test public void testWithHttpHeaders() { final Map<String, Object> config = createFakeConfig("{\"path\":\"health\",\"headers\":{\"X-Header\":\"X\",\"Y-Header\":\"Y\"}}"); setupExpectations(config); VertxHealthCheckEnricher enricher = new VertxHealthCheckEnricher(context); Probe probe = enricher.getLivenessProbe(); assertNotNull(probe); assertEquals(probe.getHttpGet().getPath(), "/health"); assertThat(probe.getHttpGet().getPort().getIntVal()).isEqualTo(8080); assertThat(probe.getHttpGet().getHttpHeaders()).hasSize(2) .contains(new HTTPHeader("X-Header", "X"), new HTTPHeader("Y-Header", "Y")); probe = enricher.getReadinessProbe(); assertNotNull(probe); assertEquals(probe.getHttpGet().getPath(), "/health"); assertThat(probe.getHttpGet().getPort().getIntVal()).isEqualTo(8080); assertThat(probe.getHttpGet().getHttpHeaders()).hasSize(2) .contains(new HTTPHeader("X-Header", "X"), new HTTPHeader("Y-Header", "Y")); }
Example #2
Source File: ProbeCreator.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 6 votes |
Probe create() { HTTPGetActionBuilder httpGetActionBuilder = new HTTPGetActionBuilder() .withPath(getProbePath()) .withNewPort(getPort()); List<HTTPHeader> httpHeaders = getHttpHeaders(); if (!httpHeaders.isEmpty()) { httpGetActionBuilder.withHttpHeaders(httpHeaders); } return new ProbeBuilder() .withHttpGet(httpGetActionBuilder.build()) .withTimeoutSeconds(getTimeout()) .withInitialDelaySeconds(getInitialDelay()) .withPeriodSeconds(getPeriod()) .build(); }
Example #3
Source File: ProbeCreator.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
private List<HTTPHeader> getHttpHeaders() { List<HTTPHeader> httpHeaders = new ArrayList<>(); HTTPHeader authenticationHeader = getAuthorizationHeader(); if (authenticationHeader != null) { httpHeaders.add(authenticationHeader); } return httpHeaders; }
Example #4
Source File: DefaultContainerFactoryTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 5 votes |
@Test public void testProbeCredentialsSecret() throws Exception { Secret secret = randomSecret(); String secretName = secret.getMetadata().getName(); Map<String,String> appProperties = new HashMap<>(); appProperties.put("spring.cloud.deployer.kubernetes.probeCredentialsSecret", secretName); AppDefinition definition = new AppDefinition("app-test", appProperties); AppDeploymentRequest appDeploymentRequest = new AppDeploymentRequest(definition, getResource(), appProperties); ContainerConfiguration containerConfiguration = new ContainerConfiguration("app-test", appDeploymentRequest) .withExternalPort(8080) .withProbeCredentialsSecret(secret); ContainerFactory containerFactory = new DefaultContainerFactory(new KubernetesDeployerProperties()); Container container = containerFactory.create(containerConfiguration); String credentials = containerConfiguration.getProbeCredentialsSecret().getData() .get(ProbeCreator.PROBE_CREDENTIALS_SECRET_KEY_NAME); HTTPHeader livenessProbeHeader = container.getLivenessProbe().getHttpGet().getHttpHeaders().get(0); assertEquals(ProbeCreator.AUTHORIZATION_HEADER_NAME, livenessProbeHeader.getName()); assertEquals(ProbeAuthenticationType.Basic.name() + " " + credentials, livenessProbeHeader.getValue()); HTTPHeader readinessProbeHeader = container.getReadinessProbe().getHttpGet().getHttpHeaders().get(0); assertEquals(ProbeCreator.AUTHORIZATION_HEADER_NAME, readinessProbeHeader.getName()); assertEquals(ProbeAuthenticationType.Basic.name() + " " + credentials, readinessProbeHeader.getValue()); }