Skip to content

Commit

Permalink
Allow goldpinger / goldpinger util images to be set in collector spec (
Browse files Browse the repository at this point in the history
…#1635)

* Add image parameter to the goldpinger collector

* Pass image directly as a function arg

Also allow util image to be set in spec

* Remove pointless util image override

* Update pkg/collect/goldpinger.go

Co-authored-by: Evans Mungai <evans@replicated.com>

* Simplify image override

---------

Co-authored-by: Evans Mungai <evans@replicated.com>
  • Loading branch information
hedge-sparrow and banjoh authored Oct 3, 2024
1 parent 2efbc20 commit f58f025
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/crds/troubleshoot.sh_collectors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ spec:
type: string
exclude:
type: BoolString
image:
type: string
namespace:
type: string
podLaunchOptions:
Expand Down
2 changes: 2 additions & 0 deletions config/crds/troubleshoot.sh_preflights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,8 @@ spec:
type: string
exclude:
type: BoolString
image:
type: string
namespace:
type: string
podLaunchOptions:
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/troubleshoot/v1beta2/collector_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ type Helm struct {
type Goldpinger struct {
CollectorMeta `json:",inline" yaml:",inline"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
Image string `json:"image,omitempty" yaml:"image,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty" yaml:"serviceAccountName,omitempty"`
CollectDelay string `json:"collectDelay,omitempty" yaml:"collectDelay,omitempty"`
PodLaunchOptions *PodLaunchOptions `json:"podLaunchOptions,omitempty" yaml:"podLaunchOptions,omitempty"`
Expand Down
9 changes: 8 additions & 1 deletion pkg/collect/goldpinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"k8s.io/utils/ptr"
)

var goldpingerImage = "bloomberg/goldpinger:3.10.1"

// Collect goldpinger results from goldpinger service running in a cluster
// The results are stored in goldpinger/check_all.json since we use
// the /check_all endpoint
Expand Down Expand Up @@ -299,6 +301,10 @@ func (c *CollectGoldpinger) createGoldpingerRoleBinding(ns string) (*rbacv1.Role
func (c *CollectGoldpinger) createGoldpingerDaemonSet(ns, svcAccName string) (*appsv1.DaemonSet, error) {
ds := &appsv1.DaemonSet{}

if c.Collector.Image != "" {
goldpingerImage = c.Collector.Image
}

ds.ObjectMeta = metav1.ObjectMeta{
Name: "ts-goldpinger",
Namespace: ns,
Expand All @@ -320,7 +326,7 @@ func (c *CollectGoldpinger) createGoldpingerDaemonSet(ns, svcAccName string) (*a
Containers: []corev1.Container{
{
Name: "goldpinger-daemon",
Image: "bloomberg/goldpinger:3.10.1",
Image: goldpingerImage,
ImagePullPolicy: corev1.PullIfNotPresent,
Env: []corev1.EnvVar{
{
Expand Down Expand Up @@ -479,6 +485,7 @@ func (c *CollectGoldpinger) runPodAndCollectGPResults(url string, progressChan c
namespace := "default"
serviceAccountName := ""
image := constants.GP_DEFAULT_IMAGE

var imagePullSecret *troubleshootv1beta2.ImagePullSecrets

if c.Collector.PodLaunchOptions != nil {
Expand Down
3 changes: 3 additions & 0 deletions schemas/collector-troubleshoot-v1beta2.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@
"exclude": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"image": {
"type": "string"
},
"namespace": {
"type": "string"
},
Expand Down
3 changes: 3 additions & 0 deletions schemas/preflight-troubleshoot-v1beta2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3148,6 +3148,9 @@
"exclude": {
"oneOf": [{"type": "string"},{"type": "boolean"}]
},
"image": {
"type": "string"
},
"namespace": {
"type": "string"
},
Expand Down

0 comments on commit f58f025

Please sign in to comment.