Commit 754d27a8 authored by Christos Tranoris's avatar Christos Tranoris
Browse files

adding new spec param for values yaml

parent 171fe4b2
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
eclipse.preferences.version=1
encoding//src/main/java=utf-8
encoding//src/main/resources=utf-8
encoding//src/test/java=utf-8
encoding//src/test/resources=utf-8
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
+25 −2
Original line number Diff line number Diff line
@@ -371,8 +371,15 @@ public class SylvaMDResourceOperator {
    createEmptyFile(deploymentFolder + "/secrets.yaml");

    // Step 3: Modify values.yaml using SylvaMDResourceSpec
    
    if ( resourceClone.getSpec().getValuesyaml() != null ) {
      populateFileFromText(namespace, resourceClone.getSpec().getValuesyaml(),
          deploymentFolder + "/values.yaml");      
    }else {
      populateAndModifyValuesYaml(namespace, "values.sylvamd.configmaps.osl.etsi.org",
          deploymentFolder + "/values.yaml", resourceClone.getSpec());      
    }
    

    // Step 4: Populate kustomization.yaml and secrets.yaml from ConfigMaps
    populateFileFromConfigMap(namespace, "kustomization.sylvamd.configmaps.osl.etsi.org",
@@ -488,6 +495,22 @@ public class SylvaMDResourceOperator {
    }
  }
  

  private void populateFileFromText(String namespace, String text, String filePath) {
    try {

      if (text != null ) {
        String content = text;
        Files.write(Paths.get(filePath), content.getBytes());
        log.info("Populated file {} from text {}", filePath, text);
      } else {
        log.error("Failed to write text: {}", text);
      }
    } catch (IOException e) {
      log.error("Error writing to file: {}", filePath, e);
    }
  }

  // Execute the shell script to apply the workload with the working directory set to
  // /opt/sylva-core
  private SylvaMDResource executeShellScriptApplyWC(String deploymentFolderPath,
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ public class SylvaMDResourceSpec {

  private int clusterControlPlaneReplicas;
  private int clusterMd0Replicas;
  private String valuesyaml;
  
  
}
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ spec:
            spec:
              type: object
              properties:
                valuesyaml:
                  type: string
                clusterControlPlaneReplicas:
                  type: string
                clusterMd0Replicas:
+54 −0
Original line number Diff line number Diff line
apiVersion: controllers.osl.etsi.org/v1alpha1
kind: SylvaMDResource
metadata:
  name: wc67890-bbccdd
spec:
  valuesyaml: |
    ---
    cluster:

      capi_providers:
        infra_provider: capo
        bootstrap_provider: cabpr

      capo:
        image_key: ubuntu-jammy-plain-rke2-1-28-8  # OpenStack Glance image (key of image in sylva_diskimagebuilder_images/os_images)
        ssh_key_name: sylva # OpenStack Nova SSH keypair is provided by runner context in CI
        network_id: 7b490a0c-0f5c-4475-a436-e4bcbecc7f5e # OpenStack Neutron network id is provided by runner context in CI
        flavor_name: cpu8.m16384.d40g
        control_plane_az:
          - nova

      machine_deployments:
        md0:
          replicas: 2
          capo:
            failure_domain: nova
            flavor_name: cpu8.m16384.d40g

      control_plane_replicas: 1

    openstack:
      control_plane_affinity_policy: soft-anti-affinity
      storageClass:
        name: "rbd1"
        type: "rbd1"

    proxies:
      http_proxy: ""
      https_proxy: ""
      no_proxy: ""

    ntp:
      enabled: false
      servers:
      # - 1.2.3.4
      # - 1.2.3.5

    sylva_diskimagebuilder_images:
     ubuntu-jammy-plain-rke2-1-28-8:
        enabled: true

     ubuntu-jammy-plain-kubeadm-1-28-9:
        enabled: true
Loading