查看 DestinationRules
package main
import (
"context"
"log"
"github.com/owenliang/k8s-client-go/common"
versionedclient "istio.io/client-go/pkg/clientset/versioned"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func main() {
namespace := "bookinfo"
restConfig, err := common.GetRestConf()
if err != nil {
return
}
istioClient, err := versionedclient.NewForConfig(restConfig)
if err != nil {
return
}
dr,err := istioClient.NetworkingV1alpha3().DestinationRules(namespace).List(context.TODO(),v1.ListOptions{
})
if err != nil {
return
}
for i := range dr.Items {
dr := dr.Items[i]
log.Printf("DestinationRule : %+v\n", dr.Spec)
}
}
新建 DestinationRules
package main
import (
"context"
"log"
"github.com/gogo/protobuf/types"
"github.com/owenliang/k8s-client-go/common"
networkingv1alpha3 "istio.io/api/networking/v1alpha3"
"istio.io/client-go/pkg/apis/networking/v1alpha3"
versionedclient "istio.io/client-go/pkg/clientset/versioned"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func main() {
namespace := "bookinfo"
restConfig