Friends,
I am learning here and trying to run a pod with an init container which checks if the DNS of the service of my mysql pod resolves. Both pods are being deployed with helm (Version:v3.4.1) charts created by me in minikube (version: v1.15.0).
The problem is that the init container tries for about five minutes until it finally resolves the DNS. It always works after 4 to 5 minutes but never before that, no matter for how long the mysql pod is running and the mysql service exists. Does anyone know how this is happening?
One interesting thing is that if I pass the clusterIP instead of the the DNS, it resolves immediately and it also resolves immediately if I passe the full domain name like this: mysql.default.svc.cluster.local.
Here is the conde of my init container:
initContainers:
- name: {{ .Values.initContainers.name }}
image: {{ .Values.initContainers.image }}
command: ['sh', '-c', 'until nslookup mysql; do echo waiting for mysql; sleep 2; done;']
Here is the service of the mysql deployment:
apiVersion: v1
kind: Service
metadata:
name: mysql
labels:
app: mysql
spec:
ports:
- protocol: TCP
port: 3306
targetPort: 3306
selector:
app: mysql
type: ClusterIP
And the deployment of the mysql:
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql
spec:
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8.0
envFrom:
- configMapRef:
name: mysql
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-storage
mountPath: /var/lib/mysql
subPath: mysql
volumes:
- name: mysql-storage
persistentVolumeClaim:
claimName: pvc-mysql