Skip to content

Commit

Permalink
Allow user to generate support bundle in Airgap environment (#8786)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eks-distro-pr-bot and 2ez4szliu authored Sep 17, 2024
1 parent 49f3c2c commit 2509b36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cmd/eksctl-anywhere/cmd/supportbundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -22,6 +23,7 @@ type createSupportBundleOptions struct {
bundleConfig string
hardwareFileName string
tinkerbellBootstrapIP string
bundlesManifest string
}

var csbo = &createSupportBundleOptions{}
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
}
Expand Down
3 changes: 3 additions & 0 deletions docs/content/en/docs/clustermgmt/support/supportbundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2509b36

Please sign in to comment.