• kubernets 集群和本地环境联调环境打通工具kt-connect


    原文链接:https://github.com/alibaba/kt-connect

    官方github:https://github.com/alibaba/kt-connect

    一、准备环境

    所有机器都是:centos 7.5

    本地Linux机器:localhost

    k8s集群机器:k8s-master-15-81

    二、本地Linux安装ktctl

    在本地Linux机器操作:

    # 切换到root用户
    sudo su 

    mkdir /root/.kube mkdir /root/tools
    cd /root/tools/
    pip
    install sshuttle curl -OL https://rdc-incubators.oss-cn-beijing.aliyuncs.com/stable/ktctl_linux_amd64.tar.gz tar -xzvf ktctl_linux_amd64.tar.gz mv ktctl_linux_amd64 /usr/local/bin/ktctl ktctl -h

    [root@localhost ~]# ktctl -v
    Kubernetes Develope Tools version 0.0.4

    这种安装的可能不是最新版,也可以离线下载并编译,下载地址:

    https://github.com/alibaba/kt-connect/releases/

    但是我尝试编译,报错了

    [root@k8s-master-15-81 ~]# cd tools/
    [root@k8s-master-15-81 tools]# ll
    total 1228
    drwxr-xr-x 11 root root    4096 Oct 29 09:31 kt-connect-kt-0.0.6
    -rw-r--r--  1 root root 1251777 Oct 29 09:20 kt-connect-kt-0.0.6.zip
    [root@k8s-master-15-81 tools]# cd kt-connect-kt-0.0.6/
    [root@k8s-master-15-81 kt-connect-kt-0.0.6]# ll
    total 80
    drwxr-xr-x 2 root root  4096 Oct 29 09:32 bin
    drwxr-xr-x 5 root root  4096 Oct  9 19:43 cmd
    drwxr-xr-x 3 root root  4096 Oct  9 19:43 config
    drwxr-xr-x 7 root root  4096 Oct  9 19:43 docker
    drwxr-xr-x 6 root root  4096 Oct  9 19:43 docs
    -rw-r--r-- 1 root root  1314 Oct  9 19:43 go.mod
    -rw-r--r-- 1 root root 21123 Oct  9 19:43 go.sum
    -rw-r--r-- 1 root root  1076 Oct  9 19:43 LICENSE
    -rw-r--r-- 1 root root  1100 Oct  9 19:43 package.json
    drwxr-xr-x 5 root root  4096 Oct  9 19:43 pkg
    drwxr-xr-x 2 root root  4096 Oct  9 19:43 public
    -rw-r--r-- 1 root root  5570 Oct  9 19:43 README.md
    -rwxr-xr-x 1 root root   299 Oct  9 19:43 release.sh
    drwxr-xr-x 7 root root  4096 Oct  9 19:43 src
    [root@k8s-master-15-81 kt-connect-kt-0.0.6]# go build -o "output/ktctl/ktctl" ./cmd/ktctl
    go: finding github.com/deckarep/golang-set v1.7.1
    go: finding github.com/jessevdk/go-assets v0.0.0-20160921144138-4f4301a06e15
    go: finding github.com/imdario/mergo v0.3.7
    go: finding github.com/thinkerou/favicon v0.1.0
    go: finding github.com/rs/zerolog v0.0.0-20190704061603-77a169535877
    go: finding github.com/gorilla/websocket v1.4.1
    go: finding github.com/golang/protobuf v1.3.2
    go: finding github.com/campoy/embedmd v0.0.0-20171205015432-c59ce00e0296
    go: finding github.com/gin-gonic/autotls v0.0.0-20180426091246-be87bd5ef97b
    go: finding github.com/urfave/cli v0.0.0-20190203184040-693af58b4d51
    go: finding github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
    go: finding github.com/zenazn/goji v0.9.0
    go: finding github.com/miekg/dns v0.0.0-20190106042521-5beb9624161b
    go: k8s.io/apimachinery@v0.0.0-20190717022731-0bb8574e0887: unrecognized import path "k8s.io/apimachinery" (https fetch: Get https://k8s.io/apimachinery?go-get=1: dial tcp 35.201.71.162:443: i/o timeout)
    go: k8s.io/utils@v0.0.0-20190712204705-3dccf664f023: unrecognized import path "k8s.io/utils" (https fetch: Get https://k8s.io/utils?go-get=1: dial tcp 35.201.71.162:443: i/o timeout)
    go: k8s.io/client-go@v0.0.0-20190620085101-78d2af792bab: unrecognized import path "k8s.io/client-go" (https fetch: Get https://k8s.io/client-go?go-get=1: dial tcp 35.201.71.162:443: i/o timeout)
    go: finding github.com/pkg/errors v0.8.1
    go: finding github.com/kubernetes/dashboard v1.10.1
    go: golang.org/x/lint@v0.0.0-20181011164241-5906bd5c48cd: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
    go: finding github.com/dustin/go-broadcast v0.0.0-20171205050544-f664265f5a66
    go: finding github.com/manucorporat/stats v0.0.0-20180402194714-3ba42d56d227
    go: golang.org/x/time@v0.0.0-20190308202827-9d24e82272b4: unrecognized import path "golang.org/x/time" (https fetch: Get https://golang.org/x/time?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
    go: finding github.com/rs/xid v1.2.1
    go: google.golang.org/grpc@v1.15.0: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
    go: finding github.com/gin-gonic/gin v1.4.0
    go: k8s.io/api@v0.0.0-20190717022910-653c86b0609b: unrecognized import path "k8s.io/api" (https fetch: Get https://k8s.io/api?go-get=1: dial tcp 35.201.71.162:443: i/o timeout)
    go: golang.org/x/tools@v0.0.0-20190425163242-31fd60d6bfdc: unrecognized import path "golang.org/x/tools" (https fetch: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
    go: error loading module requirements
    [root@k8s-master-15-81 kt-connect-kt-0.0.6]#
    [root@k8s-master-15-81 ~]# go version
    go version go1.12.9 linux/amd64

    编译报错问题解决方法:

    [root@k8s-master-15-81 kt-connect-kt-0.0.6]# export GOPROXY="https://goproxy.io"
    [root@k8s-master-15-81 kt-connect-kt-0.0.6]# go build -o "output/ktctl/ktctl" ./cmd/ktctl
    go: finding k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887
    go: finding k8s.io/utils v0.0.0-20190712204705-3dccf664f023
    go: finding k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
    go: finding golang.org/x/lint v0.0.0-20181011164241-5906bd5c48cd
    go: finding k8s.io/api v0.0.0-20190717022910-653c86b0609b
    go: finding github.com/stretchr/testify v1.3.0
    go: finding github.com/mattn/go-isatty v0.0.7
    go: finding gopkg.in/yaml.v2 v2.2.2
    go: finding golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c
    go: finding github.com/golang/protobuf v1.3.1
    go: finding github.com/ugorji/go v1.1.4
    go: finding github.com/modern-go/reflect2 v1.0.1
    go: finding github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf
    go: finding k8s.io/utils v0.0.0-20190221042446-c2654d5206da
    go: finding golang.org/x/net v0.0.0-20190206173232-65e2d4e15006
    go: finding github.com/evanphx/json-patch v0.0.0-20190203023257-5858425f7550
    go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
    go: finding github.com/stretchr/objx v0.1.0
    go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
    go: finding github.com/davecgh/go-spew v1.1.1
    go: finding github.com/stretchr/testify v1.2.2
    go: finding github.com/peterbourgon/diskv v2.0.1+incompatible
    go: finding google.golang.org/grpc v1.15.0
    go: finding github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda
    go: finding k8s.io/klog v0.3.1
    go: finding github.com/evanphx/json-patch v4.2.0+incompatible
    go: finding github.com/onsi/gomega v1.5.0
    go: finding github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96
    go: finding golang.org/x/text v0.3.0
    go: finding github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d
    go: finding golang.org/x/time v0.0.0-20161028155119-f51c12702a4d
    go: finding golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223
    go: finding golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
    go: finding golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc
    go: finding github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
    go: finding github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f
    go: finding golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
    go: finding github.com/spf13/pflag v1.0.3
    go: finding google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8
    go: finding golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
    go: finding sigs.k8s.io/yaml v1.1.0
    go: finding golang.org/x/text v0.3.2
    go: finding github.com/golang/protobuf v1.2.0
    go: finding github.com/spf13/pflag v1.0.1
    go: finding github.com/kisielk/gotool v1.0.0
    go: finding github.com/google/uuid v1.1.1
    go: finding honnef.co/go/tools v0.0.0-20180728063816-88497007e858
    go: finding k8s.io/api v0.0.0-20190620084959-7cf5895f2711
    go: finding golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
    go: finding github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e
    go: finding k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
    go: finding github.com/google/go-cmp v0.3.0
    go: finding github.com/hpcloud/tail v1.0.0
    go: finding golang.org/x/net v0.0.0-20190311183353-d8887717615a
    go: finding github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3
    go: finding gopkg.in/fsnotify.v1 v1.4.7
    go: finding golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e
    go: finding github.com/spf13/afero v1.2.2
    go: finding github.com/google/btree v0.0.0-20160524151835-7d79101e329e
    go: finding github.com/gogo/protobuf v1.0.0
    go: finding github.com/kr/pretty v0.1.0
    go: finding github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be
    go: finding k8s.io/klog v0.3.0
    go: finding k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30
    go: finding google.golang.org/appengine v1.1.0
    go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
    go: finding golang.org/x/net v0.0.0-20180826012351-8a410e7b638d
    go: finding gopkg.in/go-playground/validator.v8 v8.18.2
    go: finding github.com/davecgh/go-spew v1.1.0
    go: finding github.com/onsi/ginkgo v1.6.0
    go: finding github.com/fsnotify/fsnotify v1.4.7
    go: finding golang.org/x/lint v0.0.0-20180702182130-06c8688daad7
    go: finding golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
    go: finding github.com/json-iterator/go v1.1.6
    go: finding gopkg.in/yaml.v2 v2.2.1
    go: finding github.com/pmezard/go-difflib v1.0.0
    go: finding cloud.google.com/go v0.26.0
    go: finding github.com/golang/lint v0.0.0-20180702182130-06c8688daad7
    go: finding github.com/Azure/go-autorest v11.1.2+incompatible
    go: finding golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
    go: finding k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058
    go: finding golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a
    go: finding golang.org/x/sys v0.0.0-20190312061237-fead79001313
    go: finding github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903
    go: finding github.com/google/uuid v1.0.0
    go: finding github.com/gophercloud/gophercloud v0.0.0-20190126172459-c818fa66e4c8
    go: finding github.com/google/gofuzz v1.0.0
    go: finding golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52
    go: finding gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7
    go: finding golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
    go: finding github.com/hashicorp/golang-lru v0.5.0
    go: finding gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127
    go: finding github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680
    go: finding golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
    go: finding github.com/golang/mock v1.1.1
    go: finding github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2
    go: finding github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff
    go: finding github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c
    go: finding github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46
    go: finding github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2
    go: finding github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501
    go: finding github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3
    go: finding github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365
    go: finding golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
    go: finding k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6
    go: finding github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0
    go: finding golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
    go: finding github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a
    go: finding github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1
    go: finding golang.org/x/net v0.0.0-20170114055629-f2499483f923
    go: finding golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea
    go: finding github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7
    go: finding github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87
    go: finding google.golang.org/appengine v1.5.0
    go: finding golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
    go: finding github.com/onsi/ginkgo v1.8.0
    go: finding github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9
    go: finding gopkg.in/go-playground/assert.v1 v1.2.1
    go: finding github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
    go: finding github.com/kr/text v0.1.0
    go: finding github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9
    go: finding github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c
    go: finding github.com/client9/misspell v0.3.4
    go: finding k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92
    go: finding github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da
    go: finding github.com/PuerkitoBio/purell v1.0.0
    go: finding sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e
    go: finding github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7
    go: finding golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09
    go: finding github.com/gogo/protobuf v0.0.0-20171007142547-342cbe0a0415
    go: finding golang.org/x/net v0.0.0-20180724234803-3673e40ba225
    go: finding google.golang.org/appengine v1.4.0
    go: finding github.com/onsi/gomega v0.0.0-20190113212917-5533ce8a0da3
    go: finding github.com/kr/pty v1.1.1
    go: finding github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633
    go: finding golang.org/x/text v0.0.0-20160726164857-2910a502d2bf
    go: finding cloud.google.com/go v0.34.0
    go: finding github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d
    go: finding golang.org/x/crypto v0.0.0-20181025213731-e84da0312774
    go: finding github.com/imdario/mergo v0.3.5
    go: finding gopkg.in/inf.v0 v0.9.0
    go: finding github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367
    go: finding golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e
    go: downloading k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
    go: downloading github.com/rs/zerolog v0.0.0-20190704061603-77a169535877
    go: downloading k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887
    go: downloading k8s.io/api v0.0.0-20190717022910-653c86b0609b
    go: downloading github.com/urfave/cli v0.0.0-20190203184040-693af58b4d51
    go: downloading github.com/deckarep/golang-set v1.7.1
    go: extracting github.com/urfave/cli v0.0.0-20190203184040-693af58b4d51
    go: extracting github.com/deckarep/golang-set v1.7.1
    go: extracting github.com/rs/zerolog v0.0.0-20190704061603-77a169535877
    go: extracting k8s.io/apimachinery v0.0.0-20190717022731-0bb8574e0887
    go: downloading github.com/gogo/protobuf v1.0.0
    go: downloading github.com/google/gofuzz v1.0.0
    go: downloading gopkg.in/inf.v0 v0.9.0
    go: downloading golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
    go: downloading k8s.io/klog v0.3.1
    go: extracting k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
    go: extracting github.com/google/gofuzz v1.0.0
    go: extracting gopkg.in/inf.v0 v0.9.0
    go: extracting k8s.io/klog v0.3.1
    go: downloading golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
    go: downloading golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
    go: downloading github.com/spf13/pflag v1.0.3
    go: extracting golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a
    go: extracting github.com/spf13/pflag v1.0.3
    go: extracting k8s.io/api v0.0.0-20190717022910-653c86b0609b
    go: extracting golang.org/x/net v0.0.0-20190613194153-d28f0bde5980
    go: downloading github.com/davecgh/go-spew v1.1.1
    go: downloading cloud.google.com/go v0.34.0
    go: downloading k8s.io/utils v0.0.0-20190712204705-3dccf664f023
    go: downloading github.com/imdario/mergo v0.3.7
    go: downloading github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d
    go: downloading github.com/golang/protobuf v1.3.2
    go: downloading github.com/modern-go/reflect2 v1.0.1
    go: extracting golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
    go: extracting github.com/davecgh/go-spew v1.1.1
    go: downloading github.com/json-iterator/go v1.1.6
    go: extracting github.com/imdario/mergo v0.3.7
    go: downloading sigs.k8s.io/yaml v1.1.0
    go: downloading golang.org/x/text v0.3.2
    go: extracting k8s.io/utils v0.0.0-20190712204705-3dccf664f023
    go: extracting github.com/modern-go/reflect2 v1.0.1
    go: extracting sigs.k8s.io/yaml v1.1.0
    go: downloading golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
    go: extracting github.com/gogo/protobuf v1.0.0
    go: extracting github.com/json-iterator/go v1.1.6
    go: downloading gopkg.in/yaml.v2 v2.2.2
    go: downloading golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
    go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
    go: extracting github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d
    go: extracting golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
    go: extracting github.com/golang/protobuf v1.3.2
    go: extracting gopkg.in/yaml.v2 v2.2.2
    go: extracting github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
    go: extracting cloud.google.com/go v0.34.0
    go: extracting golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f
    go: extracting golang.org/x/text v0.3.2
    
    
    编译后的文件为:
    [root@k8s-master-15-81 kt-connect-kt-0.0.6]# ll output/ktctl/
    total 35200
    -rwxr-xr-x 1 root root 36042716 Oct 29 15:55 ktctl

    三、在Kubernetes中部署联调服务

    在k8s集群操作:

    kubectl run tomcat --image=tomcat:7 --expose --port=8080
    会自动创建deployments和service

    四、Connect 从本地访问Kubernetes资源

    在k8s集群操作:把admin.conf文件分发给本地linux机器

    [root@k8s-master-15-81 ~]# scp /etc/kubernetes/admin.conf root@192.168.15.91:/root/.kube

    在本地Linux机器操作:

    [root@localhost ~]# ktctl --kubeconfig /root/.kube/admin.conf --debug connect
    2019/10/29 11:58:46 Client address 10.0.0.100
    2019/10/29 11:58:46 Deploying proxy deployment kt-connect-daemon-fbyyp in namespace default
    2019/10/29 11:58:46 Pods not ready......
    2019/10/29 11:58:48 Pod status is Pending
    2019/10/29 11:58:50 Pod status is Running
    2019/10/29 11:58:50 Success deploy proxy deployment kt-connect-daemon-fbyyp in namespace default
    2019/10/29 11:58:50 Child, os.Args = [ktctl --kubeconfig /root/.kube/admin.conf --debug connect]
    2019/10/29 11:58:50 Child, cmd.Args = [kubectl --kubeconfig=/root/.kube/admin.conf -n default port-forward deployments/kt-connect-daemon-fbyyp 2222:22]
    Daemon Start At 18753


    #root用户执行,不需要操作 # ktctl
    --kubeconfig /home/luanpeng/.kube/config --debug connect

    如果提示已经运行,则可以在k8s中把deployment删除,在客户端把/home/luanpeng/.ktctl/文件夹删除.



    运行成功后可以查看是否成功启动sshuttle,这是老版本的,新版本不能这样判断。

    ps -ef |grep sshuttle

    [root@localhost ~]# ps -ef |grep sshuttle  #此时进程不存在
    root 18647 18448 0 15:24 pts/1 00:00:00 grep --color=auto sshuttle
    [root@localhost ~]#

    如果sshuttle两个进程没有启动,则说明启动失败

    /usr/bin/python3 /usr/local/bin/sshuttle --dns --to-ns 10.42.0.58 -e ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -i /root/.kt_id_rsa -r 
    
    /usr/bin/python3 /usr/local/bin/sshuttle --method auto --firewall

    在这种场景下,开发者只要直接使用ktctl connect打通本地到集群的网络即可,就可以直接在本地通过PodIP/ClusterIP/DNS地址访问集群中的服务。

    访问PodIP:deamon通,其他的有的通,有点不通

    curl http://172.16.0.147:8080 

    访问ClusterIP:不通

    curl http://172.19.143.139:8080

    Access Server内部DNS地址:不通(未测试成功, 提示Could not resolve host)

    # 先看是否能正常解析
    nslookup tomcat.default.svc.cluster.local
    # 试一下http请求
    $ curl http://tomcat.default.svc.cluster.local:8080

    四、Exchange从群集访问本地

    在本地创建Tomcat 8并公开8080端口

    docker run -itd -p 8080:8080 tomcat:8
    $ ktctl exchange tomcat --expose 8080

    暴露本地服务到k8s中

    ktctl exchange tomcat --expose 8080

    在k8spod中通过内部服务DNS地址访问本地tomcat:

    注意:如果kubectl connect未运行,则只能从群集访问

    curl http://tomcat.default.svc.cluster.local:8080 | grep '<h1>'

    在这个场景下,我们希望集群中所有对服务C的访问能够请求到本地正在开发的C’。因此开发者可以通过ktctl exhcnage命令,在集群内部署一个Shadow容器已接管所有原本对C实例的请求,再通过Shadow容器将请求转发到本地。并在退出命令式恢复集群中C的实例状态。

    玩转Kubernetes开发测试环境

    https://mp.weixin.qq.com/s?__biz=MzA5OTAyNzQ2OA==&mid=2649703426&idx=1&sn=22be252aac597745cf832df987b324cf&chksm=88937b61bfe4f277d4744f2205a4f1fbdc7ff928e386c5aa728d8e0baccb202f44ef502a78a9&mpshare=1&scene=1&srcid=&sharer_sharetime=1572233974491&sharer_shareid=13fe4d560ad7f178a70a6b90efad8011#rd

    五、Mesh

    mesh与exchange的最大区别在于,exchange会完全替换原有的应用实例。mesh命令创建代理容器,但是会保留原应用容器,代理容器会动态生成version标签,以便用于可以通过Istio流量规则将特定的流量转发到本地,同时保证环境正常链路始终可用。在这种场景下,在确保开发测试环境稳定的同时,基于Istio的流量规则,我们可以把部分流量转到本地,从而实现在共享的开发测试环境中的联调能力。

    六、仪表盘部署

    参考:https://alibaba.github.io/kt-connect/#/guide/dashboard

    参考:

    https://blog.csdn.net/luanpeng825485697/article/details/102775981

    https://rdc-incubator.github.io/kt-docs/#/zh-cn/downloads

    https://github.com/alibaba/kt-connect

     

  • 相关阅读:
    [刷题] PTA 7-32 说反话-加强版
    [算法] 堆
    [笔记] 《c++ primer》显示器程序 Chapter7
    [笔记] 《c++ primer》书店程序 Chapter7
    [c++] <vector>
    [笔记] 《c++ primer》书店程序 Chapter2
    [笔记] 《c++ primer》书店程序 Chapter 1
    253. Meeting Rooms II
    461. Hamming Distance
    252. Meeting Rooms
  • 原文地址:https://www.cnblogs.com/sandshell/p/11757571.html
Copyright © 2020-2023  润新知