mirror of
https://github.com/wahyd4/kt-connect.git
synced 2026-08-10 13:55:53 +10:00
Merge pull request #71 from aaa8825121/master
quick start example doc issue.
This commit is contained in:
@@ -23,48 +23,58 @@ You can download and install the ktctl from [Downloads And Install](https://rdc-
|
||||
### Deploy a service in Kubernetes
|
||||
|
||||
```
|
||||
$ kubectl run tomcat --image=tomcat:7 --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
|
||||
$ kubectl run tomcat --image=tomcat:9 --expose --port=8080
|
||||
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:7 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 <none>
|
||||
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 <none> 8080/TCP 4m
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
tomcat ClusterIP 172.21.14.57 <none> 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
|
||||
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html>
|
||||
```
|
||||
|
||||
Access ClusterIP:
|
||||
|
||||
```
|
||||
$ curl http://172.19.143.139:8080
|
||||
$ curl http://172.21.14.57:8080
|
||||
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html>
|
||||
```
|
||||
|
||||
Access Server internal DNS address
|
||||
|
||||
+28
-18
@@ -1,29 +1,28 @@
|
||||
# Quick Start Guide
|
||||
|
||||
In this chapter, we will deployment a sample app(tomcat:7) in Kubernetes cluster. With Kt to access the app from user labtop or exchange the request to user labtop.
|
||||
In this chapter, we will deployment a sample app(tomcat:9) in Kubernetes cluster. With Kt to access the app from user labtop or exchange the request to user labtop.
|
||||
|
||||
## Create a Demo APP in Cluster
|
||||
|
||||
``` shell
|
||||
$ kubectl run tomcat --image=tomcat:7 --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
|
||||
$ kubectl run tomcat --image=tomcat:9 --expose --port=8080
|
||||
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:7 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 <none>
|
||||
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 <none> 8080/TCP 4m
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
tomcat ClusterIP 172.21.14.57 <none> 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
|
||||
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html>
|
||||
$ curl http://172.21.14.57:8080 #Access ClusterIP
|
||||
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html>
|
||||
$ curl http://tomcat:8080 #Access Server internal DNS address
|
||||
```
|
||||
|
||||
|
||||
+30
-19
@@ -1,26 +1,25 @@
|
||||
# 快速开始
|
||||
|
||||
这里,我们通过一个简单的示例,来体验KT的主要能力。 这里我们会在集群中部署一个Tomcat:7的镜像,并且通过KT直接在本地访问该服务,同时也可以将集群中所有原本对该应用的请求转发到本地。
|
||||
这里,我们通过一个简单的示例,来体验KT的主要能力。 这里我们会在集群中部署一个Tomcat:9的镜像,并且通过KT直接在本地访问该服务,同时也可以将集群中所有原本对该应用的请求转发到本地。
|
||||
|
||||
## 部署实例应用
|
||||
|
||||
``` shell
|
||||
$ kubectl run tomcat --image=tomcat:7 --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
|
||||
$ kubectl run tomcat --image=tomcat:9 --expose --port=8080
|
||||
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:7 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 <none>
|
||||
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 <none> 8080/TCP 4m
|
||||
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
tomcat ClusterIP 172.21.14.57 <none> 8080/TCP 1m
|
||||
```
|
||||
|
||||
## Connect:连接集群网络
|
||||
@@ -37,18 +36,30 @@ tomcat ClusterIP 172.19.143.139 <none> 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
|
||||
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html>
|
||||
|
||||
$ curl http://172.21.14.57:8080 #在本地访问ClusteriIP
|
||||
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Not found</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.31</h3></body></html>
|
||||
$ curl http://tomcat:8080 #使用Service的域名访问
|
||||
```
|
||||
|
||||
@@ -110,7 +121,7 @@ SSH Remote port-forward for POD starting
|
||||
2019/06/19 11:19:14 ssh remote port-forward start at pid: 3567
|
||||
```
|
||||
|
||||
在本地或者集群中访问原本指向Tomcat:7的应用,查看输出结果:
|
||||
在本地或者集群中访问原本指向Tomcat:9的应用,查看输出结果:
|
||||
|
||||
> 注意如果未运行`ktctl connect`,只能从集群内访问
|
||||
|
||||
|
||||
Reference in New Issue
Block a user