How to recover deleted or lost values.yaml files for an installed VKS package
search cancel

How to recover deleted or lost values.yaml files for an installed VKS package

book

Article ID: 427753

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service VMware Tanzu Kubernetes Grid Management

Issue/Introduction

The original configuration file (values.yaml) used to deploy a VKS Package (e.g., Prometheus, Grafana, Contour) has been deleted or lost from the jumpbox/administrator workstation. The administrator needs to retrieve the current active configuration to perform updates or modifications.

Environment

vSphere Kubernetes Service 
Tanzu Kubernetes Grid Management 

Cause

In vsphere kubernetes service guest cluster, when a package is installed via a PackageInstall (pkgi) resource, the configuration values are stored as a Kubernetes Secret. This KB provides the steps to reconstruct the values.yaml file from the cluster state.

Resolution

The following steps demonstrate how to recover the values.yaml for a Prometheus installation.

Note: These same steps apply to any Tanzu package (e.g., Grafana, Contour, Fluent Bit) by simply substituting the package name.

1. Locate the Configuration Secret

Every installed package (pkgi) references a secret that stores its configuration. To find the name of this secret, view the package details in YAML format:

# Replace 'prometheus' and the namespace with your specific package details
kubectl get pkgi -n vmware-system-tkg prometheus -o yaml

Search the output for the spec.values section. It will contain the secretRef name:

spec:
  packageRef:
    refName: prometheus.kubernetes.vmware.com
    versionSelection:
      constraints: 3.5.0+vmware.1-vks.2
  values:
  - secretRef:
      name: prometheus-vmware-system-tkg-values  <-- THIS IS YOUR TARGET SECRET

 

2. Extract and Decode the values.yaml

The configuration is stored as a Base64-encoded string within that secret. Use the following command to extract, decode, and save the content directly to a file:

# Replace the secret name with the one found in Step 1
kubectl get secret -n vmware-system-tkg prometheus-vmware-system-tkg-values -o jsonpath='{.data.values\.yaml}' | base64 -d > recovered-prometheus-values.yaml

 

3. Verify the Content

cat recovered-prometheus-values.yaml


You can now use this file to perform updates or modifications to your package via the Tanzu CLI.