Feature: 11055 Support of several node groups in clusters created by OSM

	- Added control plane support in managed post
	- When aws vim account is selected paylaod will get differed
	- Added details page in clusters to view node and ksu for
	  specified cluster
	- Fixed Bug 2402 - Unable to create Ns Config template from Ui
	  bug by chnaging api

Change-Id: I4eb327fd86b0c4a706b05a8ed10524e4d2c5bc95
Signed-off-by: SANDHYA.JS <sandhya.j@tataelxsi.co.in>
diff --git a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html
index e9ac743..73f1038 100644
--- a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html
+++ b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.html
@@ -15,7 +15,7 @@
 
 Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in)
 -->
-<form [formGroup]="k8sclusterForm" (ngSubmit)="k8sAddClusterSubmit();">
+<form [formGroup]="k8sclusterForm" (ngSubmit)="k8sAddClusterSubmit();" (keydown.enter)="$event.preventDefault()">
   <div class="modal-header">
     <h4 *ngIf="profileType === 'Register'" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.REGISTERCLUSTER' |
       translate}}
@@ -23,7 +23,7 @@
     <h4 *ngIf="profileType === 'Manage'" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.CREATECLUSTER' |
       translate}}
     </h4>
-    <h4 *ngIf="profileType === 'upgrade'" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.UPGRADECLUSTER' |
+    <h4 *ngIf="profileType === 'upgrade'" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.VERSIONUPGRADE' |
       translate}}
     </h4>
     <h4 *ngIf="profileType === 'update'" class="modal-title" id="modal-basic-title">{{'PAGE.K8S.UPDATECLUSTER' |
@@ -33,7 +33,8 @@
       <i class="fas fa-times-circle text-danger"></i>
     </button>
   </div>
-  <div class="modal-body modal-body-custom-height">
+  <div class="modal-body modal-body-custom-height"
+    *ngIf="profileType === 'Manage' || profileType === 'Register' || isChecked || profileType === 'upgrade'">
     <div class="form-group row mb-3" *ngIf="profileType === 'Manage' || profileType === 'Register'">
       <div class="col-sm-12">
         <label class="form-check-label">
@@ -71,6 +72,15 @@
           required>
       </div>
     </div>
+    <div class="form-group row mb-3"
+      *ngIf="profileType === 'Manage' || profileType === 'Register' || !isChecked || profileType === 'update'">
+      <label class="col-sm-4 col-form-label" for="description">{{'PAGE.K8S.DESCRIPTION' | translate}}</label>
+      <div class="col-sm-8">
+        <textarea class="form-control" placeholder="{{'PAGE.K8S.DESCRIPTION' | translate}}" type="text"
+          formControlName="description" id="description"
+          [ngClass]="{ 'is-invalid': submitted && f.description.errors }"></textarea>
+      </div>
+    </div>
     <div class="form-group row mb-3" *ngIf="profileType === 'Manage' || profileType === 'Register' || !isChecked">
       <label class="col-sm-4 col-form-label" for="vim_account">{{'PAGE.K8S.VIMACCOUNT' | translate}}*</label>
       <div class="col-sm-8">
@@ -81,6 +91,45 @@
         </ng-select>
       </div>
     </div>
+    <div class="form-group row mb-3" *ngIf=" vimType === 'aws' && profileType === 'Manage'">
+      <label class="col-sm-4 col-form-label" for="k8s_version">{{'PAGE.K8S.ROLENAME' | translate}}</label>
+      <div class="col-sm-8">
+        <input autocomplete="off" class="form-control" placeholder="{{'arn:aws:iam::[account-id]:role/[role-name]' | translate}}" type="text"
+          formControlName="iam_role" id="iam_role" [ngClass]="{ 'is-invalid': submitted && f.iam_role.errors }">
+      </div>
+    </div>
+    <div class="form-group row mb-3" *ngIf=" vimType === 'aws' && profileType === 'Manage'">
+      <label class="col-sm-4 col-form-label" for="private_subnet">{{ 'PAGE.K8S.PRIVATESUBNET' | translate }}</label>
+      <div class="col-sm-8">
+        <div class="chip-input-container">
+          <div formArrayName="private_subnet" class="chips-wrapper">
+            <span class="chip" *ngFor="let chip of chipsprivateArray.controls; let i = index">
+              {{ chip.value }}
+              <button type="button" (click)="removeprivateChip(i)">x</button>
+            </span>
+            <input #inputField autocomplete="off" class="form-control chip-input" id="private_subnet"
+              (keyup.enter)="addprivateChips()" (keydown.backspace)="removeprivateLastChip($event)"
+              placeholder="Type and press Enter">
+          </div>
+        </div>
+      </div>
+    </div>
+    <div class="form-group row mb-3" *ngIf=" vimType === 'aws' && profileType === 'Manage'">
+      <label class="col-sm-4 col-form-label" for="public_subnet">{{ 'PAGE.K8S.PUBLICSUBNET' | translate }}</label>
+      <div class="col-sm-8">
+        <div class="chip-input-container">
+          <div formArrayName="public_subnet" class="chips-wrapper">
+            <span class="chip" *ngFor="let chip of chipspublicArray.controls; let i = index">
+              {{ chip.value }}
+              <button type="button" (click)="removepublicChip(i)">x</button>
+            </span>
+            <input #inputField autocomplete="off" class="form-control chip-input" id="public_subnet"
+              (keyup.enter)="addpublicChips()" (keydown.backspace)="removepublicLastChip($event)"
+              placeholder="Type and press Enter">
+          </div>
+        </div>
+      </div>
+    </div>
     <div class="form-group row mb-3" *ngIf="!isChecked && profileType === 'Register'">
       <label class="col-sm-4 col-form-label" for="deployment_methods">{{'PAGE.K8S.DEPLOYMENTMETHODS' |
         translate}}*</label>
@@ -92,14 +141,6 @@
         </ng-select>
       </div>
     </div>
-    <div class="form-group row mb-3" *ngIf="profileType === 'Manage' || profileType === 'Register' || !isChecked || profileType === 'update'">
-      <label class="col-sm-4 col-form-label" for="description">{{'PAGE.K8S.DESCRIPTION' | translate}}</label>
-      <div class="col-sm-8">
-        <textarea class="form-control" placeholder="{{'PAGE.K8S.DESCRIPTION' | translate}}" type="text"
-          formControlName="description" id="description"
-          [ngClass]="{ 'is-invalid': submitted && f.description.errors }"></textarea>
-      </div>
-    </div>
     <div class="form-group row mb-3" *ngIf="!isChecked && profileType === 'Register'">
       <label class="col-sm-4 col-form-label" for="nets">{{'PAGE.K8S.NETS' | translate}}*</label>
       <div class="col-sm-8">
@@ -125,7 +166,7 @@
         </div>
       </div>
     </div>
-    <div class="form-group row mb-3" *ngIf="profileType === 'Manage'">
+    <div class="form-group row mb-3" *ngIf="vimType === 'aws' && profileType === 'Manage'">
       <label class="col-sm-4 col-form-label" for="k8s_version">{{'PAGE.K8S.REGIONNAME' | translate}}</label>
       <div class="col-sm-8">
         <input autocomplete="off" class="form-control" placeholder="{{'PAGE.K8S.REGIONNAME' | translate}}" type="text"
@@ -133,7 +174,7 @@
           [ngClass]="{ 'is-invalid': submitted && f.region_name.errors }">
       </div>
     </div>
-    <div class="form-group row mb-3" *ngIf="profileType === 'Manage'">
+    <div class="form-group row mb-3" *ngIf="profileType === 'Manage' && vimType !== 'aws' ">
       <label class="col-sm-4 col-form-label" for="k8s_version">{{'PAGE.K8S.RESOURCEGROUP' | translate}}</label>
       <div class="col-sm-8">
         <input autocomplete="off" class="form-control" placeholder="{{'PAGE.K8S.RESOURCEGROUP' | translate}}"
@@ -141,20 +182,18 @@
           [ngClass]="{ 'is-invalid': submitted && f.resource_group.errors }">
       </div>
     </div>
-    <div class="form-group row mb-3" *ngIf="profileType === 'Manage'">
-      <label class="col-sm-4 col-form-label" for="node_count">{{'PAGE.K8S.NODECOUNT' | translate}}*</label>
-      <div class="col-sm-8">
-        <input autocomplete="off" class="form-control" placeholder="{{'PAGE.K8S.NODECOUNT' | translate}}" type="text"
-          formControlName="node_count" id="node_count" [ngClass]="{ 'is-invalid': submitted && f.node_count.errors }"
-          required>
-      </div>
-    </div>
-    <div class="form-group row mb-3" *ngIf="profileType === 'Manage'">
+    <div class="form-group row mb-3" *ngIf="profileType === 'Manage' && vimType !== 'aws' ">
       <label class="col-sm-4 col-form-label" for="k8s_version">{{'PAGE.K8S.NODESIZE' | translate}}*</label>
       <div class="col-sm-8">
-        <input autocomplete="off" class="form-control" placeholder="{{'PAGE.K8S.NODESIZE' | translate}}" type="text"
-          formControlName="node_size" id="k8s_version" [ngClass]="{ 'is-invalid': submitted && f.node_size.errors }"
-          required>
+        <input autocomplete="off" class="form-control" placeholder="{{'Node Size' | translate}}" type="text"
+          formControlName="node_size" id="node_size" [ngClass]="{ 'is-invalid': submitted && f.node_size.errors }">
+      </div>
+    </div>
+    <div class="form-group row mb-3" *ngIf="profileType === 'Manage' && vimType !== 'aws'">
+      <label class="col-sm-4 col-form-label" for="k8s_version">{{'PAGE.K8S.NODECOUNT' | translate}}*</label>
+      <div class="col-sm-8">
+        <input autocomplete="off" class="form-control" placeholder="{{'Node Count' | translate}}" type="text"
+          formControlName="node_count" id="node_count" [ngClass]="{ 'is-invalid': submitted && f.node_count.errors }">
       </div>
     </div>
     <div class="form-group row mb-3" *ngIf="profileType === 'upgrade'">
@@ -169,9 +208,7 @@
     <button type="button" class="btn btn-danger" (click)="activeModal.close()">{{'CANCEL' | translate}}</button>
     <button *ngIf="profileType === 'Manage'" type="submit" class="btn btn-primary">{{'CREATE' | translate}}</button>
     <button *ngIf="profileType === 'Register'" type="submit" class="btn btn-primary">{{'REGISTER' | translate}}</button>
-    <button *ngIf="profileType === 'upgrade'|| profileType === 'update'"
-      type="submit" class="btn btn-primary">{{'APPLY'
-      | translate}}</button>
+    <button *ngIf="profileType === 'upgrade' || profileType === 'update'" type="submit" class="btn btn-primary">{{'APPLY'| translate}}</button>
   </div>
 </form>
 <app-loader [waitingMessage]="message" *ngIf="isLoadingResults"></app-loader>
\ No newline at end of file
diff --git a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.scss b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.scss
index 8885be8..1fd08a8 100644
--- a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.scss
+++ b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.scss
@@ -18,42 +18,90 @@
 @import "../../../assets/scss/variable.scss";
 @import "../../../assets/scss/mixins/mixin";
 .quotacheck {
-   box-shadow: none;
-   border-radius: 2px;
-   border-color: $gray-600;
+  box-shadow: none;
+  border-radius: 2px;
+  border-color: $gray-600;
 }
 .form-check {
-   padding-left: 30px;
+  padding-left: 30px;
 }
 .quotaCheck-label {
-   position: absolute;
-   left: 26px;
+  position: absolute;
+  left: 26px;
 }
 .tooltip-icon {
-   position: relative;
-   margin-left: 5px;
-   cursor: pointer;
- }
- 
- .tooltip-icon .tooltip-text {
-   visibility: hidden;
-   width: 200px;
-   background-color: #fff;
-   color: #555;
-   text-align: center;
-   padding: 5px 10px;
-   border-radius: 4px;
-   @include border(all, 1, solid, $gray-300);
-   z-index: 1;
-   bottom: 125%;
-   left: 50%;
-   transform: translateX(-50%);
-   opacity: 0;
-   transition: opacity 0.3s;
- }
- 
- .tooltip-icon:hover .tooltip-text {
-   visibility: visible;
-   opacity: 1;
- }
- 
\ No newline at end of file
+  position: relative;
+  margin-left: 5px;
+  cursor: pointer;
+}
+.tooltip-icon .tooltip-text {
+  visibility: hidden;
+  width: 200px;
+  background-color: #fff;
+  color: #555;
+  text-align: center;
+  padding: 5px 10px;
+  border-radius: 4px;
+  @include border(all, 1, solid, $gray-300);
+  z-index: 1;
+  bottom: 125%;
+  left: 50%;
+  transform: translateX(-50%);
+  opacity: 0;
+  transition: opacity 0.3s;
+}
+.tooltip-icon:hover .tooltip-text {
+  visibility: visible;
+  opacity: 1;
+}
+.chip-input-container {
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  border: 1px solid #e9ecef;
+  padding: 5px;
+  border-radius: 5px;
+  min-height: 38px;
+  width: 100%;
+  position: relative;
+  box-sizing: border-box;
+}
+.chip-input-container:focus-within {
+  border: 1px solid #afb5c1;
+  background-color: #f2f4f5;
+}
+.chips-wrapper {
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  gap: 5px;
+  width: 100%;
+}
+.chip {
+  background: #007bff;
+  color: white;
+  padding: 5px 10px;
+  border-radius: 15px;
+  font-size: 14px;
+  display: flex;
+  align-items: center;
+  height: 28px;
+  white-space: nowrap;
+}
+.chip button {
+  background: none;
+  border: none;
+  color: white;
+  margin-left: 5px;
+  cursor: pointer;
+  font-size: 14px;
+}
+.chip-input {
+  border: none;
+  outline: none;
+  flex: 1;
+  min-width: 100px;
+  height: 28px;
+  padding: 4px;
+  background: transparent;
+}
\ No newline at end of file
diff --git a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts
index 34ceeab..69fe54f 100644
--- a/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts
+++ b/src/app/k8s/k8s-add-cluster/K8sAddClusterComponent.ts
@@ -20,7 +20,7 @@
  */
 import { HttpHeaders } from '@angular/common/http';
 import { Component, ElementRef, Injector, Input, OnInit, ViewChild } from '@angular/core';
-import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
+import { AbstractControl, FormArray, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import { TranslateService } from '@ngx-translate/core';
 import { NotifierService } from 'angular-notifier';
@@ -51,6 +51,9 @@
   /** Contains all vim account collections */
   public vimAccountSelect: VimAccountDetails;
 
+  /** Contains selected vim */
+  public vimType: string;
+
   /** Input contains Modal dialog component Instance @public */
   @Input() public profileType: string;
 
@@ -163,7 +166,7 @@
   public k8sclusterFormAction(): void {
     this.k8sclusterForm = this.formBuilder.group({
       name: ['', [Validators.required]],
-      k8s_version: ['', [Validators.required]],
+      k8s_version: [''],
       vim_account: [null, [Validators.required]],
       description: [''],
       nets: ['', [Validators.required]],
@@ -175,6 +178,9 @@
       node_size: ['', [Validators.required]],
       bootstrap: [true],
       k8sVersion: ['', [Validators.required]],
+      iam_role: [''],
+      private_subnet: this.formBuilder.array([]),
+      public_subnet: this.formBuilder.array([]),
       update: ['']
     });
   }
@@ -182,6 +188,65 @@
   /** convenience getter for easy access to form fields */
   get f(): FormGroup['controls'] { return this.k8sclusterForm.controls; }
 
+  /** convenience getter for easy access to form array privatesubnet */
+  get chipsprivateArray(): FormArray {
+    return this.k8sclusterForm.get('private_subnet') as FormArray;
+  }
+
+  /** To add privatesubnet chips */
+  public addprivateChips() {
+    const input = document.getElementById('private_subnet') as HTMLInputElement;
+    const value = input.value.trim();
+
+    if (value) {
+      this.chipsprivateArray.push(new FormControl(value));
+      input.value = '';
+    }
+  }
+  /** convenience getter for easy access to form array publicsubnet */
+  get chipspublicArray(): FormArray {
+    return this.k8sclusterForm.get('public_subnet') as FormArray;
+  }
+
+  /** To add publicsubnet chips */
+  public addpublicChips() {
+    const input = document.getElementById('public_subnet') as HTMLInputElement;
+    const value = input.value.trim();
+
+    if (value) {
+      this.chipspublicArray.push(new FormControl(value));
+      input.value = '';
+    }
+  }
+
+  /** To remove privatesubnet chips */
+  public removeprivateChip(index: number) {
+    this.chipsprivateArray.removeAt(index);
+  }
+
+  /** To remove privatesubnet last chip */
+  public removeprivateLastChip(event: KeyboardEvent) {
+    const input = event.target as HTMLInputElement;
+    if (event.key === 'Backspace' && input.value === '' && this.chipsprivateArray.length > 0) {
+      this.chipsprivateArray.removeAt(this.chipsprivateArray.length - 1); // Remove last chip if input is empty
+      event.preventDefault();
+    }
+  }
+  /** To remove publicsubnet chips */
+  public removepublicChip(index: number) {
+    this.chipspublicArray.removeAt(index);
+  }
+
+  /** To remove publicsubnet last chip */
+  public removepublicLastChip(event: KeyboardEvent) {
+    const input = event.target as HTMLInputElement;
+    if (event.key === 'Backspace' && input.value === '' && this.chipspublicArray.length > 0) {
+      this.chipspublicArray.removeAt(this.chipspublicArray.length - 1); // Remove last chip if input is empty
+      event.preventDefault();
+    }
+  }
+
+
   /** Call the vimAccount details in the selection options @public */
   public getDetailsvimAccount(): void {
     this.isLoadingResults = true;
@@ -219,6 +284,7 @@
   /** Contain selected vimAccount details @public */
   public getDetailsvim(event: VimAccountDetails): void {
     this.vimAccountId = event._id;
+    this.vimType = event.vim_type;
   }
 
   /** On modal submit k8sAddClusterSubmit will called @public */
@@ -229,6 +295,23 @@
       this.getFormControl('deployment_methods').disable();
       this.getFormControl('k8sVersion').disable();
       this.getFormControl('update').disable();
+      this.clusterUrl = environment.K8SCREATECLUSTER_URL;
+      if (this.vimType === 'aws') {
+        this.getFormControl('resource_group').disable();
+        this.getFormControl('k8sVersion').disable();
+        this.getFormControl('node_size').disable();
+        this.getFormControl('node_count').disable();
+        this.getFormControl('nets').disable();
+        this.getFormControl('credentials').disable();
+        this.getFormControl('update').disable();
+        this.getFormControl('deployment_methods').disable();
+      } else if (this.vimType !== 'aws') {
+        this.getFormControl('nets').disable();
+        this.getFormControl('credentials').disable();
+        this.getFormControl('deployment_methods').disable();
+        this.getFormControl('k8sVersion').disable();
+        this.getFormControl('update').disable();
+      }
       this.manageCluster();
     } else if (this.profileType === 'Register' && this.isChecked === true) {
       this.clusterUrl = environment.K8SCREATECLUSTER_URL + '/register';
@@ -240,6 +323,9 @@
       this.getFormControl('nets').disable();
       this.getFormControl('deployment_methods').disable();
       this.getFormControl('k8sVersion').disable();
+      this.getFormControl('iam_role').disable();
+      this.getFormControl('private_subnet').disable();
+      this.getFormControl('public_subnet').disable();
       this.getFormControl('update').disable();
       this.registerCluster();
     } if (this.isChecked === false && this.profileType === 'Register') {
@@ -250,6 +336,9 @@
       this.getFormControl('node_count').disable();
       this.getFormControl('node_size').disable();
       this.getFormControl('k8sVersion').disable();
+      this.getFormControl('iam_role').disable();
+      this.getFormControl('private_subnet').disable();
+      this.getFormControl('public_subnet').disable();
       this.getFormControl('update').disable();
       this.oldregisterCluster();
     } else if (this.profileType === 'upgrade') {
@@ -265,7 +354,9 @@
       this.getFormControl('bootstrap').disable();
       this.getFormControl('node_count').disable();
       this.getFormControl('node_size').disable();
-      this.getFormControl('k8s_version').disable();
+      this.getFormControl('iam_role').disable();
+      this.getFormControl('private_subnet').disable();
+      this.getFormControl('public_subnet').disable();
       this.getFormControl('update').disable();
       this.updateCluster();
     } else if (this.profileType === 'update') {
@@ -281,8 +372,10 @@
       this.getFormControl('node_size').disable();
       this.getFormControl('k8s_version').disable();
       this.getFormControl('k8sVersion').disable();
+      this.getFormControl('iam_role').disable();
+      this.getFormControl('private_subnet').disable();
+      this.getFormControl('public_subnet').disable();
       this.getFormControl('name').disable();
-
       this.editCluster();
     }
   }
@@ -375,7 +468,6 @@
     if (this.k8sclusterForm.value.description === '') {
       delete this.k8sclusterForm.value.description;
     }
-
     const apiURLHeader: APIURLHEADER = {
       url: this.clusterUrl,
       httpOptions: { headers: this.headers }
@@ -393,7 +485,7 @@
     });
   }
 
-  /** Manage cluster @public */
+  /** controlplane cluster flow @public */
   public manageCluster(): void {
     this.submitted = true;
     this.sharedService.cleanForm(this.k8sclusterForm);
@@ -404,36 +496,51 @@
       message: 'Done'
     };
     const apiURLHeader: APIURLHEADER = {
-      url: environment.K8SCREATECLUSTER_URL,
+      url: this.clusterUrl,
       httpOptions: { headers: this.headers }
     };
 
     this.isLoadingResults = true;
-    const payload: K8SPayload = {
-      name: this.k8sclusterForm.value.name,
-      vim_account: this.k8sclusterForm.value.vim_account,
-      location: this.k8sclusterForm.value.location,
-      region_name: this.k8sclusterForm.value.region_name,
-      resource_group: this.k8sclusterForm.value.resource_group,
-      k8s_version: this.k8sclusterForm.value.k8s_version,
-      node_size: this.k8sclusterForm.value.node_size,
-      node_count: Number(this.k8sclusterForm.value.node_count),
-      description: this.k8sclusterForm.value.description,
-      bootstrap: Boolean(this.k8sclusterForm.value.bootstrap)
-    };
-    if (this.k8sclusterForm.value.region_name === '') {
-      delete payload.region_name;
-    } else if (this.k8sclusterForm.value.resource_group === '') {
-      delete payload.resource_group;
-    } else if (this.k8sclusterForm.value.description === '') {
-      delete payload.description;
+    const formData = this.k8sclusterForm.value;
+    if (this.k8sclusterForm.value.private_subnet.length <= 0) {
+      delete this.k8sclusterForm.value.private_subnet;
     }
-    if (this.k8sclusterForm.value.region_name === '' && this.k8sclusterForm.value.resource_group === '' && this.k8sclusterForm.value.description === '') {
-      delete payload.region_name;
-      delete payload.resource_group;
-      delete payload.description;
+    if (this.k8sclusterForm.value.public_subnet.length <= 0) {
+      delete this.k8sclusterForm.value.public_subnet;
     }
-    this.restService.postResource(apiURLHeader, payload).subscribe((result: {}) => {
+    if (this.vimType !== 'aws') {
+      this.payload = {
+        name: this.k8sclusterForm.value.name,
+        vim_account: this.k8sclusterForm.value.vim_account,
+        location: this.k8sclusterForm.value.location,
+        region_name: this.k8sclusterForm.value.region_name,
+        resource_group: this.k8sclusterForm.value.resource_group,
+        k8s_version: this.k8sclusterForm.value.k8s_version,
+        node_size: this.k8sclusterForm.value.node_size,
+        node_count: Number(this.k8sclusterForm.value.node_count),
+        description: this.k8sclusterForm.value.description,
+        bootstrap: Boolean(this.k8sclusterForm.value.bootstrap)
+      };
+      if (this.k8sclusterForm.value.region_name === '') {
+        delete this.payload.region_name;
+      }
+      if (this.k8sclusterForm.value.resource_group === '') {
+        delete this.payload.resource_group;
+      }
+      if (this.k8sclusterForm.value.description === '') {
+        delete this.payload.description;
+      }
+    } else {
+      this.payload = Object.keys(formData).reduce((acc, key) => {
+        // eslint-disable-next-line security/detect-object-injection
+        if (formData[key] !== null && formData[key] !== undefined && formData[key] !== '') {
+          // eslint-disable-next-line security/detect-object-injection
+          acc[key] = formData[key];
+        }
+        return acc;
+      }, {});
+    }
+    this.restService.postResource(apiURLHeader, this.payload).subscribe((result: {}) => {
       this.activeModal.close(modalData);
       this.isLoadingResults = false;
       this.notifierService.notify('success', this.k8sclusterForm.value.name +
@@ -475,8 +582,7 @@
     });
   }
 
-
-  /** Update cluster @public */
+  /** Edit cluster @public */
   public editCluster(): void {
     this.submitted = true;
     this.sharedService.cleanForm(this.k8sclusterForm);