欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

使用Istio進(jìn)行多集群部署管理及單控制平面Gateway連接拓?fù)涞氖纠治?/h1>

本篇文章給大家分享的是有關(guān)使用 Istio 進(jìn)行多集群部署管理及單控制平面Gateway連接拓?fù)涞氖纠治?,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

專注于為中小企業(yè)提供成都網(wǎng)站制作、做網(wǎng)站服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)湛河免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

單控制平面拓?fù)湎?,多個 Kubernetes 集群共同使用在其中一個集群上運(yùn)行的單個 Istio 控制平面。控制平面的 Pilot 管理本地和遠(yuǎn)程集群上的服務(wù),并為所有集群配置 Envoy Sidecar 代理。

集群感知的服務(wù)路由

Istio 1.1 中引入了集群感知的服務(wù)路由能力,在單一控制平面拓?fù)渑渲孟?,使?nbsp;Istio 的 Split-horizon EDS(水平分割端點(diǎn)發(fā)現(xiàn)服務(wù))功能可以通過其入口網(wǎng)關(guān)將服務(wù)請求路由到其他集群?;谡埱笤吹奈恢茫琁stio 能夠?qū)⒄埱舐酚傻讲煌亩它c(diǎn)。

在該配置中,從一個集群中的 Sidecar 代理到同一集群中的服務(wù)的請求仍然被轉(zhuǎn)發(fā)到本地服務(wù) IP。如果目標(biāo)工作負(fù)載在其他集群中運(yùn)行,則使用遠(yuǎn)程集群的網(wǎng)關(guān) IP 來連接到該服務(wù)。

使用 Istio 進(jìn)行多集群部署管理及單控制平面Gateway連接拓?fù)涞氖纠治?> (集群感知的服務(wù)路由)</p><p>如圖所示,主集群 cluster1 運(yùn)行全套的 Istio 控制平面組件,同時集群 cluster2 僅運(yùn)行 Istio Citadel、Sidecar Injector 和 Ingress 網(wǎng)關(guān)。不需要 VPN 連接,不同集群中的工作負(fù)載之間也不需要直接網(wǎng)絡(luò)訪問。</p><p>從共享的根 CA 為每個集群的 Citadel 生成中間 CA 證書,共享的根 CA 啟用跨不同集群的雙向 TLS 通信。為了便于說明,我們將 samples/certs 目錄下 Istio 安裝中提供的示例根 CA 證書用于兩個集群。在實(shí)際部署中,你可能會為每個集群使用不同的 CA 證書,所有 CA 證書都由公共根 CA 簽名。</p><p>在每個 Kubernetes 集群中(包括示例中的集群 cluster1 與 cluster2)使用以下命令為生成的 CA 證書創(chuàng)建 Kubernetes 密鑰:</p><pre>kubectl
create namespace istio-system
kubectl
create secret generic cacerts -n istio-system \
  --from-file=samples/certs/ca-cert.pem \
  --from-file=samples/certs/ca-key.pem \
  --from-file=samples/certs/root-cert.pem \
  --from-file=samples/certs/cert-chain.pem</pre><h3>Istio 控制平面組件</h3><p>在部署全套 Istio 控制平面組件的集群 cluster1 中,按照以下步驟執(zhí)行:</p><p><strong>1.安裝 Istio 的 CRD 并等待幾秒鐘,以便將它們提交給 Kubernetes API <a title=服務(wù)器,如下所示:

for
i in install/kubernetes/helm/istio-init/files/crd*yaml; do kubectl apply -f $i;
done

2.然后開始在集群 cluster1 中部署 Istio 控制平面。

如果 helm 依賴項缺失或者不是最新的,可以通過 helm dep update 來更新這些依賴項。需要注意的是,因?yàn)闆]有使用 istio-cni,可以暫時將其從依賴項 requirements.yaml 中去掉再執(zhí)行更新操作。具體命令如下所示:

helm
template --name=istio --namespace=istio-system \
--set
global.mtls.enabled=true \
--set
security.selfSigned=false \
--set
global.controlPlaneSecurityEnabled=true \
--set
global.meshExpansion.enabled=true \
--set
global.meshNetworks.network2.endpoints[0].fromRegistry=n2-k8s-config \
--set
global.meshNetworks.network2.gateways[0].address=0.0.0.0 \
--set
global.meshNetworks.network2.gateways[0].port=15443 \
install/kubernetes/helm/istio
> ./istio-auth.yaml

請注意,網(wǎng)關(guān)地址設(shè)置為 0.0.0.0。這是一個臨時占位符值,在集群 cluster2 部署之后將更新為其網(wǎng)關(guān)的公共 IP 值。

將 Istio 部署到 cluster1,如下所示:

kubectl
apply -f ./istio-auth.yaml

確保上述步驟在 Kubernetes 集群中執(zhí)行成功。

3. 創(chuàng)建網(wǎng)關(guān)以訪問遠(yuǎn)程服務(wù),如下所示:

kubectl
create -f - <<EOF
apiVersion:
networking.istio.io/v1alpha3
kind:
Gateway
metadata:
  name: cluster-aware-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 15443
      name: tls
      protocol: TLS
    tls:
      mode: AUTO_PASSTHROUGH
    hosts:
    - "*"
EOF

上述網(wǎng)關(guān)配置了一個專用端口 15443 用來將傳入流量傳遞到請求的 SNI 標(biāo)頭中指定的目標(biāo)服務(wù),從源服務(wù)到目標(biāo)服務(wù)一直使用雙向 TLS 連接。

請注意雖然該網(wǎng)關(guān)定義應(yīng)用于集群 cluster1,但因?yàn)閮蓚€集群都與同一個 Pilot 進(jìn)行通信,此網(wǎng)關(guān)實(shí)例同樣也適用于集群 cluster2。

istio-remote 組件

在另一集群 cluster2 中部署 istio-remote 組件,按照以下步驟執(zhí)行:

1.首先獲取集群 cluster1 的入口網(wǎng)關(guān)地址,如下所示:

export
LOCAL_GW_ADDR=$(kubectl get svc --selector=app=istio-ingressgateway \
  -n istio-system -o
jsonpath="{.items[0].status.loadBalancer.ingress[0].ip}")

通過執(zhí)行以下命令,使用 Helm 創(chuàng)建 Istio remote 部署 YAML 文件:

helm
template --name istio-remote --namespace=istio-system \
--values
install/kubernetes/helm/istio/values-istio-remote.yaml \
--set
global.mtls.enabled=true \
--set
gateways.enabled=true \
--set
security.selfSigned=false \
--set
global.controlPlaneSecurityEnabled=true \
--set
global.createRemoteSvcEndpoints=true \
--set
global.remotePilotCreateSvcEndpoint=true \
--set
global.remotePilotAddress=${LOCAL_GW_ADDR} \
--set
global.remotePolicyAddress=${LOCAL_GW_ADDR} \
--set
global.remoteTelemetryAddress=${LOCAL_GW_ADDR} \
--set
gateways.istio-ingressgateway.env.ISTIO_META_NETWORK="network2" \
--set
global.network="network2" \
install/kubernetes/helm/istio
> istio-remote-auth.yaml

2. 將 Istio remote 組件部署到 cluster2,如下所示:

kubectl
apply -f ./istio-remote-auth.yaml

確保上述步驟在 Kubernetes 集群中執(zhí)行成功。

3.更新集群 cluster1 的配置項 istio,獲取集群 cluster2 的入口網(wǎng)關(guān)地址,如下所示:

export
REMOTE_GW_ADDR=$(kubectl get --context=$CTX_REMOTE svc --selector=app=
istio-ingressgateway
-n istio-system -o jsonpath="{.items[0].status.loadBalancer.ingress
[0].ip}")

在集群 cluster1 中編輯命名空間 istio-system 下的配置項 istio,替換 network2 的網(wǎng)關(guān)地址,從 0.0.0.0 變成集群 cluster2 的入口網(wǎng)關(guān)地址 ${REMOTE_GW_ADDR}。保存后,Pilot 將自動讀取更新的網(wǎng)絡(luò)配置。

4.創(chuàng)建集群 cluster2 的 Kubeconfig。通過以下命令,在集群 cluster2 上創(chuàng)建服務(wù)賬號 istio-multi 的 Kubeconfig,并保存為文件 n2-k8s-config:

CLUSTER_NAME="cluster2"
SERVER=$(kubectl
config view --minify=true -o "jsonpath={.clusters[].cluster.server}")
SECRET_NAME=$(kubectl
get sa istio-multi -n istio-system -o jsonpath='{.secrets[].name}')
CA_DATA=$(kubectl
get secret ${SECRET_NAME} -n istio-system -o
"jsonpath={.data['ca\.crt']}")
TOKEN=$(kubectl
get secret ${SECRET_NAME} -n istio-system -o
"jsonpath={.data['token']}" | base64 --decode)
cat
<<EOF > n2-k8s-config
apiVersion:
v1
kind:
Config
clusters:
  - cluster:
      certificate-authority-data: ${CA_DATA}
      server: ${SERVER}
    name: ${CLUSTER_NAME}
contexts:
  - context:
      cluster: ${CLUSTER_NAME}
      user: ${CLUSTER_NAME}
    name: ${CLUSTER_NAME}
current-context:
${CLUSTER_NAME}
users:
  - name: ${CLUSTER_NAME}
    user:
      token: ${TOKEN}
EOF

5.將集群 cluster2 加入到 Istio 控制平面。

在集群 clusterl 執(zhí)行以下命令,將上述生成的集群 cluster2 的 kubeconfig 添加到集群 cluster1 的 secret 中,執(zhí)行這些命令后,集群 cluster1 中的 Istio Pilot 將開始監(jiān)聽集群 cluster2 的服務(wù)和實(shí)例,就像監(jiān)聽集群 cluster1 中的服務(wù)與實(shí)例一樣:

kubectl
create secret generic n2-k8s-secret --from-file n2-k8s-config -n istio-system
kubectl
label secret n2-k8s-secret istio/multiCluster=true -n istio-system

部署示例應(yīng)用

為了演示跨集群訪問,在第一個 Kubernetes 集群 cluster1 中部署 sleep 應(yīng)用服務(wù)和版本 v1 的 helloworld 服務(wù),在第二個集群 cluster2 中部署版本 v2 的 helloworld 服務(wù),然后驗(yàn)證 sleep 應(yīng)用是否可以調(diào)用本地或者遠(yuǎn)程集群的 helloworld 服務(wù)。

1.部署 sleep 和版本 v1 的 helloworld 服務(wù)到第一個集群 cluster1 中,執(zhí)行如下命令:

kubectl
create namespace app1
kubectl
label namespace app1 istio-injection=enabled
kubectl
apply -n app1 -f samples/sleep/sleep.yaml
kubectl
apply -n app1 -f samples/helloworld/service.yaml
kubectl
apply -n app1 -f samples/helloworld/helloworld.yaml -l version=v1
export
SLEEP_POD=$(kubectl get -n app1 pod -l app=sleep -o
jsonpath={.items..metadata.name})

2.部署版本 v2 的 helloworld 服務(wù)到第二個集群 cluster2 中,執(zhí)行如下命令:

kubectl
create namespace app1
kubectl
label namespace app1 istio-injection=enabled
kubectl
apply -n app1 -f samples/helloworld/service.yaml
kubectl
apply -n app1 -f samples/helloworld/helloworld.yaml -l version=v2

3.登錄到命名空間 istio-system 下的 istio-pilot 容器中,運(yùn)行 curl localhost:8080/v1/registration | grep helloworld -A 11 -B 2 命令,如果得到如下類似的結(jié)果就說明版本 v1 與 v2 的 helloworld 服務(wù)都已經(jīng)注冊到 Istio 控制平面中了:

使用 Istio 進(jìn)行多集群部署管理及單控制平面Gateway連接拓?fù)涞氖纠治?></p><p><strong>4.驗(yàn)證在集群 cluster1 中的 sleep 服務(wù)是否可以正常調(diào)用本地或者遠(yuǎn)程集群的 helloworld 服務(wù),在集群 cluster1 下執(zhí)行如下命令:</strong></p><pre>kubectl
exec -it -n app1 $SLEEP_POD sh</pre><p><img src=使用Istio進(jìn)行多集群部署管理及單控制平面Gateway連接拓?fù)涞氖纠治?/a>
轉(zhuǎn)載來于:http://chinadenli.net/article4/jiijoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司、響應(yīng)式網(wǎng)站靜態(tài)網(wǎng)站、網(wǎng)站排名、網(wǎng)站維護(hù)移動網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司