I have a Init container in my kubernetes deployment file, I see that init containers are not able to verify the availability of services present in different namespaces using helm. below ns1 is a namespace
initContainers:
- name: init-service1 #here I cannot give init-service1.<namespace> as (.) is not allowd
image: busybox
command: ['sh', '-c', 'until nslookup service1.<namespace>; do echo waiting for service1.<namespace>; sleep 10; done;']
I tried the same with same namespace and it works perfectly fine with helm
Secondly the name of initcontainer should match the name of services I am looking up??
another problem is helm I cannot give the name as init-service1. as (.) is not allowed.
Any help is highly appreciayed
Since you are working with multiples namespaces, you need to use a FQDN for reach your services:
When you create a Service, it creates a corresponding DNS entry. This entry is of the form
<service-name>.<namespace-name>.svc.cluster.local
, which means that if a container just uses<service-name>
it will resolve to the service which is local to a namespace. This is useful for using the same configuration across multiple namespaces such as Development, Staging and Production. If you want to reach across namespaces, you need to use the fully qualified domain name (FQDN)
In your case: service1.svc.myapp.svc.cluster.local
Secondly the name of initontainer should match the name of services I am looking up??
No. The initContainer
name doesn't matter in this field, you could use what you want.
In your case it should work:
initContainers:
- name: my-init
image: busybox:1.28
command: ['sh', '-c', 'until nslookup service1.svc.myapp.svc.cluster.local; do echo waiting for service1.svc.myapp.svc.cluster.local; sleep 10; done;']
References: