func (c *client) Update(r *Resource, opts ...UpdateOption) error {
	options := UpdateOptions{
		Namespace: c.opts.Namespace,
	}
	for _, o := range opts {
		o(&options)
	}
	req := api.NewRequest(c.opts).
		Patch().
		SetHeader("Content-Type", "application/strategic-merge-patch+json").
		Resource(r.Kind).
		Name(r.Name).
		Namespace(options.Namespace)
	switch r.Kind {
	case "service":
		req.Body(r.Value.(*Service))
	case "deployment":
		req.Body(r.Value.(*Deployment))
	case "pod":
		req.Body(r.Value.(*Pod))
	case "networkpolicy", "networkpolicies":
		req.Body(r.Value.(*NetworkPolicy))
	case "resourcequota":
		req.Body(r.Value.(*ResourceQuota))
	default:
		return errors.New("unsupported resource")
	}
	return req.Do().Error()
}
Update updates API object
package client
import (
	"bytes"
	"crypto/tls"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"os"
	"path"
	"regexp"
	"strconv"
	"strings"
	"github.com/micro/micro/v3/service/logger"
	"github.com/micro/micro/v3/service/runtime"
	"github.com/micro/micro/v3/service/runtime/kubernetes/api"
)
var (
	serviceAccountPath = "/var/run/secrets/kubernetes.io/serviceaccount"
	ErrReadNamespace = errors.New("Could not read namespace from service account secret")
	DefaultImage = "micro/cells:v3"
	DefaultNamespace = "default"
	DefaultPort = 8080
)
type client struct {
	opts *api.Options
}
type Client interface {
	Create(*Resource, ...CreateOption) error
	Get(*Resource, ...GetOption) error
	Update(*Resource, ...UpdateOption) error
	Delete(*Resource, ...DeleteOption) error
	List(*Resource, ...ListOption) error
	Log(*Resource, ...LogOption) (io.ReadCloser, error)
	Watch(*Resource, ...WatchOption) (Watcher, error)
}
func (c *client) Create(r *Resource, opts ...CreateOption) error {
	options := CreateOptions{
		Namespace: c.opts.Namespace,
	}
	for _, o := range opts {
		o(&options)
	}
	b := new(bytes.Buffer)
	if err := renderTemplate(r.Kind, b, r.Value); err != nil {
		return err
	}
	return api.NewRequest(c.opts).
		Post().
		SetHeader("Content-Type", "application/yaml").
		Namespace(options.Namespace).
		Resource(r.Kind).
		Body(b).
		Do().
		Error()
}
var (
	nameRegex = regexp.MustCompile("[^a-zA-Z0-9]+")
)
func (c *client) Get(r *Resource, opts ...GetOption) error {
	options := GetOptions{
		Namespace: c.opts.Namespace,
	}
	for _, o := range opts {
		o(&options)
	}
	return api.NewRequest(c.opts).
		Get().
		Resource(r.Kind).
		Namespace(options.Namespace).
		Params(&api.Params{LabelSelector: options.Labels}).
		Do().
		Into(r.Value)
}
func (c *client) Log(r *Resource, opts ...LogOption) (io.ReadCloser, error) {
	options := LogOptions{
		Namespace: c.opts.Namespace,
	}
	for _, o := range opts {
		o(&options)
	}
	req := api.NewRequest(c.opts).
		Get().
		Resource(r.Kind).
		SubResource("log").
		Name(r.Name).
		Namespace(options.Namespace)
	if options.Params != nil {
		req.Params(&api.Params{Additional: options.Params})
	}
	resp, err := req.Raw()
	if err != nil {
		return nil, err
	}
	if resp.StatusCode < 200 || resp.StatusCode >= 300 {
		resp.Body.Close()
		return nil, errors.New(resp.Request.URL.String() + ": " + resp.Status)
	}
	return resp.Body, nil
}