Skip to content

Instantly share code, notes, and snippets.

@felipelima94
Created December 6, 2022 14:55
Show Gist options
  • Save felipelima94/85b8c45a1a23ad08d4a1900921b9a084 to your computer and use it in GitHub Desktop.
Save felipelima94/85b8c45a1a23ad08d4a1900921b9a084 to your computer and use it in GitHub Desktop.
Criar pod temporario dentro do kubernetes
kubectl run [pod-name] -i --tty -n [namespace] --image [image] --image-pull-policy='IfNotPresent' --restart='Never' --rm -- [commands]
kubectl run "$USER-ubuntu" -i --tty -n [namespace] --image=ubuntu:latest --image-pull-policy='IfNotPresent' --restart='Never' --rm -- bash -c 'apt update;/bin/bash'

Comando para criar pod $USER-ubuntu pega o nome de usuário do seu sistema e concatena com ubuntu

run "$USER-ubuntu"

--tty exibe o nome do usuário do sistema (container)

root@ubuntu:/#

--rm flag para apagar do kubernetes apos finalizar

--rm -- [commands]

os comandos seguintes são executados na inicialização

então um update seguido da execução do bash para entrar no terminal.

--rm -- bash -c 'apt update;/bin/bash'

OBS: Lembrem-se de sempre especificar a namespace

@WillianTomaz
Copy link

Very Good my Friend 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment