카타코더 - Istio 1.0.x workshop: Deploy microservices

카타코더 - Service Mesh with Istio on OpenShift
# 코스
카타코더 - Istio 1.0.x workshop: Istio Introduction
카타코더 - Istio 1.0.x workshop: Deploy microservices
카타코더 - Istio 1.0.x workshop: Monitoring and Tracing
카타코더 - Istio 1.0.x workshop: Simple Routing
카타코더 - Istio 1.0.x workshop: Advanced RouteRules
카타코더 - Istio 1.0.x workshop: Fault Injection
카타코더 - Istio 1.0.x workshop: Circuit Breaker
카타코더 - Istio 1.0.x workshop: Egress
카타코더 - Istio 1.0.x Advanced: Observing with Kiali
카타코더 - Istio 1.0.x Advanced: Mutual TLS

1 Create the Example project[ | ]

$ oc new-project tutorial
Now using project "tutorial" on server "https://master:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git

to build a new example application in Ruby.
$ oc adm policy add-scc-to-user privileged -z default -n tutorial
scc "privileged" added to: ["system:serviceaccount:tutorial:default"]

2 Clone the Example project[ | ]

$ git clone https://github.com/redhat-developer-demos/istio-tutorial/
Cloning into 'istio-tutorial'...
remote: Enumerating objects: 141, done.
remote: Counting objects: 100% (141/141), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 6868 (delta 103), reused 97 (delta 69), pack-reused 6727
Receiving objects: 100% (6868/6868), 27.80 MiB | 10.23 MiB/s, done.
Resolving deltas: 100% (3722/3722), done.

3 Deploy Customer microservice[ | ]

$ cd ~/projects/istio-tutorial/customer/java/springboot
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< com.redhat.developer.demos:customer >-----------------
[INFO] Building customer 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ customer ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ customer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /root/projects/istio-tutorial/customer/java/springboot/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ customer---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /root/projects/istio-tutorial/customer/java/springboot/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ customer ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /root/projects/istio-tutorial/customer/java/springboot/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ customer ---
[INFO] Downloading from jboss-enterprise-maven-repository-ga: https://maven.repository.redhat.com/ga/org/apache/maven/surefire/maven-surefire-common/2.18.1/maven-surefire-common-2.18.1.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-surefire-common/2.18.1/maven-surefire-common-2.18.1.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-surefire-common/2.18.1/maven-surefire-common-2.18.1.pom (6.3 kB at 87 kB/s)
[INFO] Downloading from jboss-enterprise-maven-repository-ga: https://maven.repository.redhat.com/ga/org/apache/maven/surefire/surefire-api/2.18.1/surefire-api-2.18.1.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-api/2.18.1/surefire-api-2.18.1.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-api/2.18.1/surefire-api-2.18.1.pom (2.3 kB at 134 kB/s)
[INFO] Downloading from jboss-enterprise-maven-repository-ga: https://maven.repository.redhat.com/ga/org/apache/maven/surefire/surefire-booter/2.18.1/surefire-booter-2.18.1.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.18.1/surefire-booter-2.18.1.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.18.1/surefire-booter-2.18.1.pom (2.9 kB at 97 kB/s)
[INFO] Downloading from jboss-enterprise-maven-repository-ga: https://maven.repository.redhat.com/ga/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.pom
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.pom (17 kB at 668 kB/s)
[INFO] Downloading from jboss-enterprise-maven-repository-ga: https://maven.repository.redhat.com/ga/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[INFO] Downloading from jboss-enterprise-maven-repository-ga: https://maven.repository.redhat.com/ga/org/apache/maven/surefire/surefire-booter/2.18.1/surefire-booter-2.18.1.jar
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.18.1/surefire-booter-2.18.1.jar
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-booter/2.18.1/surefire-booter-2.18.1.jar (40 kB at 831 kB/s)
[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/commons/commons-lang3/3.1/commons-lang3-3.1.jar (316 kB at 4.7 MB/s)
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ customer ---
[INFO] Building jar: /root/projects/istio-tutorial/customer/java/springboot/target/customer.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.8.RELEASE:repackage (default) @ customer ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.566 s
[INFO] Finished at: 2019-07-02T04:47:43Z
[INFO] ------------------------------------------------------------------------

3.1 Create the customer docker image[ | ]

Dockerfile
FROM fabric8/java-jboss-openjdk8-jdk:1.5.2
ENV JAVA_APP_DIR=/deployments
ENV JAEGER_SERVICE_NAME=customer\
  JAEGER_ENDPOINT=http://jaeger-collector.istio-system.svc:14268/api/traces\
  JAEGER_PROPAGATION=b3\
  JAEGER_SAMPLER_TYPE=const\
  JAEGER_SAMPLER_PARAM=1
EXPOSE 8080 8778 9779
COPY target/customer.jar /deployments/
$ docker build -t example/customer .
Sending build context to Docker daemon 23.29 MB
Step 1/5 : FROM fabric8/java-jboss-openjdk8-jdk:1.5.2
 ---> 2d81027cb149
Step 2/5 : ENV JAVA_APP_DIR /deployments
 ---> Running in ec067add5657
 ---> aaa500d79ec6
Removing intermediate container ec067add5657
Step 3/5 : ENV JAEGER_SERVICE_NAME customer JAEGER_ENDPOINT http://jaeger-collector.istio-system.svc:14268/api/traces JAEGER_PROPAGATION b3 JAEGER_SAMPLER_TYPE const JAEGER_SAMPLER_PARAM 1
 ---> Running in 261a60587462
 ---> 3c32489d3cfe
Removing intermediate container 261a60587462
Step 4/5 : EXPOSE 8080 8778 9779
 ---> Running in 33f78d2bb3ab
 ---> 1cfafa16035d
Removing intermediate container 33f78d2bb3ab
Step 5/5 : COPY target/customer.jar /deployments/
 ---> 519e37ef2fd4
Removing intermediate container 3f849dfa94f9
Successfully built 519e37ef2fd4
$ docker images | grep customer
example/customer                                                               latest            519e37ef2fd4        About a minute ago   462 MB

3.2 Injecting the sidecar proxy[ | ]

$ istioctl version
Version: 1.0.5
GitRevision: c1707e45e71c75d74bf3a5dec8c7086f32f32fad
User: root@6f6ea1061f2b
Hub: docker.io/istio
GolangVersion: go1.10.4
BuildStatus: Clean
$ oc project tutorial
Already on project "tutorial" on server "https://master:8443".
$ oc apply -f <(istioctl kube-inject -f ../../kubernetes/Deployment.yml) -n tutorial
deployment.extensions/customer created
$ oc create -f ../../kubernetes/Service.yml
service/customer created
$ oc expose service customer
route.route.openshift.io/customer exposed
$ oc get route
NAME       HOST/PORT                                                             PATH    SERVICES   PORT      TERMINATION   WILDCARD
customer   customer-tutorial.2886795273-80-rhsummit1.environments.katacoda.com    customer   http                    None
$ oc get pods
NAME                        READY     STATUS    RESTARTS   AGE
customer-8559bf9955-tmmqh   2/2       Running   0          29s
$ curl http://customer-tutorial.2886795291-80-cykoria05.environments.katacoda.com
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 502 (Server Error)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>502.</b> <ins>That’s an error.</ins>
  <p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.  <ins>That’s all we know.</ins>

4 Deploy Preference microservice[ | ]

$ cd ~/projects/istio-tutorial/preference/java/springboot
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.redhat.developer.demos:preference >----------------
[INFO] Building preference 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ preference ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ preference ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to /root/projects/istio-tutorial/preference/java/springboot/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ preference ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /root/projects/istio-tutorial/preference/java/springboot/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ preference ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /root/projects/istio-tutorial/preference/java/springboot/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ preference ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ preference ---
[INFO] Building jar: /root/projects/istio-tutorial/preference/java/springboot/target/preference.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.5.8.RELEASE:repackage (default) @ preference ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.792 s
[INFO] Finished at: 2019-07-02T05:32:53Z
[INFO] ------------------------------------------------------------------------

4.1 Create the preference docker image[ | ]

Dockerfile
FROM fabric8/java-jboss-openjdk8-jdk:1.5.2
ENV JAVA_APP_DIR=/deployments
ENV JAEGER_SERVICE_NAME=preference \
  JAEGER_ENDPOINT=http://jaeger-collector.istio-system.svc:14268/api/traces \
  JAEGER_PROPAGATION=b3 \
  JAEGER_SAMPLER_TYPE=const \
  JAEGER_SAMPLER_PARAM=1
EXPOSE 8080 8778 9779
COPY target/preference.jar /deployments/
$ docker build -t example/preference:v1 .
Sending build context to Docker daemon 23.24 MB
Step 1/5 : FROM fabric8/java-jboss-openjdk8-jdk:1.5.2
 ---> 2d81027cb149
Step 2/5 : ENV JAVA_APP_DIR /deployments
 ---> Using cache
 ---> 007ab2deac12
Step 3/5 : ENV JAEGER_SERVICE_NAME preference JAEGER_ENDPOINT http://jaeger-collector.istio-system.svc:14268/api/traces JAEGER_PROPAGATION b3 JAEGER_SAMPLER_TYPE const JAEGER_SAMPLER_PARAM 1
 ---> Running in 653ae2cbb252
 ---> e025633f37aa
Removing intermediate container 653ae2cbb252
Step 4/5 : EXPOSE 8080 8778 9779
 ---> Running in 300056f42d82
 ---> 2896d16ed7b9
Removing intermediate container 300056f42d82
Step 5/5 : COPY target/preference.jar /deployments/
 ---> 6e62ae9ff0ba
Removing intermediate container 69bfa17f6b68
Successfully built 6e62ae9ff0ba
$ docker images | grep preference
example/preference                                                             v1                  6e62ae9ff0ba        17 seconds ago      462 MB

4.2 Injecting the sidecar proxy[ | ]

$ oc apply -f <(istioctl kube-inject -f ../../kubernetes/Deployment.yml) -n tutorial
deployment.extensions/recommendation-v1 created
$ oc create -f ../../kubernetes/Service.yml
service/recommendation created
$ oc get pods
NAME                                 READY     STATUS    RESTARTS   AGE
customer-8559bf9955-nc7jj            2/2       Running   0          7m
recommendation-v1-659b4f76fb-556nr   2/2       Running   0          19s
$ curl http://customer-tutorial.2886795275-80-rhsummit1.environments.katacoda.com
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 502 (Server Error)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>502.</b> <ins>That’s an error.</ins>
  <p>The server encountered a temporary error and could not complete your request.<p>Please try again in 30 seconds.  <ins>That’s all we know.</ins>

5 Deploy Recommendation microservice[ | ]

5.1 Create the recommendations docker image[ | ]

5.2 Injecting the sidecar proxy[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}