Skip to content

Commit

Permalink
Use upstream pause image (#912)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgalsaleh authored Aug 1, 2024
1 parent 52b8846 commit 88abc4a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
23 changes: 20 additions & 3 deletions cmd/buildtools/k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var k0sImageComponents = map[string]string{
"registry.k8s.io/metrics-server/metrics-server": "metrics-server",
"quay.io/k0sproject/kube-proxy": "kube-proxy",
"quay.io/k0sproject/envoy-distroless": "envoy-distroless",
"registry.k8s.io/pause": "pause",
}

var k0sComponents = map[string]addonComponent{
Expand Down Expand Up @@ -59,6 +60,9 @@ var k0sComponents = map[string]addonComponent{
return fmt.Sprintf("envoy-%d.%d", opts.upstreamVersion.Major(), opts.upstreamVersion.Minor())
},
},
"pause": {
useUpstreamImage: true,
},
}

var updateK0sImagesCommand = &cli.Command{
Expand Down Expand Up @@ -90,18 +94,31 @@ var updateK0sImagesCommand = &cli.Command{
upstreamVersion = strings.TrimPrefix(upstreamVersion, "v")
upstreamVersion = strings.Split(upstreamVersion, "-")[0]

image = RemoveTagFromImage(image)
imageNoTag := RemoveTagFromImage(image)

componentName, ok := k0sImageComponents[image]
componentName, ok := k0sImageComponents[imageNoTag]
if !ok {
return fmt.Errorf("no component found for image %s", image)
return fmt.Errorf("no component found for image %s", imageNoTag)
}

component, ok := k0sComponents[componentName]
if !ok {
return fmt.Errorf("no component found for component name %s", componentName)
}

if component.useUpstreamImage {
logrus.Infof("fetching digest for image %s", image)
sha, err := GetImageDigest(c.Context, image)
if err != nil {
return fmt.Errorf("failed to get image %s digest: %w", image, err)
}
logrus.Infof("image %s digest: %s", image, sha)
tag := TagFromImage(image)
image = RemoveTagFromImage(image)
newmeta.Images[FamiliarImageName(image)] = fmt.Sprintf("%s@%s", tag, sha)
continue
}

packageName, packageVersion, err := component.getPackageNameAndVersion(wolfiAPKIndex, upstreamVersion)
if err != nil {
return fmt.Errorf("failed to get package name and version for %s: %w", componentName, err)
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ func overrideK0sImages(cfg *k0sv1beta1.ClusterConfig) {
cfg.Spec.Images.KubeProxy.Image = helpers.AddonImageFromComponentName("kube-proxy")
cfg.Spec.Images.KubeProxy.Version = Metadata.Images["kube-proxy"]

cfg.Spec.Images.Pause.Image = fmt.Sprintf("proxy.replicated.com/anonymous/%s", cfg.Spec.Images.Pause.Image)
cfg.Spec.Images.Pause.Image = "proxy.replicated.com/anonymous/registry.k8s.io/pause"
cfg.Spec.Images.Pause.Version = Metadata.Images["registry.k8s.io/pause"]

// TODO (salah): remove the following and uncomment when upstream PR for digest support is released: https://github.com/k0sproject/k0s/pull/4792
if cfg.Spec.Network != nil &&
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/static/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ images:
envoy-distroless: 1.29.6-r0@sha256:70b84e4366a692ec5a5bd9751ce95e89a2182b2f83d207338b76c980ac92738e
kube-proxy: 1.29.5-r0@sha256:2eedefa76a33aa075e8b2260c26353060fa2a3fa74754bad6e0b9ebfe91b43f3
metrics-server: 0.6.4-r9@sha256:58516a4f46ba645f4e0f367af41df6506951c3cd7903efd5f4ae3e17fd753e4a
pause: 1.29.5-r0@sha256:7a91a872a0a72a6a5576489744958b670871ac6a58ef606d668ef193d96fbce3
registry.k8s.io/pause: 3.9@sha256:8d4106c88ec0bd28001e34c975d65175d994072d65341f62a8ab0754b0fafe10

0 comments on commit 88abc4a

Please sign in to comment.