add a migration mutation webhook to the virt-api
@@ -85,6 +85,7 @@ const (
migrationUpdateValidatePath = "/migration-validate-update"
vmiMutatePath = "/virtualmachineinstances-mutate"
+ migrationMutatePath = "/migration-mutate-create"
certBytesValue = "cert-bytes"
keyBytesValue = "key-bytes"
@@ -755,6 +756,7 @@ func (app *virtAPIApp) createValidatingWebhook() error {
func (app *virtAPIApp) mutatingWebhooks() []admissionregistrationv1beta1.Webhook {
vmiPath := vmiMutatePath
+ migrationPath := migrationMutatePath
webHooks := []admissionregistrationv1beta1.Webhook{
{
Name: "virtualmachineinstances-mutator.kubevirt.io",
@@ -777,6 +779,27 @@ func (app *virtAPIApp) mutatingWebhooks() []admissionregistrationv1beta1.Webhook
CABundle: app.signingCertBytes,
},
},
+ {
+ Name: "migrations-mutator.kubevirt.io",
+ Rules: []admissionregistrationv1beta1.RuleWithOperations{{
+ Operations: []admissionregistrationv1beta1.OperationType{
+ admissionregistrationv1beta1.Create,
+ },
+ Rule: admissionregistrationv1beta1.Rule{
+ APIGroups: []string{v1.GroupName},
+ APIVersions: []string{v1.VirtualMachineInstanceMigrationGroupVersionKind.Version},
+ Resources: []string{"virtualmachineinstancemigrations"},
+ },
+ }},
+ ClientConfig: admissionregistrationv1beta1.WebhookClientConfig{
+ Service: &admissionregistrationv1beta1.ServiceReference{
+ Namespace: app.namespace,
+ Name: virtApiServiceName,
+ Path: &migrationPath,
+ },
+ CABundle: app.signingCertBytes,
+ },
+ },
}
return webHooks
}
@@ -827,7 +850,7 @@ func (app *virtAPIApp) createMutatingWebhook() error {
http.HandleFunc(vmiMutatePath, func(w http.ResponseWriter, r *http.Request) {
mutating_webhook.ServeVMIs(w, r)
})
- http.HandleFunc(vmiMutatePath, func(w http.ResponseWriter, r *http.Request) {
+ http.HandleFunc(migrationMutatePath, func(w http.ResponseWriter, r *http.Request) {
mutating_webhook.ServeMigrationCreate(w, r)
})
return nil
