Skip to content

Commit

Permalink
Allow user to generate support bundle in Airgap environment (#8683)
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 <lshizhao@amazon.com>
  • Loading branch information
2ez4szliu and Shizhao Liu committed Sep 17, 2024
1 parent 00c891c commit 3a283cd
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 3a283cd

Please sign in to comment.