Code change:
t.Fatalf("Unexpected error validating the service %s %v", svc.Name, err) } } <ins> type serviceMergePatch struct { Spec specMergePatch `json:"spec,omitempty"` } type specMergePatch struct { Type         v1.ServiceType `json:"type,omitempty"` ExternalName string         `json:"externalName,omitempty"` } // tests success when converting ClusterIP:Headless service to ExternalName func Test_ServiceChangeTypeHeadlessToExternalNameWithPatch(t *testing.T) { controlPlaneConfig := framework.NewIntegrationTestControlPlaneConfig() _, server, closeFn := framework.RunAnAPIServer(controlPlaneConfig) defer closeFn() config := restclient.Config{Host: server.URL} client, err := clientset.NewForConfig(&config) if err != nil { t.Fatalf("Error creating clientset: %v", err) } ns := framework.CreateTestingNamespace("test-service-allocate-node-ports", server, t) defer framework.DeleteTestingNamespace(ns, server, t) service := &v1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: "test-123", }, Spec: v1.ServiceSpec{ Type:      v1.ServiceTypeClusterIP, ClusterIP: "None", Selector:  map[string]string{"foo": "bar"}, }, } service, err = client.CoreV1().Services(ns.Name).Create(context.TODO(), service, metav1.CreateOptions{}) if err != nil { t.Fatalf("Error creating test service: %v", err) } serviceMergePatch := serviceMergePatch{ Spec: specMergePatch{ Type:         v1.ServiceTypeExternalName, ExternalName: "foo.bar", }, } patchBytes, err := json.Marshal(&serviceMergePatch) if err != nil { t.Fatalf("failed to json.Marshal ports: %v", err) } _, err = client.CoreV1().Services(ns.Name).Patch(context.TODO(), service.Name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}) if err != nil { t.Fatalf("unexpected error patching service using strategic merge patch. %v", err) } } </ins>

Related discussion:
text: <!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! If the matter is security related, please disclose it privately via --Patching a Kubernetes service failed with I the following yaml documents Create an external name service Change to to an ClusterIP Service Try to change it back to an external name service Kubernetes version (use ):Cloud provider or hardware configuration:
/sig node /sig api-machinery
Unsure if Service is part of networking /sig networking
The label(s) cannot be applied, because the repository doesn't have them. <detailsIn response to : Unsure if Service is part of networking Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/sig network
/remove-sig node
/cc /triage accepted
It is part of networking :), actually this part of Services is being revisited these days /assign
ack.
/sig network
Please don't triage/accept issues unless you're SURE they are your sig's. This fell through cracks.
/assign
this does not repo on: Here is what i did: service (the same one above) the service and change to =OK the service and change to =OK I have also performed step 3 using and the result is also OK /triage needs-information
I was using client v1.21.0 - is it resolved in newer kubectl 1.21.x patches?
please do. And also please share the exact steps you used were you using kubectl edit? or replace? or patch?
It's in the description - kubectl apply
The label(s) cannot be applied, because the repository doesn't have them. <detailsIn response to : /triage accepted - working on a fix. Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details
/triage accepted working on a fix
to confirm does the merged PR allow you to now change the type from to ? Or does it still produce an error with the difference it is reported properly vs. INTERNAL_ERROR? If it's the former can we cherry pick this PR back to supported K8s versions?