Trouble with Virtual Service Deserialization


Hello, I’m trying to make a client to work with istio virtualservices

This is my object definition

// +genclient

// VirtualService is a Istio VirtualService resource
type VirtualService struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec MyVirtualService `json:"spec"`


// VirtualServiceList is a list of VirtualService resources
type VirtualServiceList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata"`

	Items []VirtualService `json:"items"`

type MyVirtualService istiov1alpha3.VirtualService

func (in *MyVirtualService) DeepCopyInto(out *MyVirtualService) {
	*out = *in

I use k8s code generation to create my client, my get method looks like this:

func (c *virtualServices) Get(name string, options v1.GetOptions) (result *v1alpha3.VirtualService, err error) {
result = &v1alpha3.VirtualService{}
err = c.client.Get().
VersionedParams(&options, schema.ParameterCodec).

It seems to work fine however some fields are always null. For example, route match header selectors and faults are always null. This is my return object for a virtualservice with a valid fault:

spec: hosts: - details http: - route: - destination: host: details subset: v1 weight: 63 - destination: host: details subset: v2 weight: 37 fault: delay: percent: 100 HttpDelayType: null

The HttpDelayType is null.

Am I doing something wrong or is this maybe just a version issue?
Does anyone have a go-client or way of working with the istio CRDs with go?




The problem is that istio uses JSON mapping for protobuf APIs (, which is distinct from k8s API machinery. In particular, the field tags are different, there is no strategic patch, and embedding into k8s envelope is tricky.

In istio code base, the process is two step: 1) retrieve opaque JSON spec from k8s API, 2) convert JSON to proto using jsonpb package.