Closed lemonit-eric-mao closed 3 years ago
I got the same issue as above, too. [root@consul-dc1-master consul_test]# kubectl exec deploy/static-client -c static-client -- curl -sS http://static-server curl: (6) Could not resolve host: static-server command terminated with exit code 6
And I have set the consul in the k8s cluster as the official documents said as below:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/consul-connect-injector-svc ClusterIP 10.108.255.227
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/consul 3 3 3 3 3
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/consul-connect-injector-webhook-deployment 1/1 1 1 38d deployment.apps/consul-controller 1/1 1 1 38d deployment.apps/consul-mesh-gateway 2/2 2 2 38d deployment.apps/consul-webhook-cert-manager 1/1 1 1 38d deployment.apps/static-client 1/1 1 1 76m
NAME DESIRED CURRENT READY AGE replicaset.apps/consul-connect-injector-webhook-deployment-54f5796745 1 1 1 38d replicaset.apps/consul-controller-565f495b94 1 1 1 38d replicaset.apps/consul-mesh-gateway-5fb7dd646f 2 2 2 38d replicaset.apps/consul-webhook-cert-manager-5745cbb9d 1 1 1 38d replicaset.apps/static-client-7546c78c97 1 1 1 51m
NAME READY AGE statefulset.apps/consul-server 3/3 38d
[root@consul-dc1-master consul_test]# kubectl exec statefulset/consul-server -- consul members -wan
Node Address Status Type Build Protocol DC Segment
consul-server-0.dc1 172.0.0.212:8302 alive server 1.9.4 2 dc1
[root@consul-dc1-master consul_test]# kubectl exec statefulset/consul-server -- consul catalog services -datacenter dc1 consul mesh-gateway static-client static-client-sidecar-proxy [root@consul-dc1-master consul_test]# kubectl exec statefulset/consul-server -- consul catalog services -datacenter dc2 consul mesh-gateway static-server static-server-sidecar-proxy [root@consul-dc1-master consul_test]# kubectl exec statefulset/consul-server -- consul catalog services -datacenter dc3 consul demo-four mesh-gateway
[root@consul-dc1-master consul_test]# kubectl get ServiceIntentions NAME SYNCED LAST SYNCED AGE static-client-to-static-server True 70m 70m
The Secondary Cluster DC2: [root@consul-dc2-master consul_test]# kubectl get all NAME READY STATUS RESTARTS AGE pod/consul-connect-injector-webhook-deployment-b8bbbcfcc-prbtr 1/1 Running 3 20h pod/consul-controller-d5cd45947-v5h86 1/1 Running 0 20h pod/consul-d6f5q 1/1 Running 0 20h pod/consul-jns6b 1/1 Running 0 20h pod/consul-mesh-gateway-78df87f45c-6r5gf 2/2 Running 0 91m pod/consul-server-0 1/1 Running 0 20h pod/consul-server-1 1/1 Running 0 20h pod/consul-server-2 1/1 Running 0 20h pod/consul-wdbz2 1/1 Running 0 20h pod/consul-webhook-cert-manager-5745cbb9d-t5qwc 1/1 Running 0 20h pod/static-server-b4c7ff6fc-6zcq4 3/3 Running 0 22m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/consul-connect-injector-svc ClusterIP 10.101.32.14
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/consul 3 3 3 3 3
NAME READY UP-TO-DATE AVAILABLE AGE deployment.apps/consul-connect-injector-webhook-deployment 1/1 1 1 20h deployment.apps/consul-controller 1/1 1 1 20h deployment.apps/consul-mesh-gateway 1/1 1 1 20h deployment.apps/consul-webhook-cert-manager 1/1 1 1 20h deployment.apps/static-server 1/1 1 1 75m
NAME DESIRED CURRENT READY AGE replicaset.apps/consul-connect-injector-webhook-deployment-b8bbbcfcc 1 1 1 20h replicaset.apps/consul-controller-d5cd45947 1 1 1 20h replicaset.apps/consul-mesh-gateway-78df87f45c 1 1 1 20h replicaset.apps/consul-webhook-cert-manager-5745cbb9d 1 1 1 20h replicaset.apps/static-server-b4c7ff6fc 1 1 1 22m
NAME READY AGE statefulset.apps/consul-server 3/3 20h
[root@consul-dc2-master consul_test]# kubectl exec statefulset/consul-server -- consul members -wan
Node Address Status Type Build Protocol DC Segment
consul-server-0.dc1 172.0.0.212:8302 alive server 1.9.4 2 dc1
[root@consul-dc2-master consul_test]# kubectl exec statefulset/consul-server -- consul catalog services -datacenter dc1 consul mesh-gateway static-client static-client-sidecar-proxy [root@consul-dc2-master consul_test]# kubectl exec statefulset/consul-server -- consul catalog services -datacenter dc2 consul mesh-gateway static-server static-server-sidecar-proxy [root@consul-dc2-master consul_test]# kubectl exec statefulset/consul-server -- consul catalog services -datacenter dc3 consul demo-four mesh-gateway
[root@consul-dc1-master consul_test]# kubectl get ServiceIntentions NAME SYNCED LAST SYNCED AGE static-client-to-static-server True 172m 172m
I also set the upstream from the static-client to the static-server, it still not work.
@lemonit-eric-mao Could you post your YAML for static-client and static-server? Also could you point us to where you got the examples? I assume we would need to update Learn guides or docs to reflect changes we made in Consul 1.10 so that you no longer need to point your apps to localhost to hit the Envoy proxy directly. See https://www.consul.io/docs/connect/transparent-proxy#enabling-transparent-proxy for a better example for static-server and static-client on Consul 1.10.
@ZEROYXY it looks like you are not on Consul 1.10 is that correct?
@david-yu Hello, I refer to the following official website for deployment https://learn.hashicorp.com/tutorials/consul/kubernetes-mesh-gateways?in=consul/kubernetes https://www.consul.io/docs/k8s/installation/multi-cluster/kubernetes https://learn.hashicorp.com/tutorials/consul/kubernetes-mesh-gateways https://learn.hashicorp.com/tutorials/consul/kubernetes-mesh-gateways#deploy-microservices https://github.com/hashicorp/consul/blob/v1.10.0/website/content/docs/k8s/installation/multi-cluster/kubernetes.mdx#primary-datacenter
I installed consumer 1.10 directly, not upgraded from the old version. Do I need this document? https://www.consul.io/docs/connect/transparent-proxy#enabling-transparent-proxy https://github.com/hashicorp/consul/blob/v1.10.0/website/content/docs/k8s/helm.mdx
global:
name: consul
datacenter: dc1
# TLS configures whether Consul components use TLS.
tls:
# TLS must be enabled for federation in Kubernetes.
enabled: true
federation:
enabled: true
# This will cause a Kubernetes secret to be created that
# can be imported by secondary datacenters to configure them
# for federation.
createFederationSecret: true
acls:
manageSystemACLs: true
# If ACLs are enabled, we must create a token for secondary
# datacenters to replicate ACLs.
createReplicationToken: true
# Gossip encryption secures the protocol Consul uses to quickly
# discover new nodes and detect failure.
gossipEncryption:
secretName: consul-gossip-encryption-key
secretKey: key
connectInject:
enabled: true
transparentProxy:
defaultEnabled: true
controller:
enabled: true
meshGateway:
# Mesh gateways are gateways between datacenters. They must be enabled
# for federation in Kubernetes since the communication between datacenters
# goes through the mesh gateways.
enabled: true
helm install -f dc1-values.yaml consul hashicorp/consul -n dhc-consul --version "0.32.0" --wait
DC1
apiVersion: consul.hashicorp.com/v1alpha1
kind: ProxyDefaults
metadata:
name: global
spec:
meshGateway:
mode: 'local'
global:
name: consul
datacenter: dc2
tls:
enabled: true
# Here we're using the shared certificate authority from the primary
# datacenter that was exported via the federation secret.
caCert:
secretName: consul-federation
secretKey: caCert
caKey:
secretName: consul-federation
secretKey: caKey
acls:
manageSystemACLs: true
# Here we're importing the replication token that was
# exported from the primary via the federation secret.
replicationToken:
secretName: consul-federation
secretKey: replicationToken
federation:
enabled: true
gossipEncryption:
secretName: consul-federation
secretKey: gossipEncryptionKey
connectInject:
enabled: true
transparentProxy:
defaultEnabled: true
controller:
enabled: true
meshGateway:
enabled: true
server:
# Here we're including the server config exported from the primary
# via the federation secret. This config includes the addresses of
# the primary datacenter's mesh gateways so Consul can begin federation.
extraVolumes:
- type: secret
name: consul-federation
items:
- key: serverConfigJSON
path: config.json
load: true
helm install -f dc2-values.yaml consul hashicorp/consul -n dhc-consul --version "0.32.0" --wait
DC1
apiVersion: v1
kind: ServiceAccount
metadata:
name: static-client
---
apiVersion: v1
kind: Service
metadata:
name: static-client
spec:
selector:
app: static-client
ports:
- port: 4321
targetPort: 4321
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: static-client
name: static-client
spec:
replicas: 1
selector:
matchLabels:
app: static-client
template:
metadata:
annotations:
consul.hashicorp.com/connect-inject: 'true'
labels:
app: static-client
spec:
containers:
- name: static-client
image: curlimages/curl:7.77.0
ports:
- containerPort: 4321
command: ['/bin/sh', '-c', '--']
args: ['while true; do sleep 30; done;']
serviceAccountName: static-client
DC2
apiVersion: v1
kind: Service
metadata:
name: static-server
spec:
selector:
app: static-server
ports:
- protocol: TCP
port: 80
targetPort: 8080
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: static-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: static-server
spec:
replicas: 1
selector:
matchLabels:
app: static-server
template:
metadata:
name: static-server
labels:
app: static-server
annotations:
'consul.hashicorp.com/connect-inject': 'true'
'consul.hashicorp.com/transparent-proxy': 'true'
spec:
containers:
- name: static-server
image: hashicorp/http-echo:latest
args:
- -text="hello world"
- -listen=:8080
ports:
- containerPort: 8080
name: http
serviceAccountName: static-server
apiVersion: v1
data:
caCert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURRakNDQXVpZ0F3SUJBZ0lVVDhiejdYcXUxWWZtUmVXbTlZM1p2aTBSZ1pVd0NnWUlLb1pJemowRUF3SXcKZ1pFeEN6QUpCZ05WQkFZVEFsVlRNUXN3Q1FZRFZRUUlFd0pEUVRFV01CUUdBMVVFQnhNTlUyRnVJRVp5WVc1agphWE5qYnpFYU1CZ0dBMVVFQ1JNUk1UQXhJRk5sWTI5dVpDQlRkSEpsWlhReERqQU1CZ05WQkJFVEJUazBNVEExCk1SY3dGUVlEVlFRS0V3NUlZWE5vYVVOdmNuQWdTVzVqTGpFWU1CWUdBMVVFQXhNUFEyOXVjM1ZzSUVGblpXNTAKSUVOQk1CNFhEVEl4TURjd09EQTJNVGMxTmxvWERUTXhNRGN3TmpBMk1UZzFObG93Z1pFeEN6QUpCZ05WQkFZVApBbFZUTVFzd0NRWURWUVFJRXdKRFFURVdNQlFHQTFVRUJ4TU5VMkZ1SUVaeVlXNWphWE5qYnpFYU1CZ0dBMVVFCkNSTVJNVEF4SUZObFkyOXVaQ0JUZEhKbFpYUXhEakFNQmdOVkJCRVRCVGswTVRBMU1SY3dGUVlEVlFRS0V3NUkKWVhOb2FVTnZjbkFnU1c1akxqRVlNQllHQTFVRUF4TVBRMjl1YzNWc0lFRm5aVzUwSUVOQk1Ga3dFd1lIS29aSQp6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S25Ebmk5U2IzUTBxU1VWOGJpMApiVlpsT0tGK25PTzR1M0pQRUZrSXVYZ25nUjhTbHBlYndRPT0KLS0tLS1FTkQgRUMgUFJJVkFURSBLRVktLS0tLQo=
gossipEncryptionKey: MndNTFJzMS8yT1RZdzdTeGxNODFXUEljVlI2ay9KM2VVcDFCVG1nY3RGcz0=
replicationToken: YmQ2NDA4MmEtZjlhMy0yZDg0LTZlOWMtNTUxMDZhOWUzY2Ni
serverConfigJSON: eyJwcmltYXJ5X2RhdGFjZW50ZXIiOiJkYzEiLCJwcmltYXJ5X2dhdGV3YXlzIjpbIjE5Mi4xNjguMTAzLjI1Mzo0NDMiXX0=
kind: Secret
metadata:
creationTimestamp: "2021-07-08T06:20:44Z"
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:data:
.: {}
f:caCert: {}
f:caKey: {}
f:gossipEncryptionKey: {}
f:replicationToken: {}
f:serverConfigJSON: {}
f:type: {}
manager: consul-k8s
operation: Update
time: "2021-07-08T06:20:44Z"
name: consul-federation
namespace: dhc-consul
resourceVersion: "5166737"
uid: 6c58196f-b795-4a75-86d9-2843a120f1f7
type: Opaque
@david-yu Hi David
Firstly thank you so much for your kindly and quickly response on this. And it is currect that the version of Consul I used is 1.9.4.
The example which I used is as below:
I followed the guide as below to build the Consul Mesh-Gateway Federation. https://www.consul.io/docs/k8s/installation/multi-cluster/kubernetes
Then I followed the guide as below to deploy two services in two K8s clusters and tried to test if the services in different K8s clusters and DCs can communicate with each other. And the issue as above I am facing happened here. https://learn.hashicorp.com/tutorials/consul/kubernetes-mesh-gateways?in=consul/kubernetes
I tried to sync the services between consul and K8s as below guide said but found the issue as above is still there even the sync has been successful. https://www.consul.io/docs/k8s/service-sync
Transferring to Consul Helm.
@david-yu I have tried this article, but still did not solve my problem. I wonder if you can provide the yaml files of the main data center and the yaml files of the auxiliary data center separately.
Using kubectl to connect to the client and request data from the server
K8s environmental information
Reference deployment document
Primary Cluster DC1 information
static-client
Primary Cluster Consul CLI
Secondary Cluster DC2 information
static-server
Secondary Cluster Consul CLI
Test
Dear engineers, Hello, I did not have a successful visit according to the official documents. I hope I can get official help and guidance.
Chinese translation of documents