@Override protected Map<String, Object> getBindings(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { Map<String, Object> bindings = new HashMap<>(); ServiceSettings consul = endpoints.getServiceSettings(Type.CONSUL_CLIENT); bindings.put("scheme", consul.getScheme()); bindings.put("port", consul.getPort() + ""); return bindings; }
@Override protected Map<String, Object> getBindings(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { Map<String, Object> bindings = new HashMap<>(); ServiceSettings consul = endpoints.getServiceSettings(Type.CONSUL_CLIENT); bindings.put("scheme", consul.getScheme()); bindings.put("port", consul.getPort() + ""); return bindings; }
default List<String> getReadinessExecCommand(ServiceSettings settings) { return Arrays.asList("wget", "--no-check-certificate", "--spider", "-q", settings.getScheme() + "://localhost:" + settings.getPort() + settings.getHealthEndpoint()); }
default List<String> getReadinessExecCommand(ServiceSettings settings) { return Arrays.asList("wget", "--no-check-certificate", "--spider", "-q", settings.getScheme() + "://localhost:" + settings.getPort() + settings.getHealthEndpoint()); }
private Optional<URIBuilder> buildBaseUri() { if (!StringUtils.isBlank(overrideBaseUrl)) { try { return Optional.of(new URIBuilder(overrideBaseUrl)); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Illegal override baseURL: " + overrideBaseUrl, e); } } if (!StringUtils.isBlank(baseUrl)) { try { return Optional.of(new URIBuilder(baseUrl)); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Illegal baseURL: " + baseUrl, e); } } if (getScheme() != null && getPort() != null && getAddress() != null) { return Optional.of(new URIBuilder() .setScheme(getScheme()) .setPort(getPort()) .setHost(getAddress())); } return Optional.empty(); }
private Optional<URIBuilder> buildBaseUri() { if (!StringUtils.isBlank(overrideBaseUrl)) { try { return Optional.of(new URIBuilder(overrideBaseUrl)); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Illegal override baseURL: " + overrideBaseUrl, e); } } if (!StringUtils.isBlank(baseUrl)) { try { return Optional.of(new URIBuilder(baseUrl)); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Illegal baseURL: " + baseUrl, e); } } if (getScheme() != null && getPort() != null && getAddress() != null) { return Optional.of(new URIBuilder() .setScheme(getScheme()) .setPort(getPort()) .setHost(getAddress())); } return Optional.empty(); } }
@JsonIgnore public String getMetricsUrl() { URIBuilder builder = new URIBuilder() .setScheme(getScheme()) .setPort(getPort()) .setHost("localhost") .setPath("spectator/metrics"); if (getBasicAuthEnabled() != null && getBasicAuthEnabled()) { builder.setUserInfo(getUsername(), getPassword()); } try { return builder.build().toString(); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Could not build metrics endpoint. This is probably a bug.", e); } }
@JsonIgnore public String getMetricsUrl() { URIBuilder builder = new URIBuilder() .setScheme(getScheme()) .setPort(getPort()) .setHost("localhost") .setPath("spectator/metrics"); if (getBasicAuthEnabled() != null && getBasicAuthEnabled()) { builder.setUserInfo(getUsername(), getPassword()); } try { return builder.build().toString(); } catch (URISyntaxException e) { throw new HalException(Problem.Severity.FATAL, "Could not build metrics endpoint. This is probably a bug.", e); } }
@Override public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { List<Profile> profiles = super.getProfiles(deploymentConfiguration, endpoints); ServiceSettings settings = endpoints.getServiceSettings(getService()); profiles.add(shutdownScriptProfileFactoryBuilder.build( "wget --header=\"content-type: application/json\" --post-data='{\"enabled\": \"false\"}' " + settings.getScheme() + "://localhost:" + settings.getPort() + "/admin/instance/enabled\n\n" + "sleep " + terminationGracePeriodSeconds() / 2 + "\n", getArtifact() ).getProfile("orca/shutdown.sh", shutdownScriptFile(), deploymentConfiguration, endpoints)); return profiles; }
@Override public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { List<Profile> profiles = super.getProfiles(deploymentConfiguration, endpoints); ServiceSettings settings = endpoints.getServiceSettings(getService()); profiles.add(shutdownScriptProfileFactoryBuilder.build( "wget --header=\"content-type: application/json\" --post-data='{\"enabled\": \"false\"}' " + settings.getScheme() + "://localhost:" + settings.getPort() + "/admin/instance/enabled\n\n" + "sleep " + terminationGracePeriodSeconds() / 2 + "\n", getArtifact() ).getProfile("orca/shutdown.sh", shutdownScriptFile(), deploymentConfiguration, endpoints)); return profiles; }
String scheme = settings.getScheme(); if (StringUtils.isNotEmpty(scheme)) { scheme = scheme.toUpperCase();
String scheme = settings.getScheme(); if (StringUtils.isNotEmpty(scheme)) { scheme = scheme.toUpperCase();
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { ConsulCheck check = new ConsulCheck() .setId("default-hal-check") .setInterval("30s"); if (settings.getHealthEndpoint() != null) { check.setHttp(new URIBuilder() .setScheme(settings.getScheme()) .setHost("localhost") .setPort(settings.getPort()) .setPath(settings.getHealthEndpoint()) .toString() ); } else { check.setTcp("localhost:" + settings.getPort()); } ConsulService consulService = new ConsulService() .setName(type.getCanonicalName()) .setPort(settings.getPort()) .setChecks(Collections.singletonList(check)); ServiceWrapper serviceWrapper = new ServiceWrapper().setService(consulService); try { profile.appendContents(objectMapper.writeValueAsString(serviceWrapper)); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) { ConsulCheck check = new ConsulCheck() .setId("default-hal-check") .setInterval("30s"); if (settings.getHealthEndpoint() != null) { check.setHttp(new URIBuilder() .setScheme(settings.getScheme()) .setHost("localhost") .setPort(settings.getPort()) .setPath(settings.getHealthEndpoint()) .toString() ); } else { check.setTcp("localhost:" + settings.getPort()); } ConsulService consulService = new ConsulService() .setName(type.getCanonicalName()) .setPort(settings.getPort()) .setChecks(Collections.singletonList(check)); ServiceWrapper serviceWrapper = new ServiceWrapper().setService(consulService); try { profile.appendContents(objectMapper.writeValueAsString(serviceWrapper)); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
KubernetesHandler handler = new KubernetesHandler(); int port = settings.getPort(); String scheme = settings.getScheme(); if (StringUtils.isNotEmpty(scheme)) { scheme = scheme.toUpperCase();
KubernetesHandler handler = new KubernetesHandler(); int port = settings.getPort(); String scheme = settings.getScheme(); if (StringUtils.isNotEmpty(scheme)) { scheme = scheme.toUpperCase();
@Override default <S> S connectToInstance(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings, SpinnakerService<S> sidecar, String instanceId) { ServiceSettings settings = runtimeSettings.getServiceSettings(sidecar); String namespace = getNamespace(settings); int localPort = SocketUtils.findAvailableTcpPort(); int targetPort = settings.getPort(); List<String> command = KubernetesV1ProviderUtils.kubectlPortForwardCommand(details, namespace, instanceId, targetPort, localPort); JobRequest request = new JobRequest().setTokenizedCommand(command); String jobId = getJobExecutor().startJob(request); // Wait for the proxy to spin up. DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5)); JobStatus status = getJobExecutor().updateJob(jobId); // This should be a long-running job. if (status.getState() == JobStatus.State.COMPLETED) { throw new HalException(Problem.Severity.FATAL, "Unable to establish a proxy against " + getServiceName() + ":\n" + status.getStdOut() + "\n" + status.getStdErr()); } return getServiceInterfaceFactory().createService(settings.getScheme() + "://localhost:" + localPort, sidecar); }
@Override default <S> S connectToInstance(AccountDeploymentDetails<KubernetesAccount> details, SpinnakerRuntimeSettings runtimeSettings, SpinnakerService<S> sidecar, String instanceId) { ServiceSettings settings = runtimeSettings.getServiceSettings(sidecar); String namespace = getNamespace(settings); int localPort = SocketUtils.findAvailableTcpPort(); int targetPort = settings.getPort(); List<String> command = KubernetesV1ProviderUtils.kubectlPortForwardCommand(details, namespace, instanceId, targetPort, localPort); JobRequest request = new JobRequest().setTokenizedCommand(command); String jobId = getJobExecutor().startJob(request); // Wait for the proxy to spin up. DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(5)); JobStatus status = getJobExecutor().updateJob(jobId); // This should be a long-running job. if (status.getState() == JobStatus.State.COMPLETED) { throw new HalException(Problem.Severity.FATAL, "Unable to establish a proxy against " + getServiceName() + ":\n" + status.getStdOut() + "\n" + status.getStdErr()); } return getServiceInterfaceFactory().createService(settings.getScheme() + "://localhost:" + localPort, sidecar); }