kubernetes/kops · error

InstanceGroups::Patch not supported for server-side client

Error message

InstanceGroups::Patch not supported for server-side client

What it means

Patch is not implemented on the server-side instanceGroups wrapper in the kops-controller clientset. Despite the clientset's server-side-apply orientation, this resource's Patch method was not wired up, so it always returns this sentinel error with a nil result. No API request is issued.

Source

Thrown at cmd/kops-controller/pkg/controllerclientset/instancegroups.go:120

func (c *instanceGroups) Update(ctx context.Context, g *kopsapi.InstanceGroup, opts metav1.UpdateOptions) (*kopsapi.InstanceGroup, error) {
	return nil, fmt.Errorf("InstanceGroups::Update not supported for server-side client")
}

func (c *instanceGroups) Delete(ctx context.Context, name string, options metav1.DeleteOptions) error {
	return fmt.Errorf("InstanceGroups::Delete not supported for server-side client")
}

func (r *instanceGroups) DeleteCollection(ctx context.Context, options metav1.DeleteOptions, listOptions metav1.ListOptions) error {
	return fmt.Errorf("InstanceGroups::DeleteCollection not supported for server-side client")
}

func (r *instanceGroups) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) {
	return nil, fmt.Errorf("InstanceGroups::Watch not supported for server-side client")
}

func (r *instanceGroups) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *kopsapi.InstanceGroup, err error) {
	return nil, fmt.Errorf("InstanceGroups::Patch not supported for server-side client")
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use server-side apply instead: build a full *kopsapi.InstanceGroup and call Apply(ctx, obj, metav1.ApplyOptions{FieldManager: "..."})
  2. Fetch with Get, mutate the object, and write with Update(ctx, obj, metav1.UpdateOptions{})
  3. Use a standard client-go typed clientset for the kops.k8s.io/v1alpha2 group when patch semantics are mandatory
  4. Implement Patch in cmd/kops-controller/pkg/controllerclientset/instancegroups.go if it is needed

Example fix

// before
patchBytes, _ := json.Marshal(map[string]interface{}{"spec": map[string]interface{}{"minSize": 3}})
_, err := client.InstanceGroups().Patch(ctx, "nodes", types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{})
// after
ig, err := client.InstanceGroups().Get(ctx, "nodes", metav1.GetOptions{})
if err != nil { return err }
ig.Spec.MinSize = ptr.To(int32(3))
_, err = client.InstanceGroups().Update(ctx, ig, metav1.UpdateOptions{})
Defensive patterns

Strategy: try-catch

Validate before calling

if _, ok := igClient.(interface {
	Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kopsapi.InstanceGroup, error)
}); !ok {
	useGetUpdateInstead = true
}

Type guard

func supportsPatch(v interface{}) bool {
	_, ok := v.(interface {
		Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (*kopsapi.InstanceGroup, error)
	})
	return ok
}

Try / catch

_, err := igClient.Patch(ctx, name, types.StrategicMergePatchType, data, metav1.PatchOptions{})
if err != nil && strings.Contains(err.Error(), "not supported for server-side client") {
	return getMutateAndUpdate(ctx, name) // Get + mutate + Update fallback
}

Prevention

When it happens

Trigger: Calling ctxClient.InstanceGroups().Patch(ctx, name, types.StrategicMergePatchType, data, metav1.PatchOptions{}, subresources...) — e.g. strategic-merge or JSON-patch updates to an InstanceGroup, including status subresource patches.

Common situations: Porting mutation logic that used the legacy kops clientset's Patch to the controller clientset; applying merge patches from a generic reconciler framework; JSON-patch based field updates in CI tooling built on this client.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/057a242ee815672f. Report an issue: GitHub.