Skip to content

Commit

Permalink
cilium-cli/sysdump: add tetragon helm information
Browse files Browse the repository at this point in the history
With this change `cilium sysdump` is going to create the following new files:
- `tetragon-helm-metadata-<ts>.yaml`
- `tetragon-helm-values-<ts>.yaml`

Signed-off-by: Filip Nikolic <[email protected]>
  • Loading branch information
f1ko authored and tklauser committed Jan 15, 2025
1 parent d036ef2 commit 8fa4cbe
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cilium-cli/sysdump/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const (
eniconfigsFileName = "aws-eniconfigs-<ts>.yaml"
ciliumHelmMetadataFileName = "cilium-helm-metadata-<ts>.yaml"
ciliumHelmValuesFileName = "cilium-helm-values-<ts>.yaml"
tetragonHelmMetadataFileName = "tetragon-helm-metadata-<ts>.yaml"
tetragonHelmValuesFileName = "tetragon-helm-values-<ts>.yaml"
gopsFileName = "gops-%s-%s-<ts>-%s.txt"
hubbleDaemonsetFileName = "hubble-daemonset-<ts>.yaml"
hubbleFlowsFileName = "hubble-flows-%s-<ts>.json"
Expand Down
53 changes: 48 additions & 5 deletions cilium-cli/sysdump/sysdump.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import (
)

const sysdumpLogFile = "cilium-sysdump.log"
const helmReleaseName = "cilium"
const ciliumHelmReleaseName = "cilium"
const tetragonHelmReleaseName = "tetragon"

// Options groups together the set of options required to collect a sysdump.
type Options struct {
Expand All @@ -57,6 +58,8 @@ type Options struct {
CiliumEnvoyLabelSelector string
// The release name of Cilium Helm chart.
CiliumHelmReleaseName string
// The release name of Tetragon Helm chart.
TetragonHelmReleaseName string
// The labels used to target Cilium Node Init daemon set. Usually, this label is same as CiliumNodeInitLabelSelector.
CiliumNodeInitDaemonSetSelector string
// The labels used to target Cilium Node Init pods.
Expand Down Expand Up @@ -225,12 +228,19 @@ func NewCollector(
}

if c.Options.CiliumHelmReleaseName == "" {
c.log("ℹ️ Using default Cilium Helm release name: %q", helmReleaseName)
c.Options.CiliumHelmReleaseName = helmReleaseName
c.log("ℹ️ Using default Cilium Helm release name: %q", ciliumHelmReleaseName)
c.Options.CiliumHelmReleaseName = ciliumHelmReleaseName
} else {
c.log("ℹ️ Cilium Helm release name: %q", c.Options.CiliumHelmReleaseName)
}

if c.Options.TetragonHelmReleaseName == "" {
c.log("ℹ️ Using default Tetragon Helm release name: %q", tetragonHelmReleaseName)
c.Options.TetragonHelmReleaseName = tetragonHelmReleaseName
} else {
c.log("ℹ️ Tetragon Helm release name: %q", c.Options.TetragonHelmReleaseName)
}

if c.Options.CiliumSPIRENamespace == "" {
if ns, err := detectCiliumSPIRENamespace(k); err != nil {
c.logDebug("Failed to detect Cilium SPIRE installation: %v", err)
Expand Down Expand Up @@ -1617,7 +1627,7 @@ func (c *Collector) Run() error {
helmTasks := []Task{
{
CreatesSubtasks: true,
Description: "Collecting Helm metadata from the release",
Description: "Collecting Helm metadata from the Cilium release",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.GetHelmMetadata(ctx, c.Options.CiliumHelmReleaseName, c.Options.CiliumNamespace)
Expand All @@ -1632,7 +1642,22 @@ func (c *Collector) Run() error {
},
{
CreatesSubtasks: true,
Description: "Collecting Helm values from the release",
Description: "Collecting Helm metadata from the Tetragon release",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.GetHelmMetadata(ctx, c.Options.TetragonHelmReleaseName, c.Options.TetragonNamespace)
if err != nil {
return fmt.Errorf("failed to get the helm metadata from the release: %w", err)
}
if err := c.WriteString(tetragonHelmMetadataFileName, v); err != nil {
return fmt.Errorf("failed to write the helm metadata to the file: %w", err)
}
return nil
},
},
{
CreatesSubtasks: true,
Description: "Collecting Helm values from the Cilium release",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.GetHelmValues(ctx, c.Options.CiliumHelmReleaseName, c.Options.CiliumNamespace)
Expand All @@ -1645,6 +1670,21 @@ func (c *Collector) Run() error {
return nil
},
},
{
CreatesSubtasks: true,
Description: "Collecting Helm values from the Tetragon release",
Quick: true,
Task: func(ctx context.Context) error {
v, err := c.Client.GetHelmValues(ctx, c.Options.TetragonHelmReleaseName, c.Options.TetragonNamespace)
if err != nil {
return fmt.Errorf("failed to get the helm values from the release: %w", err)
}
if err := c.WriteString(tetragonHelmValuesFileName, v); err != nil {
return fmt.Errorf("failed to write the helm values to the file: %w", err)
}
return nil
},
},
}

tasks = append(tasks, helmTasks...)
Expand Down Expand Up @@ -3163,6 +3203,9 @@ func InitSysdumpFlags(cmd *cobra.Command, options *Options, optionPrefix string,
cmd.Flags().StringVar(&options.CiliumHelmReleaseName,
optionPrefix+"cilium-helm-release-name", "",
"The Cilium Helm release name for which to get values. If not provided then the --helm-release-name global flag is used (if provided)")
cmd.Flags().StringVar(&options.TetragonHelmReleaseName,
optionPrefix+"tetragon-helm-release-name", "",
"The Tetragon Helm release name for which to get values.")
cmd.Flags().StringVar(&options.CiliumOperatorLabelSelector,
optionPrefix+"cilium-operator-label-selector", DefaultCiliumOperatorLabelSelector,
"The labels used to target Cilium operator pods")
Expand Down

0 comments on commit 8fa4cbe

Please sign in to comment.