private String md5sum(HasMetadata obj) throws NoSuchAlgorithmException, JsonProcessingException { byte[] digest = MessageDigest.getInstance("MD5").digest(dumpWithoutRuntimeStateAsYaml(obj).getBytes()); BigInteger i = new BigInteger(1, digest); return String.format("%1$032x", i); }
public static String dumpAsYaml(HasMetadata obj) throws JsonProcessingException { return getMapper().writeValueAsString(obj); }
public static String dumpWithoutRuntimeStateAsYaml(HasMetadata obj) throws JsonProcessingException { return getStatelessMapper().writeValueAsString(obj); }
log("Get RC by name in namespace", gotRc); log("Dump RC as YAML", SerializationUtils.dumpAsYaml(gotRc)); log("Dump RC as YAML without state", SerializationUtils.dumpWithoutRuntimeStateAsYaml(gotRc));
log(SerializationUtils.dumpAsYaml(pod)); } catch (Exception e) { log("Exception occurred: ", e.getMessage());
private String md5sum(HasMetadata obj) throws NoSuchAlgorithmException, JsonProcessingException { byte[] digest = MessageDigest.getInstance("MD5").digest(dumpWithoutRuntimeStateAsYaml(obj).getBytes()); BigInteger i = new BigInteger(1, digest); return String.format("%1$032x", i); }
public static String dumpWithoutRuntimeStateAsYaml(HasMetadata obj) throws JsonProcessingException { return getStatelessMapper().writeValueAsString(obj); }
public static String dumpAsYaml(HasMetadata obj) throws JsonProcessingException { return getMapper().writeValueAsString(obj); }
private void generate(JobModel jobModel) throws KubernetesPluginException { try { String jobContent; if (isBlank(jobModel.getSchedule())) { jobContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(getJob(jobModel)); } else { jobContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(getCronJob(jobModel)); } KubernetesUtils.writeToFile(jobContent, JOB_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while generating yaml file for job " + jobModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
private void generate(ConfigMapModel configMapModel) throws KubernetesPluginException { ConfigMap configMap = new ConfigMapBuilder() .withNewMetadata() .withName(configMapModel.getName()) .withNamespace(dataHolder.getNamespace()) .endMetadata() .withData(configMapModel.getData()) .build(); try { String configMapContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(configMap); KubernetesUtils.writeToFile(configMapContent, CONFIG_MAP_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while parsing yaml file for config map: " + configMapModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
private void generate(SecretModel secretModel) throws KubernetesPluginException { Secret secret = new SecretBuilder() .withNewMetadata() .withNamespace(dataHolder.getNamespace()) .withName(secretModel.getName()) .endMetadata() .withData(secretModel.getData()) .build(); try { String secretContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(secret); KubernetesUtils.writeToFile(secretContent, SECRET_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while generating yaml file for secret: " + secretModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
/** * Generate resource quota files. * @param resourceQuotaModel Resource quota models. * @throws KubernetesPluginException Error when writing to file. */ private void generate(ResourceQuotaModel resourceQuotaModel) throws KubernetesPluginException { ResourceQuota resourceQuota = new ResourceQuotaBuilder() .withNewMetadata() .withName(resourceQuotaModel.getName()) .withLabels(resourceQuotaModel.getLabels()) .endMetadata() .withNewSpec() .withHard(getHard(resourceQuotaModel.getHard())) .withScopes(new ArrayList<>(resourceQuotaModel.getScopes())) .endSpec() .build(); try { String resourceQuotaContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(resourceQuota); KubernetesUtils.writeToFile(resourceQuotaContent, RESOURCE_QUOTA_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while generating yaml file for resource quotas: " + resourceQuotaModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
private void generate(PersistentVolumeClaimModel volumeClaimModel) throws KubernetesPluginException { Quantity quantity = new QuantityBuilder() .withAmount(volumeClaimModel.getVolumeClaimSize()) .build(); Map<String, Quantity> requests = new HashMap<>(); requests.put("storage", quantity); PersistentVolumeClaim claim = new PersistentVolumeClaimBuilder() .withNewMetadata() .withName(volumeClaimModel.getName()) .withNamespace(dataHolder.getNamespace()) .withAnnotations(volumeClaimModel.getAnnotations()) .endMetadata() .withNewSpec() .withAccessModes(volumeClaimModel.getAccessMode()) .withNewResources() .withRequests(requests) .endResources() .endSpec() .build(); try { String claimContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(claim); KubernetesUtils.writeToFile(claimContent, VOLUME_CLAIM_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while generating yaml file for volume claim: " + volumeClaimModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
String ingressYAML; try { ingressYAML = SerializationUtils.dumpWithoutRuntimeStateAsYaml(ingress); KubernetesUtils.writeToFile(ingressYAML, INGRESS_FILE_POSTFIX + YAML); } catch (IOException e) {
private void generate(PodAutoscalerModel podAutoscalerModel) throws KubernetesPluginException { HorizontalPodAutoscaler horizontalPodAutoscaler = new HorizontalPodAutoscalerBuilder() .withNewMetadata() .withName(podAutoscalerModel.getName()) .withNamespace(dataHolder.getNamespace()) .withLabels(podAutoscalerModel.getLabels()) .endMetadata() .withNewSpec() .withMaxReplicas(podAutoscalerModel.getMaxReplicas()) .withMinReplicas(podAutoscalerModel.getMinReplicas()) .withTargetCPUUtilizationPercentage(podAutoscalerModel.getCpuPercentage()) .withNewScaleTargetRef("extensions/v1beta1", "Deployment", podAutoscalerModel.getDeployment()) .endSpec() .build(); try { String serviceContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(horizontalPodAutoscaler); KubernetesUtils.writeToFile(serviceContent, HPA_FILE_POSTFIX + YAML); } catch (IOException e) { String errorMessage = "Error while generating yaml file for autoscaler: " + podAutoscalerModel.getName(); throw new KubernetesPluginException(errorMessage, e); } }
.build(); try { String serviceYAML = SerializationUtils.dumpWithoutRuntimeStateAsYaml(service); KubernetesUtils.writeToFile(serviceYAML, SVC_FILE_POSTFIX + YAML); } catch (IOException e) {
String deploymentContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(deployment); KubernetesUtils.writeToFile(deploymentContent, DEPLOYMENT_FILE_POSTFIX + YAML); } catch (IOException e) {