Populate empty proxy-version annotation (#9382)

Addresses: #9311 

* Set injected `proxy-version` annotation to `values.LinkerdVersion` when image version is empty.
* Set `Proxy.Image.Version` consistently between CLI and Helm

Tested when installed via CLI:

```
$ k get po -o yaml -n emojivoto | grep proxy-version
      linkerd.io/proxy-version: dev-0911ad92-jchase
      linkerd.io/proxy-version: dev-0911ad92-jchase
      linkerd.io/proxy-version: dev-0911ad92-jchase
      linkerd.io/proxy-version: dev-0911ad92-jchase
```

Untested when installed via Helm.

Signed-off-by: Jeremy Chase <jeremy.chase@gmail.com>
Co-authored-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
This commit is contained in:
Jeremy Chase 2022-10-11 15:05:59 -04:00 committed by GitHub
parent 5cb6755ebe
commit 32b4ac4f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View File

@ -266,7 +266,6 @@ func NewValues() (*Values, error) {
return nil, err
}
v.Proxy.Image.Version = version.Version
v.DebugContainer.Image.Version = version.Version
v.CliVersion = k8s.CreatedByAnnotationValue()
v.ProfileValidator.TLS = &TLS{}

View File

@ -103,7 +103,7 @@ func TestNewValues(t *testing.T) {
EnableExternalProfiles: false,
Image: &Image{
Name: "cr.l5d.io/linkerd/proxy",
Version: "dev-undefined",
Version: "",
},
LogLevel: "warn,linkerd=info",
LogFormat: "plain",

View File

@ -795,7 +795,12 @@ func (conf *ResourceConfig) serviceAccountVolumeMount() *corev1.VolumeMount {
// annotations.
func (conf *ResourceConfig) injectObjectMeta(values *podPatch) {
values.Annotations[k8s.ProxyVersionAnnotation] = values.Proxy.Image.Version
// Default proxy version to linkerd version
if values.Proxy.Image.Version != "" {
values.Annotations[k8s.ProxyVersionAnnotation] = values.Proxy.Image.Version
} else {
values.Annotations[k8s.ProxyVersionAnnotation] = values.LinkerdVersion
}
// Add the cert bundle's checksum to the workload's annotations.
checksumBytes := sha256.Sum256([]byte(values.IdentityTrustAnchorsPEM))

View File

@ -625,7 +625,8 @@ func TestOverridesSecret(t *testing.T) {
}
knownKeys["proxy"] = tree.Tree{
"image": tree.Tree{
"name": reg + "/proxy",
"name": reg + "/proxy",
"version": TestHelper.GetVersion(),
},
}
knownKeys["proxyInit"].(tree.Tree)["image"] = tree.Tree{