-
Notifications
You must be signed in to change notification settings - Fork 44
Add ability to update the image and tag of knative serving images #20
Conversation
greghaynes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple nits but LGTM.
| UpdateConfigMap(u, data, log) | ||
| } | ||
| } | ||
| if u.GetKind() == "Deployment" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 60 should get moved in to this function block now since it is not purely about config overriding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's one challenge here, just consider the image url in deployment.
Actually, there is image url in configmap, event in args in pod definition.
Could we have a common solution to pick them up and do replacement, use regex or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm concerned with a common solution that supports replacing all possible values. I think if the configmap values need to be changed, they should use the config key that mutates configmaps.
The Image kind needs to be able to be updated though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to support Image
| } | ||
| } | ||
|
|
||
| // Set some data in a configmap, only overwriting common keys if they differ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment leftover from somewhere?
I'd also expect it to start with // UpdateImage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
b874955 to
ce4fe0f
Compare
jcrossley3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I think we only need to update the CRD file.
| registry := instance.Spec.Image.Image | ||
| tag := instance.Spec.Image.Tag | ||
| var deployment *appsv1.Deployment | ||
| if err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, deployment); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using scheme.Convert to do this in other places, but I'm not sure if either is preferred. It makes me think maybe the controller's scheme should be made available in this function though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| result = append(result, extension.Transformers...) | ||
| } | ||
| // Let any config in instance override everything else | ||
| return append(result, func(u *unstructured.Unstructured) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we start adding more conditions in here, it might make more sense to define mf.Transformer functions elsewhere in the file and reference them here, similar to the mf.Inject* functions above (though they wouldn't have to be closures). I'll let you decide whether we do that now or later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if manifestival could supply something like InjectImageURL, that's will be great.
| // +optional | ||
| Config map[string]map[string]string `json:"config,omitempty"` | ||
|
|
||
| Image Registry `json:"registry,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should include the proper updates to deploy/crds/serving_v1alpha1_knativeserving_crd.yaml with this PR. Either manually or via operator-sdk generate k8s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| unstructured.SetNestedField(cm.Object, v, "data", k) | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love the name "helpers.go" for this file (my fault), and you've added so many related functions that I might lean toward putting them in their own say, "images.go" file? Still in the common package, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
e7ed236 to
f4dba39
Compare
|
/test pull-knative-serving-operator-go-coverage |
eab4ac6 to
82d87a3
Compare
|
I have verified that this works with: apiVersion: serving.knative.dev/v1alpha1
kind: KnativeServing
metadata:
name: knative-serving
spec:
registry:
default-registry: "my-registry.io/my-build/knative/cmd"
default-tag: "v0.6.0"How do you feel about this CRD? Should it be: spec:
registry:
default:
registry: my-registry.io/my-build/knative/cmd
tag: v0.6.0It's a bit strange to have a |
| func updateDeployment(scheme *runtime.Scheme, instance *servingv1alpha1.KnativeServing, u *unstructured.Unstructured) error { | ||
|
|
||
| var deployment = &appsv1.Deployment{} | ||
| err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, deployment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this better than scheme.Convert(u, deployment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't get scheme.Convert(u, deployment) to work. I got error message TypeMeta not present in src which comes from https://github.com/kubernetes/apimachinery/blob/961b39a1baa06f6c52bdd048a809b9f5b47f1337/pkg/conversion/converter.go#L828. The issue I believe is TypeMeta
| metav1.TypeMeta `json:",inline"` |
I'll look more into the scheme tests and see if I can reproduce this issue: https://github.com/kubernetes/apimachinery/blob/961b39a1baa06f6c52bdd048a809b9f5b47f1337/pkg/runtime/scheme_test.go#L1
| type Registry struct { | ||
| DefaultRegistry string `json:"default-registry,omitempty"` | ||
| DefaultTag string `json:"default-tag,omitempty"` | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the "Default*" prefix meant to imply? Why not just Name and Tag as the only elements of the Registry struct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per comment #20 (comment), it demonstrates the that this is the default registry and tag to use. I am starting to prefer the nested default map.
Personally, I'd prefer not to see "registry" used in two places: how about just
What other services? Like activator or autoscaler? So something like this? spec:
registry:
default:
name: my-registry.io/my-build/knative/cmd
tag: v0.6.0
autoscaler:
name: my-other-registry.io/my-build/knative/cmd
tag: v0.6.1 |
|
Also, would we expect this to be affected as well?
|
| registry: "new-registry.io/test/path", | ||
| tag: "new-tag", | ||
| expected: "new-registry.io/test/path/queue:new-tag", | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another challenge just occurred to me: RHT currently renames its images with a knative-serving- prefix, so queue becomes knative-serving-queue. Hence, our image name will be quay.io/openshift-knative/knative-serving-queue:v0.6.0. Will the current logic stick a / in there? If so, can we just expect the separator to be in the name, e.g quay.io/openshift-knative/knative-serving- and new-registry.io/test/path/?
|
Per comment #20 (comment), @greghaynes suggested an option that supports both a default and an individual override: #1 (comment). Your suggestion is the correct assumption. I should probably the ability to override the default per service in this PR, so I don't need to circle back again. |
|
Per comment #20 (comment), that's a good question. I don't think so, but it would be surprising. Is it unreasonable for the user to make the CR: spec:
config:
deployment: my-registry.io/my-build/knative/cmd/queue:v0.6.0
registry:
default:
name: my-registry.io/my-build/knative/cmd
tag: v0.6.0What's unfortunate is the user will always need to do this, which is pretty non-obvious. @greghaynes @jcrossley3 what do you think? |
66c69d1 to
3963496
Compare
jcrossley3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor nits, so...
/lgtm
| type Registry struct { | ||
| // The default image reference template to use for all knative images. | ||
| // It takes the form of example-registry.io/custom/path/${NAME}:custom-tag | ||
| // ${NAME} will be replaced by the deployment name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deployment name? Container? Image? Basename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| // +optional | ||
| Config map[string]map[string]string `json:"config,omitempty"` | ||
|
|
||
| // A means to override the corresponding deployment images in the upstream deployments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/deployment //
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| func updateCachingImage(scheme *runtime.Scheme, instance *servingv1alpha1.KnativeServing, u *unstructured.Unstructured) error { | ||
| var image = &caching.Image{} | ||
| err := runtime.DefaultUnstructuredConverter.FromUnstructured(u.Object, image) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into why scheme.Convert doesn't work after this is merged.
…the Deployment Containers Adds knative.dev/caching dependency
|
The following is the coverage report on pkg/.
|
|
@trshafer: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
/lgtm |
evankanderson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/hold cancel
Fixes #1.