Skip to content

Commit

Permalink
OSSM-8079 Automate Expose Grpc With Passthrough Gateway (#748)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctartici authored Oct 4, 2024
1 parent 2e12875 commit 95a114c
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 44 deletions.
4 changes: 4 additions & 0 deletions images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,7 @@ grpcurl:
z: quay.io/maistra/grpcurl:latest
arm64: quay.io/maistra/grpcurl:latest

grpc-echo:
x86: gcr.io/istio-testing/app:latest
arm64: gcr.io/istio-testing/app:latest

55 changes: 55 additions & 0 deletions pkg/tests/tasks/traffic/ingress/grpc_https_gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ var (
//go:embed yaml/grpc_https_gateway.yaml
grpcurlTLSGatewayHTTPS string

//go:embed yaml/grpc_passthrough_gateway.yaml
grpcurlPassthroughGatewayHTTPS string

//go:embed yaml/grpc_echo_server_tls.yaml
grpcEchoServerTlsTemplate string

//go:embed yaml/grpc_echo_server.yaml
grpcEchoServerTemplate string

Expand Down Expand Up @@ -86,3 +92,52 @@ func TestExposeGrpcWithHttpsGateway(t *testing.T) {

})
}

func TestExposeGrpcWitPassthroughGateway(t *testing.T) {
test.NewTest(t).Id("T45").Groups(test.Full, test.InterOp, test.ARM).Run(func(t test.TestHelper) {

t.Log("This test verifies secure grpc traffic with passthrough gateway configuration.")

if env.GetArch() == "z" || env.GetArch() == "p" {
t.Skip("gcr.io/istio-testing/app:latest image is not supported on IBM Z&P")
}

t.Cleanup(func() {
app.Uninstall(t, app.GrpCurl(ns.Default))
oc.DeleteNamespace(t, ns.EchoGrpc)
oc.RecreateNamespace(t, meshNamespace)
})

t.LogStep("Create echo-grpc project")
oc.CreateNamespace(t, ns.EchoGrpc)

t.LogStep("Deploy Control Plane")
ossm.DeployControlPlane(t)
smcpName := env.GetDefaultSMCPName()

t.LogStep("Apply SMCP with mTLS true")
oc.Patch(t,
meshNamespace, "smcp", smcpName, "merge",
`{"spec":{"security":{"dataPlane":{"mtls":true}}}}`,
)

t.LogStep("Update SMMR to include EchoGrpc Namespaces")
oc.ApplyString(t, meshNamespace, ossm.AppendDefaultSMMR(ns.EchoGrpc))
oc.WaitSMMRReady(t, meshNamespace)

t.LogStep("Create Echo Grpc Server")
oc.ApplyTemplate(t, ns.EchoGrpc, grpcEchoServerTlsTemplate, nil)

t.LogStep("Configure a TLS ingress gateway for a single host")
oc.ApplyString(t, ns.EchoGrpc, grpcurlPassthroughGatewayHTTPS)

t.LogStep("Install grpcurl image")
app.Install(t, app.GrpCurl(ns.Default))
retry.UntilSuccessWithOptions(t, retry.Options().MaxAttempts(20), func(t test.TestHelper) {
oc.LogsFromPods(t,
ns.Default,
"app=grpcurl",
assert.OutputContains("EchoTestService", "rpc command worked successfully", "rpc error"))
})
})
}
4 changes: 2 additions & 2 deletions pkg/tests/tasks/traffic/ingress/yaml/grpc_echo_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
image: gcr.io/istio-testing/app:latest
image: {{ image "grpc-echo" }}
imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
Expand Down Expand Up @@ -143,7 +143,7 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
image: gcr.io/istio-testing/app:latest
image: {{ image "grpc-echo" }}
imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
Expand Down
192 changes: 192 additions & 0 deletions pkg/tests/tasks/traffic/ingress/yaml/grpc_echo_server_tls.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: echo
name: echo
namespace: echo-grpc
spec:
selector:
app: echo
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 18080
- name: tls-grpc
protocol: TCP
port: 7070
targetPort: 17070
- name: tcp
port: 9090
targetPort: 19090
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo-v1
namespace: echo-grpc
spec:
replicas: 1
selector:
matchLabels:
app: echo
version: v1
template:
metadata:
annotations:
sidecar.istio.io/inject: "true"
labels:
app: echo
version: v1
spec:
containers:
- args:
- --metrics=15014
- --port
- "18080"
- --tcp
- "19090"
- --grpc
- "17070"
- '--tls'
- '17070'
- --grpc
- "17171"
- --port
- "3333"
- --port
- "8080"
- --version
- v1
- --crt=/cert.crt
- --key=/cert.key
env:
- name: INSTANCE_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
image: {{ image "grpc-echo" }}
imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: tcp-health-port
timeoutSeconds: 1
name: app
ports:
- containerPort: 17070
protocol: TCP
- containerPort: 17171
protocol: TCP
- containerPort: 8080
protocol: TCP
- containerPort: 3333
name: tcp-health-port
protocol: TCP
readinessProbe:
failureThreshold: 10
httpGet:
path: /
port: 8080
scheme: HTTP
initialDelaySeconds: 1
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 1
startupProbe:
failureThreshold: 10
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: tcp-health-port
timeoutSeconds: 1
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echo-v2
namespace: echo-grpc
spec:
replicas: 1
selector:
matchLabels:
app: echo
version: v2
template:
metadata:
annotations:
sidecar.istio.io/inject: "true"
labels:
app: echo
version: v2
spec:
containers:
- args:
- --metrics=15014
- --port
- "18080"
- --tcp
- "19090"
- --grpc
- "17070"
- '--tls'
- '17070'
- --grpc
- "17171"
- --port
- "3333"
- --port
- "8080"
- --version
- v2
- --crt=/cert.crt
- --key=/cert.key
env:
- name: INSTANCE_IP
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: status.podIP
image: {{ image "grpc-echo" }}
imagePullPolicy: Always
livenessProbe:
failureThreshold: 10
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: tcp-health-port
timeoutSeconds: 1
name: app
ports:
- containerPort: 17070
protocol: TCP
- containerPort: 17171
protocol: TCP
- containerPort: 8080
protocol: TCP
- containerPort: 3333
name: tcp-health-port
protocol: TCP
readinessProbe:
failureThreshold: 10
httpGet:
path: /
port: 8080
scheme: HTTP
initialDelaySeconds: 1
periodSeconds: 2
successThreshold: 1
timeoutSeconds: 1
startupProbe:
failureThreshold: 10
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: tcp-health-port
timeoutSeconds: 1
36 changes: 36 additions & 0 deletions pkg/tests/tasks/traffic/ingress/yaml/grpc_passthrough_gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: grpc-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 443
name: tls
protocol: TLS
tls:
mode: PASSTHROUGH
hosts:
- grpc.example.com
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: grpc
spec:
hosts:
- grpc.example.com
gateways:
- grpc-gateway
tls:
- match:
- port: 443
sniHosts:
- grpc.example.com
route:
- destination:
host: echo.echo-grpc.svc.cluster.local
port:
number: 7070
32 changes: 16 additions & 16 deletions sampleCerts/grpc.example.com/grpc.example.com.crt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDITCCAgmgAwIBAgIBADANBgkqhkiG9w0BAQsFADAtMRUwEwYDVQQKDAxleGFt
cGxlIEluYy4xFDASBgNVBAMMC2V4YW1wbGUuY29tMB4XDTI0MDkxMzA4MzUyM1oX
DTI1MDkxMzA4MzUyM1owNzEZMBcGA1UEAwwQZ3JwYy5leGFtcGxlLmNvbTEaMBgG
A1UECgwRZ3JwYyBvcmdhbml6YXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQDHBwwCOZP/tcEDlxfyBmnyhOoS+1VQH9C92cZnnLsmSH/p6FwX2VJT
jj274JXI0iu+tJ1zc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