"struct has no xxxx field or method" failure reported when creating management cluster with Tanzu CLI
search cancel

"struct has no xxxx field or method" failure reported when creating management cluster with Tanzu CLI

book

Article ID: 314596

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid

Issue/Introduction

  • When creating management cluster with Tanzu CLI, it might fail in generating cluster configuration with error like "struct has no xxxx field or method". xxxx is the filed name in question. It's AWS_IDENTITY_REF_NAME in example below.

    $ tanzu management-cluster create --file mgmt-config.yaml -v 9
    compatibility file (/home/usera/.config/tanzu/tkg/compatibility/tkg-compatibility.yaml) already exists, skipping download
    BOM files inside /home/usera/.config/tanzu/tkg/bom already exists, skipping download
    CEIP Opt-in status: false
    
    Validating the pre-requisites...
    Identity Provider not configured. Some authentication features won't work.
    NODE_MACHINE_TYPE_1 not set, using the default NODE_MACHINE_TYPE instead
    NODE_MACHINE_TYPE_2 not set, using the default NODE_MACHINE_TYPE instead
    using AMI 'ami-000000' for tkr version: 'v1.21.2+vmware.1-tkg.1', aws-region 'us-east-1'
    
    Setting up management cluster...
    Validating configuration...
    Using infrastructure provider aws:v0.6.6
    Generating cluster configuration...
    Error: unable to set up management cluster: unable to build management cluster configuration: unable to get template:
    - struct has no .AWS_IDENTITY_REF_NAME field or method
    in <toplevel>
    overlay.yaml:49 | #@ if data.values.AWS_IDENTITY_REF_NAME != "":
    Usage:
    tanzu management-cluster create [flags]

Environment

VMware Tanzu Kubernetes Grid 1.x

Cause

  • Tanzu CLI will leverage ytt utility to generate cluster configuration based on the parameters in config yaml file specified in Tanzu CLI command line. If some parameters, which are referenced in overlay.yaml file used by ytt are missing in the input config yaml file, Tanzu CLI will fail with error like "struct has no xxxx field or method".
  • In the give example, parameter AWS_IDENTITY_REF_NAME is missing in the input config file mgmt-config.yaml.

Resolution

Add the missing parameters with default values if user doesn't wish to explicitly configure them. The default values can be found in ~/.config/tanzu/tkg/providers/config_default.yaml.