From 3a283cdfc03c6e31e4b0b71ce90579da79eab0c1 Mon Sep 17 00:00:00 2001 From: Shizhao Liu <43278392+2ez4szliu@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:53:31 -0700 Subject: [PATCH] Allow user to generate support bundle in Airgap environment (#8683) Currently eks-anywhere cannot generate support bundle in Airgap environment because eks-a needs to read bundle manifest from remote URL. This PR fixed the issue by allowing user to specify path of local bundle manifest file so that eks-a does not need to read it from remote URL. Co-authored-by: Shizhao Liu --- cmd/eksctl-anywhere/cmd/supportbundle.go | 13 ++++++++++--- .../en/docs/clustermgmt/support/supportbundle.md | 3 +++ .../eksctl/anywhere_generate_support-bundle.md | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/eksctl-anywhere/cmd/supportbundle.go b/cmd/eksctl-anywhere/cmd/supportbundle.go index bf9c60a3f614..b8d6f49f197c 100644 --- a/cmd/eksctl-anywhere/cmd/supportbundle.go +++ b/cmd/eksctl-anywhere/cmd/supportbundle.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/cobra" + "github.com/aws/eks-anywhere/pkg/cluster" "github.com/aws/eks-anywhere/pkg/dependencies" "github.com/aws/eks-anywhere/pkg/diagnostics" "github.com/aws/eks-anywhere/pkg/kubeconfig" @@ -22,6 +23,7 @@ type createSupportBundleOptions struct { bundleConfig string hardwareFileName string tinkerbellBootstrapIP string + bundlesManifest string } var csbo = &createSupportBundleOptions{} @@ -36,7 +38,7 @@ var supportbundleCmd = &cobra.Command{ if err := csbo.validate(cmd.Context()); err != nil { return err } - if err := csbo.createBundle(cmd.Context(), csbo.since, csbo.sinceTime, csbo.bundleConfig); err != nil { + if err := csbo.createBundle(cmd.Context(), csbo.since, csbo.sinceTime, csbo.bundleConfig, csbo.bundlesManifest); err != nil { return fmt.Errorf("failed to create support bundle: %v", err) } return nil @@ -50,6 +52,7 @@ func init() { supportbundleCmd.Flags().StringVarP(&csbo.bundleConfig, "bundle-config", "", "", "Bundle Config file to use when generating support bundle") supportbundleCmd.Flags().StringVarP(&csbo.fileName, "filename", "f", "", "Filename that contains EKS-A cluster configuration") supportbundleCmd.Flags().StringVarP(&csbo.wConfig, "w-config", "w", "", "Kubeconfig file to use when creating support bundle for a workload cluster") + supportbundleCmd.Flags().StringVarP(&csbo.bundlesManifest, "bundles-manifest", "", "", "Bundles manifest to use when generating support bundle (required for generating support bundle in airgap environment)") err := supportbundleCmd.MarkFlagRequired("filename") if err != nil { log.Fatalf("Error marking flag as required: %v", err) @@ -70,8 +73,12 @@ func (csbo *createSupportBundleOptions) validate(ctx context.Context) error { return nil } -func (csbo *createSupportBundleOptions) createBundle(ctx context.Context, since, sinceTime, bundleConfig string) error { - clusterSpec, err := readAndValidateClusterSpec(csbo.fileName, version.Get()) +func (csbo *createSupportBundleOptions) createBundle(ctx context.Context, since, sinceTime, bundleConfig string, bundlesManifest string) error { + var opts []cluster.FileSpecBuilderOpt + if bundlesManifest != "" { + opts = append(opts, cluster.WithOverrideBundlesManifest(bundlesManifest)) + } + clusterSpec, err := readAndValidateClusterSpec(csbo.fileName, version.Get(), opts...) if err != nil { return fmt.Errorf("unable to get cluster config from file: %v", err) } diff --git a/docs/content/en/docs/clustermgmt/support/supportbundle.md b/docs/content/en/docs/clustermgmt/support/supportbundle.md index fc8c926a5ffe..9c432f2e83ca 100644 --- a/docs/content/en/docs/clustermgmt/support/supportbundle.md +++ b/docs/content/en/docs/clustermgmt/support/supportbundle.md @@ -39,6 +39,8 @@ If you provide a support bundle configuration file using the `--bundle-config` f for example one generated with `generate support-bundle-config`, `generate support-bundle` will use the provided configuration when collecting information from your cluster and analyzing the results. +If you want to generate support bundle in an airgapped environment, the `--bundles-manifest` flag must be set to the local path +of your eks-a bundles manifest yaml file. ``` Flags: --bundle-config string Bundle Config file to use when generating support bundle @@ -47,6 +49,7 @@ Flags: --since string Collect pod logs in the latest duration like 5s, 2m, or 3h. --since-time string Collect pod logs after a specific datetime(RFC3339) like 2021-06-28T15:04:05Z -w, --w-config string Kubeconfig file to use when creating support bundle for a workload cluster + --bundles-manifest Bundles manifest to use when generating support bundle (required for generating support bundle in airgap environment) ``` ### Collecting and analyzing a bundle diff --git a/docs/content/en/docs/reference/eksctl/anywhere_generate_support-bundle.md b/docs/content/en/docs/reference/eksctl/anywhere_generate_support-bundle.md index 114154bc55d9..636e3a652b15 100644 --- a/docs/content/en/docs/reference/eksctl/anywhere_generate_support-bundle.md +++ b/docs/content/en/docs/reference/eksctl/anywhere_generate_support-bundle.md @@ -24,6 +24,7 @@ anywhere generate support-bundle -f my-cluster.yaml [flags] --since string Collect pod logs in the latest duration like 5s, 2m, or 3h. --since-time string Collect pod logs after a specific datetime(RFC3339) like 2021-06-28T15:04:05Z -w, --w-config string Kubeconfig file to use when creating support bundle for a workload cluster + --bundles-manifest Bundles manifest to use when generating support bundle (required for generating support bundle in airgap environment) ``` ### Options inherited from parent commands