isenção de responsabilidade
Eu sei que esta não é a maneira como devemos trabalhar no cluster Kubernetes e que o que queremos fazer pode representar um risco de segurança
fundo
Um colega saiu de férias e esqueceu de documentar a senha root dos nós do nosso cluster Kubernetes. Agora preciso instalar um pacote simples nos nós (nfs-common) para poder montar um volume NFS.
Estou tentando chroot
instalar um pacote no sistema de arquivos do host montado.
Para fazer isso, criei o seguinte pod:
apiVersion: v1
kind: Pod
metadata:
name: ubuntu-pod
spec:
containers:
- name: ubuntu-container
image: ubuntu:24.04
command: ["/bin/bash", "-c", "while true; do sleep 30; done;"]
volumeMounts:
- name: host-root
mountPath: /hostfs
securityContext:
privileged: true
capabilities:
add:
- SYS_ADMIN
- SYS_RESOURCE
- SYS_NICE
- SYS_PTRACE
- SYS_BOOT
- SYS_MODULE
- SYS_RAWIO
- SYS_PACCT
- SYS_NICE
- SYS_TIME
- SYS_TTY_CONFIG
- SYSLOG
- NET_ADMIN
hostPID: true
volumes:
- name: host-root
hostPath:
path: /
restartPolicy: Never
Assim que o pod é iniciado, coloco um shell nele e chroot /hostfs /bin/bash
.
Entretanto, ele apt update && apt install -y nfs-common
falha com o seguinte erro:
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Ign:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Ign:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Ign:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Ign:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Err:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
29 packages can be upgraded. Run 'apt list --upgradable' to see them.
Acredito que me falta uma capacidade, mas não consigo descobrir qual é.
Parece um problema de DNS, não de recursos. Depois,
chroot /hostfs /bin/bash
tente isto:cp /etc/resolv.conf /hostfs/etc/resolv.conf
ATUALIZAÇÃO:
A solução acima interromperá a resolução de nomes no host. Em vez disso, você pode atualizar
/etc/resolv.conf
paranameserver 127.0.0.1
um servidor DNS público.