public static DoneablePod createDoneablePodDefaultImpl(PodConfiguration config) { DoneablePod doneablePod = config.getClient().pods() .createNew() .withNewMetadata() .withGenerateName(config.getContainerIdPrefix())
private void ensureCredentialsExist(NamespacedOpenShiftClient client, ServiceBrokerOptions options) { Secret secret = client.secrets().withName(options.getServiceCatalogCredentialsSecretName()).get(); if (secret == null) { client.secrets().createNew() .editOrNewMetadata() .withName(options.getServiceCatalogCredentialsSecretName()) .addToLabels("app", "enmasse") .endMetadata() .addToData("token", Base64.getEncoder().encodeToString(client.getConfiguration().getOauthToken().getBytes(StandardCharsets.UTF_8))) .done(); } }
client.services().createNew().withNewMetadata().withName(appId) .withLabels(idMap).withAnnotations(annotations).addToLabels(SPRING_MARKER_KEY, SPRING_MARKER_VALUE) .endMetadata().withSpec(spec.build()).done();
private void launchPod(String appId, PodSpec podSpec, Map<String, String> labelMap, Map<String, String> idMap, Map<String, String> annotations) { client.pods() .createNew() .withNewMetadata() .withName(appId) .withLabels(labelMap) .withAnnotations(annotations) .addToLabels(idMap) .endMetadata() .withSpec(podSpec) .done(); }
private static void ensureRouteExists(NamespacedOpenShiftClient client, ServiceBrokerOptions serviceBrokerOptions) throws IOException { Route proxyRoute = client.routes().withName(serviceBrokerOptions.getConsoleProxyRouteName()).get(); if (proxyRoute == null) { String caCertificate = new String(Files.readAllBytes(new File(serviceBrokerOptions.getCertDir(), "tls.crt").toPath()), StandardCharsets.UTF_8); client.routes().createNew() .editOrNewMetadata() .withName(serviceBrokerOptions.getConsoleProxyRouteName()) .addToLabels("app", "enmasse") .endMetadata() .editOrNewSpec() .editOrNewPort() .withNewTargetPort("https") .endPort() .editOrNewTo() .withKind("Service") .withName("service-broker") .endTo() .editOrNewTls() .withTermination("reencrypt") .withCaCertificate(caCertificate) .endTls() .endSpec() .done(); } }
private void launchJob(String appId, PodSpec podSpec, Map<String, String> podLabelMap, Map<String, String> idMap, Map<String, String> annotations) { ObjectMeta objectMeta = new ObjectMetaBuilder().withLabels(podLabelMap).addToLabels(idMap).build(); PodTemplateSpec podTemplateSpec = new PodTemplateSpec(objectMeta, podSpec); JobSpec jobSpec = new JobSpecBuilder() .withTemplate(podTemplateSpec) .build(); client.batch().jobs() .createNew() .withNewMetadata() .withName(appId) .withLabels(Collections.singletonMap("task-name", podLabelMap.get("task-name"))) .addToLabels(idMap) .withAnnotations(annotations) .endMetadata() .withSpec(jobSpec) .done(); }
if (certSecret != null) { String caCertificate = new String(Base64.getDecoder().decode(certSecret.getData().get("tls.crt")), StandardCharsets.UTF_8); client.routes().createNew() .editOrNewMetadata() .withName(getKeycloakRouteName(env))
Pod p = client.pods().createNew() .withNewMetadata() .withName(podTemplate.getName())
log.info("Creating REST API external route {}", options.getRestapiRouteName()); String caCertificate = new String(Files.readAllBytes(new File(options.getCertDir(), "tls.crt").toPath()), StandardCharsets.UTF_8); client.routes().createNew() .editOrNewMetadata() .withName(options.getRestapiRouteName()) if (restapiService == null) { log.info("Creating REST API external service {}", options.getRestapiRouteName()); client.services().createNew() .editOrNewMetadata() .withName(options.getRestapiRouteName())
private static void ensurePersistentVolumeClaimExists(NamespacedOpenShiftClient client, Map<String, String> env) { String pvcName = getKeycloakPvcName(env); String pvcStorageSize = getKeycloakPvcStorageSize(env); PersistentVolumeClaim pvc = client.persistentVolumeClaims().withName(pvcName).get(); if (pvc == null) { client.persistentVolumeClaims().createNew() .editOrNewMetadata() .withName(pvcName) .addToLabels("app", "enmasse") .endMetadata() .editOrNewSpec() .addToAccessModes("ReadWriteOnce") .editOrNewResources() .addToRequests("storage", new Quantity(pvcStorageSize)) .endResources() .endSpec() .done(); } }