Skip to content

Commit

Permalink
Handle pushgateway image as any other image
Browse files Browse the repository at this point in the history
This PR has 3 fixes in it:
1. Allow overriding the image repo for pushgateway image
2. Include pushgateway image into airgap image list when `--all` is used
3. Handle pause image via config in airgap list, i.e. make it respect repo override too

Signed-off-by: Jussi Nummelin <[email protected]>
  • Loading branch information
jnummelin committed Feb 5, 2025
1 parent af1d97d commit ff3fadc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/airgap/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ import (
"runtime"

"github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
"github.com/k0sproject/k0s/pkg/constant"
)

// GetImageURIs returns all image tags
func GetImageURIs(spec *v1beta1.ClusterSpec, all bool) []string {
pauseImage := v1beta1.ImageSpec{
Image: constant.KubePauseContainerImage,
Version: constant.KubePauseContainerImageVersion,
}

imageURIs := []string{
spec.Images.Calico.CNI.URI(),
Expand All @@ -40,7 +35,15 @@ func GetImageURIs(spec *v1beta1.ClusterSpec, all bool) []string {
spec.Images.KubeRouter.CNI.URI(),
spec.Images.KubeRouter.CNIInstaller.URI(),
spec.Images.MetricsServer.URI(),
pauseImage.URI(),
spec.Images.Pause.URI(),
}

if all {
// Currently we can't determine if the user has enabled the PushGateway via
// config so include it only if all is requested
imageURIs = append(imageURIs,
spec.Images.PushGateway.URI(),
)
}

if spec.Network != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/k0s/v1beta1/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func (ci *ClusterImages) overrideImageRepositories() {
override(ci.KubeRouter.CNI)
override(ci.KubeRouter.CNIInstaller)
override(ci.Pause)
override(ci.PushGateway)
}

// CalicoImageSpec config group for calico related image settings
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/k0s/v1beta1/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func TestImagesRepoOverrideInConfiguration(t *testing.T) {
require.Equal(t, "my.repo/k0sproject/kube-router:"+constant.KubeRouterCNIImageVersion, testingConfig.Spec.Images.KubeRouter.CNI.URI())
require.Equal(t, "my.repo/k0sproject/cni-node:"+constant.KubeRouterCNIInstallerImageVersion, testingConfig.Spec.Images.KubeRouter.CNIInstaller.URI())
require.Equal(t, "my.repo/pause:"+constant.KubePauseContainerImageVersion, testingConfig.Spec.Images.Pause.URI())
require.Equal(t, "my.repo/k0sproject/pushgateway-ttl:"+constant.PushGatewayImageVersion, testingConfig.Spec.Images.PushGateway.URI())
})
t.Run("config_with_custom_images", func(t *testing.T) {
cfg := DefaultClusterConfig()
Expand Down

0 comments on commit ff3fadc

Please sign in to comment.