Skip to content

Instantly share code, notes, and snippets.

@pablotdv
Last active September 21, 2022 13:10
Show Gist options
  • Save pablotdv/0b3b3a2b8d0b60bde5f875b7d24a5b73 to your computer and use it in GitHub Desktop.
Save pablotdv/0b3b3a2b8d0b60bde5f875b7d24a5b73 to your computer and use it in GitHub Desktop.
Configurando um cluster K8S no WSL2

Instalando o Docker Engine no WSL 2

sudo apt-get update

sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

sudo usermod -aG docker $USER

no final do arquivo .profile adicionar

export DOCKER_BUILDKIT=1

fonte: https://docs.docker.com/engine/install/ubuntu/

auto iniciar o serviço no docker

adicione no /etc/wsl.conf

[boot]
command="service docker start"

Instalando o docker compose no WSL2

sudo apt-get update
 
sudo apt-get install docker-compose-plugin

fonte: https://docs.docker.com/compose/install/compose-plugin/

Instalando o MiniKube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64

sudo install minikube-linux-amd64 /usr/local/bin/minikube

minikube start --vm-driver=docker

minikube addons enable ingress

fonte: https://minikube.sigs.k8s.io/docs/start/

Instalando o kubectl

curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

fonte: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

criando e rodando a imagem com docker

docker build -f DojoK8S/Dockerfile . -t dojok8s 

docker run -d -p 8080:80 dojok8s

subindo uma imagem para o minikube

minikube image build -f DojoK8S/Dockerfile . -t dojok8s:2.0.0

instalando o dotnet (opcional)

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb

sudo dpkg -i packages-microsoft-prod.deb

rm packages-microsoft-prod.deb

sudo apt-get update
  
sudo apt-get install -y dotnet-sdk-6.0

OBS: o dotnet só é necessário para desenvolver um exemplo a ser usado para subir no k8s. Logo esse passo não se faz necessário para o resto da instalação.

fonte: https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu

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