Hi All,
Facing an issue with sidecar injection. It fails in the init container : consul-connect-inject-init step. Tried various debugging but not able to find the root cause.
Error is :
[ERROR] Timed out waiting for service registration: error="did not find correct number of services, found: 0, services: map[]"
Following are the connect injector logs:
{"level":"info","ts":1653060188.246912,"logger":"controller.endpoints","msg":"ignoring because endpoints pods have not been injected","name":"test","ns":"search"}
We get the below in the consul client logs:
[ERROR] agent.http: Request error: method=GET url=/v1/acl/token/self?stale= from=10.140.132.67:33496 error="ACL not found"
However if we run /v1/acl/token/self?stale= after exec into the init container of the failing pod, it succeeds and we get the below response:
{"AccessorID":"3574d53c-c932-7cf1-6dfc-cbab8bfdd832","SecretID":"88a61d4b-c5d9-7168-35d5-825b7ba45550","Description":"token created via login: {\"pod\":\"test\"}","ServiceIdentities":[{"ServiceName":"test"}],"Local":true,"AuthMethod":"consul-consul-k8s-auth-method","CreateTime":"2022-05-24T13:20:39.150970114Z","Hash":"ZV9+Kxykl3bcsYdVxFRMaUfmz534rfgSWs1rqsn4m3g4=","CreateIndex":718941,"ModifyIndex":718941}
Also can see the below annotation in the pod definition:
consul.hashicorp.com/connect-inject-status: injected
From the Consul UI can see that the ACL token is also created for the pod.
One weird thing is that the sidecar injection works sometimes but that too takes a good amount of time, approximately 5-10 minutes. But for most times it does not work. However once injected it works perfectly fine, with new deployments, pod recreation / restarts,etc. The issue is only with enabling sidecars for the first time.
Have added the below annotations to the pod definition:
{{- if $.Values.service_mesh.enabled }}
'consul.hashicorp.com/connect-service': "{{ $.Release.Name }}"
'consul.hashicorp.com/connect-inject': 'true'
'consul.hashicorp.com/transparent-proxy': 'false'
'consul.hashicorp.com/connect-service-upstreams': {{ $.Values.service_mesh.upstreams | quote }}
{{- end }}
Also the service account has the same name as the service name.
Versions:
Consul : consul:1.11.1
Envoy : envoy-alpine:v1.18.2
Helm Chart : consul-0.41.1
Any leads would be greatly appreciated!