Skip to content

Commit

Permalink
Use istio api and client version v1beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
ReToCode committed Apr 18, 2023
1 parent 8f1b6c8 commit 35ebcb8
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 42 deletions.
24 changes: 12 additions & 12 deletions pkg/reconciler/ingress/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,13 @@ func TestReconcile_EnableInternalEncryption(t *testing.T) {
Objects: []runtime.Object{
ing("reconcile-virtualservice"),
ingressServiceHTTP1,
gateway("knative-ingress-gateway", system.Namespace(), []*istiov1alpha3.Server{irrelevantServer1}),
gateway("knative-test-gateway", system.Namespace(), []*istiov1alpha3.Server{irrelevantServer1}),
gateway("knative-ingress-gateway", system.Namespace(), []*istiov1beta1.Server{irrelevantServer1}),
gateway("knative-test-gateway", system.Namespace(), []*istiov1beta1.Server{irrelevantServer1}),
},
WantCreates: []runtime.Object{
resources.MakeInternalEncryptionDestinationRule("test-service.test-ns.svc.cluster.local", ing("reconcile-virtualservice"), false),
resources.MakeMeshVirtualService(context.Background(), insertProbe(ing("reconcile-virtualservice")), gateways),
resources.MakeIngressVirtualService(context.Background(), insertProbe(ing("reconcile-virtualservice")),
resources.MakeMeshVirtualService(insertProbe(ing("reconcile-virtualservice")), gateways),
resources.MakeIngressVirtualService(insertProbe(ing("reconcile-virtualservice")),
makeGatewayMap([]string{"knative-testing/knative-test-gateway", "knative-testing/" + config.KnativeIngressGateway}, nil)),
},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Expand Down Expand Up @@ -781,13 +781,13 @@ func TestReconcile_EnableInternalEncryption(t *testing.T) {
Objects: []runtime.Object{
ing("reconcile-virtualservice"),
ingressServiceHTTP2,
gateway("knative-ingress-gateway", system.Namespace(), []*istiov1alpha3.Server{irrelevantServer1}),
gateway("knative-test-gateway", system.Namespace(), []*istiov1alpha3.Server{irrelevantServer1}),
gateway("knative-ingress-gateway", system.Namespace(), []*istiov1beta1.Server{irrelevantServer1}),
gateway("knative-test-gateway", system.Namespace(), []*istiov1beta1.Server{irrelevantServer1}),
},
WantCreates: []runtime.Object{
resources.MakeInternalEncryptionDestinationRule("test-service.test-ns.svc.cluster.local", ing("reconcile-virtualservice"), true),
resources.MakeMeshVirtualService(context.Background(), insertProbe(ing("reconcile-virtualservice")), gateways),
resources.MakeIngressVirtualService(context.Background(), insertProbe(ing("reconcile-virtualservice")),
resources.MakeMeshVirtualService(insertProbe(ing("reconcile-virtualservice")), gateways),
resources.MakeIngressVirtualService(insertProbe(ing("reconcile-virtualservice")),
makeGatewayMap([]string{"knative-testing/knative-test-gateway", "knative-testing/" + config.KnativeIngressGateway}, nil)),
},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Expand Down Expand Up @@ -840,14 +840,14 @@ func TestReconcile_EnableInternalEncryption(t *testing.T) {
ingWithMultipleSplitsWithStatus("reconcile-virtualservice", v1alpha1.IngressStatus{}),
ingressServiceHTTP1,
ingressService2HTTP1,
gateway("knative-ingress-gateway", system.Namespace(), []*istiov1alpha3.Server{irrelevantServer1}),
gateway("knative-test-gateway", system.Namespace(), []*istiov1alpha3.Server{irrelevantServer1}),
gateway("knative-ingress-gateway", system.Namespace(), []*istiov1beta1.Server{irrelevantServer1}),
gateway("knative-test-gateway", system.Namespace(), []*istiov1beta1.Server{irrelevantServer1}),
},
WantCreates: []runtime.Object{
resources.MakeInternalEncryptionDestinationRule("test-service.test-ns.svc.cluster.local", ing("reconcile-virtualservice"), false),
resources.MakeInternalEncryptionDestinationRule("test-service-2.test-ns.svc.cluster.local", ing("reconcile-virtualservice"), false),
resources.MakeMeshVirtualService(context.Background(), insertProbe(ingWithMultipleSplitsWithStatus("reconcile-virtualservice", v1alpha1.IngressStatus{})), gateways),
resources.MakeIngressVirtualService(context.Background(), insertProbe(ingWithMultipleSplitsWithStatus("reconcile-virtualservice", v1alpha1.IngressStatus{})),
resources.MakeMeshVirtualService(insertProbe(ingWithMultipleSplitsWithStatus("reconcile-virtualservice", v1alpha1.IngressStatus{})), gateways),
resources.MakeIngressVirtualService(insertProbe(ingWithMultipleSplitsWithStatus("reconcile-virtualservice", v1alpha1.IngressStatus{})),
makeGatewayMap([]string{"knative-testing/knative-test-gateway", "knative-testing/" + config.KnativeIngressGateway}, nil)),
},
WantStatusUpdates: []clientgotesting.UpdateActionImpl{{
Expand Down
26 changes: 13 additions & 13 deletions pkg/reconciler/ingress/resources/destinationrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ limitations under the License.
package resources

import (
istiov1alpha3 "istio.io/api/networking/v1alpha3"
"istio.io/client-go/pkg/apis/networking/v1alpha3"
istiov1beta1 "istio.io/api/networking/v1beta1"
"istio.io/client-go/pkg/apis/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/networking/pkg/apis/networking"
"knative.dev/networking/pkg/apis/networking/v1alpha1"
Expand All @@ -31,26 +31,26 @@ const (
knativeServingCertsSecret = "knative-serving-certs"

// has to match https://github.com/knative-sandbox/control-protocol/blob/main/pkg/certificates/constants.go#L21
knativeFakeDnsName = "data-plane.knative.dev"
knativeFakeDNSName = "data-plane.knative.dev"
)

// MakeInternalEncryptionDestinationRule creates a DestinationRule that enables upstream TLS
// on for the specified host
func MakeInternalEncryptionDestinationRule(host string, ing *v1alpha1.Ingress, http2 bool) *v1alpha3.DestinationRule {
dr := &v1alpha3.DestinationRule{
func MakeInternalEncryptionDestinationRule(host string, ing *v1alpha1.Ingress, http2 bool) *v1beta1.DestinationRule {
dr := &v1beta1.DestinationRule{
ObjectMeta: metav1.ObjectMeta{
Name: host,
Namespace: ing.Namespace,
OwnerReferences: []metav1.OwnerReference{*kmeta.NewControllerRef(ing)},
Annotations: ing.GetAnnotations(),
},
Spec: istiov1alpha3.DestinationRule{
Spec: istiov1beta1.DestinationRule{
Host: host,
TrafficPolicy: &istiov1alpha3.TrafficPolicy{
Tls: &istiov1alpha3.ClientTLSSettings{
Mode: istiov1alpha3.ClientTLSSettings_SIMPLE,
TrafficPolicy: &istiov1beta1.TrafficPolicy{
Tls: &istiov1beta1.ClientTLSSettings{
Mode: istiov1beta1.ClientTLSSettings_SIMPLE,
CredentialName: knativeServingCertsSecret,
SubjectAltNames: []string{knativeFakeDnsName},
SubjectAltNames: []string{knativeFakeDNSName},
},
},
},
Expand All @@ -63,9 +63,9 @@ func MakeInternalEncryptionDestinationRule(host string, ing *v1alpha1.Ingress, h
dr.Labels[networking.IngressLabelKey] = ing.Name

if http2 {
dr.Spec.TrafficPolicy.ConnectionPool = &istiov1alpha3.ConnectionPoolSettings{
Http: &istiov1alpha3.ConnectionPoolSettings_HTTPSettings{
H2UpgradePolicy: istiov1alpha3.ConnectionPoolSettings_HTTPSettings_UPGRADE},
dr.Spec.TrafficPolicy.ConnectionPool = &istiov1beta1.ConnectionPoolSettings{
Http: &istiov1beta1.ConnectionPoolSettings_HTTPSettings{
H2UpgradePolicy: istiov1beta1.ConnectionPoolSettings_HTTPSettings_UPGRADE},
}
}

Expand Down
34 changes: 17 additions & 17 deletions pkg/reconciler/ingress/resources/destinationrule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (

"github.com/google/go-cmp/cmp"
"google.golang.org/protobuf/testing/protocmp"
istiov1alpha3 "istio.io/api/networking/v1alpha3"
"istio.io/client-go/pkg/apis/networking/v1alpha3"
istiov1beta1 "istio.io/api/networking/v1beta1"
"istio.io/client-go/pkg/apis/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/networking/pkg/apis/networking"
"knative.dev/networking/pkg/apis/networking/v1alpha1"
Expand All @@ -49,7 +49,7 @@ var (

func TestMakeInternalEncryptionDestinationRuleHttp1(t *testing.T) {
dr := MakeInternalEncryptionDestinationRule(host, ing, false)
expected := &v1alpha3.DestinationRule{
expected := &v1beta1.DestinationRule{
ObjectMeta: metav1.ObjectMeta{
Name: host,
Namespace: ing.Namespace,
Expand All @@ -63,13 +63,13 @@ func TestMakeInternalEncryptionDestinationRuleHttp1(t *testing.T) {
RouteNamespaceLabelKey: "my-route-namespace",
},
},
Spec: istiov1alpha3.DestinationRule{
Spec: istiov1beta1.DestinationRule{
Host: host,
TrafficPolicy: &istiov1alpha3.TrafficPolicy{
Tls: &istiov1alpha3.ClientTLSSettings{
Mode: istiov1alpha3.ClientTLSSettings_SIMPLE,
TrafficPolicy: &istiov1beta1.TrafficPolicy{
Tls: &istiov1beta1.ClientTLSSettings{
Mode: istiov1beta1.ClientTLSSettings_SIMPLE,
CredentialName: knativeServingCertsSecret,
SubjectAltNames: []string{knativeFakeDnsName},
SubjectAltNames: []string{knativeFakeDNSName},
},
},
},
Expand All @@ -82,7 +82,7 @@ func TestMakeInternalEncryptionDestinationRuleHttp1(t *testing.T) {

func TestMakeInternalEncryptionDestinationRuleHttp2(t *testing.T) {
dr := MakeInternalEncryptionDestinationRule(host, ing, true)
expected := &v1alpha3.DestinationRule{
expected := &v1beta1.DestinationRule{
ObjectMeta: metav1.ObjectMeta{
Name: host,
Namespace: ing.Namespace,
Expand All @@ -96,17 +96,17 @@ func TestMakeInternalEncryptionDestinationRuleHttp2(t *testing.T) {
RouteNamespaceLabelKey: "my-route-namespace",
},
},
Spec: istiov1alpha3.DestinationRule{
Spec: istiov1beta1.DestinationRule{
Host: host,
TrafficPolicy: &istiov1alpha3.TrafficPolicy{
Tls: &istiov1alpha3.ClientTLSSettings{
Mode: istiov1alpha3.ClientTLSSettings_SIMPLE,
TrafficPolicy: &istiov1beta1.TrafficPolicy{
Tls: &istiov1beta1.ClientTLSSettings{
Mode: istiov1beta1.ClientTLSSettings_SIMPLE,
CredentialName: knativeServingCertsSecret,
SubjectAltNames: []string{knativeFakeDnsName},
SubjectAltNames: []string{knativeFakeDNSName},
},
ConnectionPool: &istiov1alpha3.ConnectionPoolSettings{
Http: &istiov1alpha3.ConnectionPoolSettings_HTTPSettings{
H2UpgradePolicy: istiov1alpha3.ConnectionPoolSettings_HTTPSettings_UPGRADE},
ConnectionPool: &istiov1beta1.ConnectionPoolSettings{
Http: &istiov1beta1.ConnectionPoolSettings_HTTPSettings{
H2UpgradePolicy: istiov1beta1.ConnectionPoolSettings_HTTPSettings_UPGRADE},
},
},
},
Expand Down

0 comments on commit 35ebcb8

Please sign in to comment.