---
# System prepended metadata

title: OSSM 2.0 Internal svc test

---

# OSSM 2.0 Internal svc test

## Env
* OSSM 2.0
* crc 4.10

## Install bookinfo app into bookinfo ns

```
oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.1/samples/bookinfo/platform/kube/bookinfo.yaml

oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.1/samples/bookinfo/networking/bookinfo-gateway.yaml
oc apply -n bookinfo -f https://raw.githubusercontent.com/Maistra/istio/maistra-2.1/samples/bookinfo/networking/destination-rule-all.yaml
```

## Create a ubunto pod in bookinfo ns

```
cat << EOF | oc apply -f -
apiVersion: v1
kind: Pod
metadata:
  annotations:
    sidecar.istio.io/inject: "true"
  name: ubuntu
  labels:
    app: ubuntu
spec:
  containers:
  - image: ubuntu
    command:
      - "sleep"
      - "604800"
    imagePullPolicy: IfNotPresent
    name: ubuntu
  restartPolicy: Always
EOF
```

## Test

1. 用ubuntu Pod對svc/productpage curl測試
```
oc exec -it ubuntu bash

root@ubuntu:/# curl http://productpage:9080/hello
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

root@ubuntu:/# curl  http://productpage:9080/new
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>

```


2. 新增一組新的virtualService對internal svc生效
```
cat << EOF | oc apply -f -
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-service-a
  namespace: bookinfo
spec:
  hosts:
  - productpage.bookinfo.svc.cluster.local
  gateways:
  - mesh
  http:
  - match:
    - uri:
        prefix: "/hello"
    rewrite:
      uri: /productpage
    route:
    - destination:
        host: productpage
        port:
          number: 9080
  - match:
    - uri:
        prefix: "/new"
    rewrite:
      uri: /api/v1/products
    route:
    - destination:
        host: productpage
        port:
          number: 9080
EOF
```

3. 重新測試
```
oc exec -it ubuntu bash

root@ubuntu:/# curl -vv http://productpage:9080/hello
*   Trying 10.217.5.36:9080...
* Connected to productpage (10.217.5.36) port 9080 (#0)
> GET /hello HTTP/1.1
> Host: productpage:9080
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: text/html; charset=utf-8
< content-length: 4183
< server: envoy
< date: Thu, 20 Oct 2022 00:51:31 GMT
< x-envoy-upstream-service-time: 825
<
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Bookstore App</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
............
............
............
```
```
root@ubuntu:/# curl -vv http://productpage:9080/new
*   Trying 10.217.5.36:9080...
* Connected to productpage (10.217.5.36) port 9080 (#0)
> GET /new HTTP/1.1
> Host: productpage:9080
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-type: application/json
< content-length: 395
< server: envoy
< date: Thu, 20 Oct 2022 00:52:05 GMT
< x-envoy-upstream-service-time: 3
<
* Connection #0 to host productpage left intact
[{"id": 0, "title": "The Comedy of Errors", "descriptionHtml": "<a href=\"https://en.wikipedia.org/wiki/The_Comedy_of_Errors\">Wikipedia Summary</a>: The Comedy of Errors is one of <b>William Shakespeare's</b> early plays. It is his shortest and one of his most farcical comedies, with a major part of the humour coming from slapstick and mistaken identity, in addition to puns and word play."}]


```