From c0ab3bb0ba6043a04987e6fa3047d19a6be39e7a Mon Sep 17 00:00:00 2001 From: duanyingluo Date: Fri, 14 Feb 2020 00:05:57 +0800 Subject: [PATCH] Tomcat 9 --- README.md | 42 ++++++++++++++++++++++++--------------- docs/en-us/quickstart.md | 42 ++++++++++++++++++++++++--------------- docs/zh-cn/quickstart.md | 43 +++++++++++++++++++++++++--------------- 3 files changed, 79 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index aaee43c..fd6de55 100644 --- a/README.md +++ b/README.md @@ -24,47 +24,57 @@ You can download and install the ktctl from [Downloads And Install](https://rdc- ``` $ kubectl run tomcat --image=tomcat:9 --expose --port=8080 -kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead. -service/tomcat created -deployment.apps/tomcat created +service "tomcat" created +deployment.apps "tomcat" created # Deployment info $ kubectl get deployments -o wide --selector run=tomcat -NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR -tomcat 1 1 1 1 12m tomcat tomcat:9 run=tomcat +NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR +tomcat 1 1 1 1 47s tomcat tomcat:9 run=tomcat # Pods info $ kubectl get pods -o wide --selector run=tomcat -NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE -tomcat-cc7648444-r9tw4 1/1 Running 0 2m 172.16.0.147 cn-beijing.i-2ze11lz4lijf1pmecnwp +NAME READY STATUS RESTARTS AGE IP NODE +tomcat-5b75798b56-228r4 1/1 Running 0 1m 172.23.2.231 cn-beijing.192.168.0.8 # Service info $ kubectl get svc tomcat -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -tomcat ClusterIP 172.19.143.139 8080/TCP 4m +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +tomcat ClusterIP 172.21.14.57 8080/TCP 1m ``` ### Connect: Access Kubernetes resource from local ``` $ sudo ktctl connect -2019/06/19 11:11:07 Deploying proxy deployment kt-connect-daemon in namespace default -2019/06/19 11:11:07 Pod status is Pending -2019/06/19 11:11:09 Pod status is Running -2019/06/19 11:11:09 Success deploy proxy deployment kt-connect-daemon in namespace default -2019/06/19 11:11:18 KT proxy start successful +11:48PM INF Connect Start At 27758 +11:48PM INF Client address 192.168.3.120 +11:48PM INF Deploying shadow deployment kt-connect-daemon-uhojp in namespace default + +11:48PM INF Shadow Pod status is Pending +11:48PM INF Shadow Pod status is Running +11:48PM INF Shadow is ready. +11:48PM INF Success deploy proxy deployment kt-connect-daemon-uhojp in namespace default + +Forwarding from 127.0.0.1:2222 -> 22 +Forwarding from [::1]:2222 -> 22 +Handling connection for 2222 +Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts. +client: Connected. ``` Access PodIP: ``` -curl http://172.16.0.147:8080 +curl http://172.23.2.231:8080 +HTTP Status 404 – Not Found

HTTP Status 404 – Not Found


Type Status Report

Message Not found

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.31

``` Access ClusterIP: ``` -$ curl http://172.19.143.139:8080 +$ curl http://172.21.14.57:8080 +HTTP Status 404 – Not Found

HTTP Status 404 – Not Found


Type Status Report

Message Not found

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.31

``` Access Server internal DNS address diff --git a/docs/en-us/quickstart.md b/docs/en-us/quickstart.md index 2d9a31e..4546328 100644 --- a/docs/en-us/quickstart.md +++ b/docs/en-us/quickstart.md @@ -6,24 +6,23 @@ In this chapter, we will deployment a sample app(tomcat:9) in Kubernetes cluster ``` shell $ kubectl run tomcat --image=tomcat:9 --expose --port=8080 -kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead. -service/tomcat created -deployment.apps/tomcat created +service "tomcat" created +deployment.apps "tomcat" created # Deployment info $ kubectl get deployments -o wide --selector run=tomcat -NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR -tomcat 1 1 1 1 12m tomcat tomcat:9 run=tomcat +NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR +tomcat 1 1 1 1 47s tomcat tomcat:9 run=tomcat # Pods info $ kubectl get pods -o wide --selector run=tomcat -NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE -tomcat-cc7648444-r9tw4 1/1 Running 0 2m 172.16.0.147 cn-beijing.i-2ze11lz4lijf1pmecnwp +NAME READY STATUS RESTARTS AGE IP NODE +tomcat-5b75798b56-228r4 1/1 Running 0 1m 172.23.2.231 cn-beijing.192.168.0.8 # Service info $ kubectl get svc tomcat -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -tomcat ClusterIP 172.19.143.139 8080/TCP 4m +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +tomcat ClusterIP 172.21.14.57 8080/TCP 1m ``` ## Connect: Access APP From Local @@ -40,16 +39,27 @@ Connect to kubernetes cluster, KT will deployment a proxy pod in cluster: ```shell $ sudo ktctl connect --method=vpn -2019/06/19 11:11:07 Deploying proxy deployment kt-connect-daemon in namespace default -2019/06/19 11:11:07 Pod status is Pending -2019/06/19 11:11:09 Pod status is Running -2019/06/19 11:11:09 Success deploy proxy deployment kt-connect-daemon in namespace default -2019/06/19 11:11:18 KT proxy start successful +11:48PM INF Connect Start At 27758 +11:48PM INF Client address 192.168.3.120 +11:48PM INF Deploying shadow deployment kt-connect-daemon-uhojp in namespace default + +11:48PM INF Shadow Pod status is Pending +11:48PM INF Shadow Pod status is Running +11:48PM INF Shadow is ready. +11:48PM INF Success deploy proxy deployment kt-connect-daemon-uhojp in namespace default + +Forwarding from 127.0.0.1:2222 -> 22 +Forwarding from [::1]:2222 -> 22 +Handling connection for 2222 +Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts. +client: Connected. ``` ``` -$ curl http://172.16.0.147:8080 #Access PodIP from local -$ curl http://172.19.143.139:8080 #Access ClusterIP +$ curl http://172.23.2.231:8080 #Access PodIP from local +HTTP Status 404 – Not Found

HTTP Status 404 – Not Found


Type Status Report

Message Not found

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.31

+$ curl http://172.21.14.57:8080 #Access ClusterIP +HTTP Status 404 – Not Found

HTTP Status 404 – Not Found


Type Status Report

Message Not found

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.31

$ curl http://tomcat:8080 #Access Server internal DNS address ``` diff --git a/docs/zh-cn/quickstart.md b/docs/zh-cn/quickstart.md index da7a52b..509b25f 100644 --- a/docs/zh-cn/quickstart.md +++ b/docs/zh-cn/quickstart.md @@ -6,21 +6,20 @@ ``` shell $ kubectl run tomcat --image=tomcat:9 --expose --port=8080 -kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead. -service/tomcat created -deployment.apps/tomcat created +service "tomcat" created +deployment.apps "tomcat" created $ kubectl get deployments -o wide --selector run=tomcat -NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR -tomcat 1 1 1 1 12m tomcat tomcat:9 run=tomcat +NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR +tomcat 1 1 1 1 47s tomcat tomcat:9 run=tomcat $ kubectl get pods -o wide --selector run=tomcat -NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE -tomcat-cc7648444-r9tw4 1/1 Running 0 2m 172.16.0.147 cn-beijing.i-2ze11lz4lijf1pmecnwp +NAME READY STATUS RESTARTS AGE IP NODE +tomcat-5b75798b56-228r4 1/1 Running 0 1m 172.23.2.231 cn-beijing.192.168.0.8 $ kubectl get svc tomcat -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -tomcat ClusterIP 172.19.143.139 8080/TCP 4m +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +tomcat ClusterIP 172.21.14.57 8080/TCP 1m ``` ## Connect:连接集群网络 @@ -37,18 +36,30 @@ tomcat ClusterIP 172.19.143.139 8080/TCP 4m ```shell $ sudo ktctl connect --method=vpn -2019/06/19 11:11:07 Deploying proxy deployment kt-connect-daemon in namespace default -2019/06/19 11:11:07 Pod status is Pending -2019/06/19 11:11:09 Pod status is Running -2019/06/19 11:11:09 Success deploy proxy deployment kt-connect-daemon in namespace default -2019/06/19 11:11:18 KT proxy start successful +11:48PM INF Connect Start At 27758 +11:48PM INF Client address 192.168.3.120 +11:48PM INF Deploying shadow deployment kt-connect-daemon-uhojp in namespace default + +11:48PM INF Shadow Pod status is Pending +11:48PM INF Shadow Pod status is Running +11:48PM INF Shadow is ready. +11:48PM INF Success deploy proxy deployment kt-connect-daemon-uhojp in namespace default + +Forwarding from 127.0.0.1:2222 -> 22 +Forwarding from [::1]:2222 -> 22 +Handling connection for 2222 +Warning: Permanently added '[127.0.0.1]:2222' (ECDSA) to the list of known hosts. +client: Connected. ``` 启用VPN后直接访问集群资源: ``` -$ curl http://172.16.0.147:8080 #在本地直接访问PodIP -$ curl http://172.19.143.139:8080 #在本地访问ClusteriIP +$ curl curl http://172.23.2.231:8080 #在本地直接访问PodIP +HTTP Status 404 – Not Found

HTTP Status 404 – Not Found


Type Status Report

Message Not found

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.31

+ +$ curl http://172.21.14.57:8080 #在本地访问ClusteriIP +HTTP Status 404 – Not Found

HTTP Status 404 – Not Found


Type Status Report

Message Not found

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/9.0.31

$ curl http://tomcat:8080 #使用Service的域名访问 ```