I recently had to move my K3 cluster running AWX-operator. The IP addresses of my nodes had to change from 10.0.3.51, 10.0.3.52, 10.0.3.53 to 10.6.3.44, 10.6.3.45, 10.6.3.71. I updated hostAlias in my awx-demo deployment:
271 dnsPolicy: ClusterFirst
272 hostAliases:
273 - hostnames:
274 - awx.example.com
275 ip: 10.6.3.44
276 initContainers:
277 - command:
278 - /bin/sh
279 - -c
280 - |
281 hostname=$MY_POD_NAME
282 receptor --cert-makereq bits=2048 commonname=$hostname dnsname=$hostname nodeid=$hostname outreq=/etc/receptor/tls/receptor.req outkey=/etc/receptor/tls/receptor.key
283 receptor --cert-signreq req=/etc/receptor/tls/receptor.req cacert=/etc/receptor/tls/ca/receptor-ca.crt cakey=/etc/receptor/tls/ca/receptor-ca.key outcert=/etc/receptor/tls/ receptor.crt verify=yes
But still on my automation-job pods the /etc/hosts file has the old IP address. What can I do to correct the /etc/hosts when my automation-job pods get created?
I can get on to the automation pod like so and show the /etc/hosts
$ kubectl -n awx exec -it automation-job-19120-2npln -- bash
bash-4.4$ cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
fe00::0 ip6-mcastprefix
fe00::1 ip6-allnodes
fe00::2 ip6-allrouters
10.42.1.31 automation-job-19120-2npln
# Entries added by HostAliases.
10.0.3.51 awx.example.com
bash-4.4$
If I edit the pod I see this ...
apiVersion: v1
kind: Pod
metadata:
... omitted ...
spec:
automountServiceAccountToken: false
containers:
- args:
- ansible-runner
- worker
- --private-data-dir=/runner
image: quay.io/ansible/awx-ee:latest
imagePullPolicy: Always
name: worker
resources:
requests:
cpu: 250m
memory: 100Mi
stdin: true
stdinOnce: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
enableServiceLinks: true
hostAliases:
- hostnames:
- awx.example.com
ip: 10.0.3.51
nodeName: rocky-k3-3
... omitted ...
Where the heck is that 10.0.3.51 coming from?
Someone on the AWX mailing listed reminded me that I need to use the AWX Web UI console to update the Admininstation >> Group Instance >> 'default' and update the
hostAliases
defined there. From the docs: https://docs.ansible.com/automation-controller/latest/html/administration/containers_instance_groups.html#customize-the-pod-spec