我最近不得不移动运行 AWX-operator 的 K3 集群。我的节点的 IP 地址必须从 10.0.3.51、10.0.3.52、10.0.3.53 更改为 10.6.3.44、10.6.3.45、10.6.3.71。我在 awx-demo 部署中更新了 hostAlias:
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
但在我的自动化作业 Pod 上,/etc/hosts 文件仍然具有旧的 IP 地址。创建自动化作业 Pod 后,我该如何更正 /etc/hosts?
我可以像这样进入自动化容器并显示 /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$
如果我编辑 Pod,我会看到这个......
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 ...
10.0.3.51 到底是从哪里来的?
AWX 邮件列表中的某人提醒我,我需要使用 AWX Web UI 控制台来更新管理站 >> 组实例 >>“默认”并更新
hostAliases
其中的定义。来自文档:https://docs.ansible.com/automation-controller/latest/html/administration/containers_instance_groups.html#customize-the-pod-spec