Tips

Some tips and tricks that you might find handy

You have two containers in a pod

  1. oc get pods -o jsonpath="{.items[*].spec.containers[*].name}" -l app=customer -n tutorial
  2. or
  3. kubectl get pods -o jsonpath="{.items[*].spec.containers[*].name}" -l app=customer -n tutorial

From these images

  1. oc get pods -o jsonpath="{.items[*].spec.containers[*].image}" -l app=customer -n tutorial
  2. or
  3. kubectl get pods -o jsonpath="{.items[*].spec.containers[*].image}" -l app=customer -n tutorial

Get the pod ids

  1. CPOD=$(oc get pods -o jsonpath='{.items[*].metadata.name}' -l app=customer -n tutorial)
  2. PPOD=$(oc get pods -o jsonpath='{.items[*].metadata.name}' -l app=preference -n tutorial)
  3. RPOD1=$(oc get pods -o jsonpath='{.items[*].metadata.name}' -l app=recommendation,version=v1 -n tutorial)
  4. RPOD2=$(oc get pods -o jsonpath='{.items[*].metadata.name}' -l app=recommendation,version=v2 -n tutorial)
  5. or
  6. CPOD=$(kubectl get pods -o jsonpath='{.items[*].metadata.name}' -l app=customer -n tutorial)
  7. PPOD=$(kubectl get pods -o jsonpath='{.items[*].metadata.name}' -l app=preference -n tutorial)
  8. RPOD1=$(kubectl get pods -o jsonpath='{.items[*].metadata.name}' -l app=recommendation,version=v1 -n tutorial)
  9. RPOD2=$(kubectl get pods -o jsonpath='{.items[*].metadata.name}' -l app=recommendation,version=v2 -n tutorial)

The pods all see each other’s services

  1. oc exec $CPOD -c customer -n tutorial curl http://preference:8080
  2. oc exec $CPOD -c customer -n tutorial curl http://recommendation:8080
  3. oc exec $RPOD2 -c recommendation -n tutorial curl http://customer:8080
  4. or
  5. kubectl exec $CPOD -c customer -n tutorial curl http://preference:8080
  6. kubectl exec $CPOD -c customer -n tutorial curl http://recommendation:8080
  7. kubectl exec $RPOD2 -c recommendation -n tutorial curl http://customer:8080
  1. oc exec $CPOD -c customer -n tutorial curl http://localhost:15000/config_dump > afile.json
  2. or
  3. kubectl exec $CPOD -c customer -n tutorial curl http://localhost:15000/config_dump > afile.json

Look for route_config, containing "name": "8080" and you should see entries for customer, preference and recommendation

  1. "virtualHosts": [
  2. {
  3. "name": "customer.tutorial.svc.cluster.local:8080",
  4. "domains": [
  5. "customer.tutorial.svc.cluster.local",
  6. "customer.tutorial.svc.cluster.local:8080",
  7. "customer",
  8. "customer:8080",
  9. "customer.tutorial.svc.cluster",
  10. "customer.tutorial.svc.cluster:8080",
  11. "customer.tutorial.svc",
  12. "customer.tutorial.svc:8080",
  13. "customer.tutorial",
  14. "customer.tutorial:8080",
  15. "172.30.107.115",
  16. "172.30.107.115:8080"
  17. ],
  18. "routes": [
  19. {
  20. "match": {
  21. "prefix": "/"
  22. },
  23. "route": {
  24. "cluster": "outbound|8080||customer.tutorial.svc.cluster.local"
  25. },
  26. "decorator": {
  27. "operation": "default-route"
  28. }
  29. }
  30. ]
  31. },
  32. {
  33. "name": "istio-pilot.istio-system.svc.cluster.local:8080",
  34. "domains": [
  35. "istio-pilot.istio-system.svc.cluster.local",
  36. "istio-pilot.istio-system.svc.cluster.local:8080",
  37. "istio-pilot.istio-system",
  38. "istio-pilot.istio-system:8080",
  39. "istio-pilot.istio-system.svc.cluster",
  40. "istio-pilot.istio-system.svc.cluster:8080",
  41. "istio-pilot.istio-system.svc",
  42. "istio-pilot.istio-system.svc:8080",
  43. "172.30.142.41",
  44. "172.30.142.41:8080"
  45. ],
  46. "routes": [
  47. {
  48. "match": {
  49. "prefix": "/"
  50. },
  51. "route": {
  52. "cluster": "outbound|8080||istio-pilot.istio-system.svc.cluster.local"
  53. },
  54. "decorator": {
  55. "operation": "default-route"
  56. }
  57. }
  58. ]
  59. },
  60. {
  61. "name": "preference.tutorial.svc.cluster.local:8080",
  62. "domains": [
  63. "preference.tutorial.svc.cluster.local",
  64. "preference.tutorial.svc.cluster.local:8080",
  65. "preference",
  66. "preference:8080",
  67. "preference.tutorial.svc.cluster",
  68. "preference.tutorial.svc.cluster:8080",
  69. "preference.tutorial.svc",
  70. "preference.tutorial.svc:8080",
  71. "preference.tutorial",
  72. "preference.tutorial:8080",
  73. "172.30.26.194",
  74. "172.30.26.194:8080"
  75. ],
  76. "routes": [
  77. {
  78. "match": {
  79. "prefix": "/"
  80. },
  81. "route": {
  82. "cluster": "outbound|8080||preference.tutorial.svc.cluster.local"
  83. },
  84. "decorator": {
  85. "operation": "default-route"
  86. }
  87. }
  88. ]
  89. },
  90. {
  91. "name": "recommendation.tutorial.svc.cluster.local:8080",
  92. "domains": [
  93. "recommendation.tutorial.svc.cluster.local",
  94. "recommendation.tutorial.svc.cluster.local:8080",
  95. "recommendation",
  96. "recommendation:8080",
  97. "recommendation.tutorial.svc.cluster",
  98. "recommendation.tutorial.svc.cluster:8080",
  99. "recommendation.tutorial.svc",
  100. "recommendation.tutorial.svc:8080",
  101. "recommendation.tutorial",
  102. "recommendation.tutorial:8080",
  103. "172.30.103.127",
  104. "172.30.103.127:8080"
  105. ],
  106. "routes": [
  107. {
  108. "match": {
  109. "prefix": "/"
  110. },
  111. "route": {
  112. "cluster": "outbound|8080||recommendation.tutorial.svc.cluster.local"
  113. },
  114. "decorator": {
  115. "operation": "default-route"
  116. }
  117. }
  118. ]
  119. }
  120. ],

Now add a new destinationrule and virtualservice.

  1. istioctl create -f istiofiles/destination-rule-recommendation-v1-v2.yml
  2. istioctl create -f istiofiles/virtual-service-recommendation-v2.yml

The review the routes again

  1. oc exec $CPOD -c customer -n tutorial curl http://localhost:15000/config_dump > bfile.json
  2. or
  3. kubectl exec $CPOD -c customer -n tutorial curl http://localhost:15000/config_dump > bfile.json

Here is the Before:

  1. "route": {
  2. "cluster": "out.recommendation.springistio.svc.cluster.local|http",
  3. "timeout": "0s"
  4. },

and

  1. "decorator": {
  2. "operation": "default-route"
  3. }

And the After:

  1. "route": {
  2. "cluster": "outbound|8080|version-v2|recommendation.tutorial.svc.cluster.local",
  3. },

and

  1. "decorator": {
  2. "operation": "recommendation"
  3. }

If you need the Pod IP

  1. oc get pods -o jsonpath='{.items[*].status.podIP}' -l app=customer -n tutorial
  2. or
  3. kubectl get pods -o jsonpath='{.items[*].status.podIP}' -l app=customer -n tutorial

Dive into the istio-proxy container

  1. oc exec -it $CPOD -c istio-proxy -n tutorial /bin/bash
  2. or
  3. kubectl exec -it $CPOD -c istio-proxy -n tutorial /bin/bash
  4. cd /etc/istio/proxy
  5. ls
  6. cat envoy-rev0.json

Snowdrop Troubleshooting

https://github.com/snowdrop/spring-boot-quickstart-istio/blob/master/TROUBLESHOOT.md