-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override default pod spec with StrategicMergePatch #321
Conversation
d6dd1da
to
0308a51
Compare
2b45be0
to
b99f57f
Compare
576135e
to
4d59a3e
Compare
@@ -24,6 +24,7 @@ The TemplateParam struct is defined as: | |||
Options map[string]string | |||
Object map[string]interface{} | |||
Phases map[string]*Phase | |||
PodOverride map[string]interface{} |
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.
PodOverride map[string]interface{} | |
PodOverride strategicpatch.JSONMap |
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 thought that will confuse reader which format to use while passing the parameter from the Actionset. That's why I've kept it's type as map[string]interface{}
in functions page also
https://github.com/kanisterio/kanister/pull/321/files#diff-610c3344a79db2ab08c4ef6b15842adeR416
Let me know that you think
pkg/testing/e2e_test.go
Outdated
} | ||
sec, err = s.cli.CoreV1().Secrets(s.namespace).Create(sec) | ||
c.Assert(err, IsNil) | ||
p := &crv1alpha1.Profile{ |
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.
@PrasadG193 can we make use of func NewTestProfile(namespace string, secretName string)
from pkg/testutil/testutil.go here ?
// default pod specs | ||
PodOverride v1.PodSpec `json:"podOverride,omitempty"` | ||
PodOverride sp.JSONMap `json:"podOverride,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.
@PrasadG193 please add these file changes along with pkg/param/param.go
into a separate PR!
pkg/kube/pod.go
Outdated
@@ -133,3 +144,58 @@ func WaitForPodCompletion(ctx context.Context, cli kubernetes.Interface, namespa | |||
}) | |||
return errors.Wrap(err, "Pod did not transition into complete state") | |||
} | |||
|
|||
// PatchDefaultPodSpecs use Strategic Merge to patch default pod specs with the passed specs | |||
func PatchDefaultPodSpecs(defaultPodSpecs v1.PodSpec, override sp.JSONMap) (v1.PodSpec, 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.
(From meeting discussion) Lets avoid exporting func PatchDefaultPodSpecs
and CreateAndMergeJsonPatch
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.
We'll still need CreateAndMergeJsonPatch
I believe
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.
Yes, CreateAndMergeJsonPatch
is being used in function
package
pkg/function/copy_volume_data.go
Outdated
@@ -133,11 +136,24 @@ func (*copyVolumeDataFunc) Exec(ctx context.Context, tp param.TemplateParams, ar | |||
if err = OptArg(args, CopyVolumeDataEncryptionKeyArg, &encryptionKey, restic.GeneratePassword()); err != nil { | |||
return nil, err | |||
} | |||
if err = OptArg(args, CopyVolumeDataPodOverrideArg, &podOverride, tp.PodOverride); 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.
You might want to move this all into a helper function in the function pkg - possibly in args.go
. It'll simplify the repeated code in the functions.
e.g.
// GetPodSpecOverride
func GetPodSpecOverride(tp param.TemplateParams, args map[string]interface{}, argName string) (podOverride map[string]interface{}, err error)
} | ||
|
||
// CreatePod creates a pod with a single container based on the specified image | ||
func CreatePod(ctx context.Context, cli kubernetes.Interface, opts *PodOptions) (*v1.Pod, error) { | ||
volumeMounts, podVolumes := createVolumeSpecs(opts.Volumes) | ||
defaultSpecs := v1.PodSpec{ |
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.
Minor - just call this podSpecs
given that it is no longer "default" after line 66
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 - @SupriyaKasten - will let you approve
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
instead of map[string]interface{} Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
e1d7dac
to
665baf0
Compare
Signed-off-by: Prasad Ghangal <prasad.ghangal@gmail.com>
665baf0
to
2a741c4
Compare
🚀 |
Change Overview
Pull request type
Please check the type of change your PR introduces:
Issues
Test Plan