forked from jaimesouza/k8s-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae2408d
commit a8d8162
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# atualiza o sistema | ||
sudo apt update | ||
sudo apt upgrade -y | ||
|
||
# adiciona o repositorio do Kubernetes para o Ubuntu 20.04 | ||
sudo apt update | ||
sudo apt -y install curl apt-transport-https | ||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - | ||
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list | ||
|
||
# instala kubelet, kubeadm e kubectl e outros pacotes | ||
sudo apt update | ||
sudo apt -y install vim git curl wget kubelet kubeadm kubectl | ||
sudo apt-mark hold kubelet kubeadm kubectl | ||
|
||
# confirma a instalacao, verificando a versao do kubectl e kubeadm | ||
kubectl version --client && kubeadm version | ||
|
||
# desabilita o swap | ||
sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab | ||
sudo swapoff -a | ||
|
||
# configura sysctl | ||
sudo modprobe overlay | ||
sudo modprobe br_netfilter | ||
|
||
cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf | ||
net.bridge.bridge-nf-call-ip6tables = 1 | ||
net.bridge.bridge-nf-call-iptables = 1 | ||
EOF | ||
|
||
sudo sysctl --system | ||
|
||
# instala o docker | ||
bash install-docker.sh | ||
|
||
# certifica que o modeulo br_netfilter esta carregado | ||
lsmod | grep br_netfilter | ||
|
||
# habilita o servico kubelet | ||
sudo systemctl start kubelet | ||
sudo systemctl enable kubelet | ||
|
||
# Pull container images | ||
sudo kubeadm config images pull | ||
|
||
# inicia o cluster kubernetes | ||
# rede 10.244.0.0/16 padrao do flannel | ||
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 | ||
|
||
# configura o kubectl usando os comandos do outup | ||
mkdir -p $HOME/.kube | ||
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | ||
sudo chown $(id -u):$(id -g) $HOME/.kube/config | ||
|
||
# verifica o status do cluster | ||
kubectl cluster-info | ||
|
||
# instala o plugin flannel para gerenciar a rede de overlay no Kubernetes | ||
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml | ||
|
||
# verifica os pods core do kubernets | ||
kubectl get pods --all-namespaces | ||
|
||
# verifica se o no master esta pronto | ||
kubectl get nodes -o wide | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# atualiza a lista de repositorios | ||
sudo apt-get update | ||
|
||
# instala pacotes extras para o APT utilizar repositorios HTTPS | ||
sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent gnupg2 software-properties-common | ||
|
||
#bBaixa e adiciona a chave publica do docker no sistema | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | ||
sudo apt-key fingerprint 0EBFCD88 | ||
|
||
# adiciona o repositorio que contem os pacotes para a instalacao do docker | ||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | ||
|
||
# instala os pacotes docker | ||
sudo apt update | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io | ||
|
||
# adiciona o usuario ubuntu ao grupo docker | ||
sudo usermod -aG docker $USER | ||
|
||
# cria diretorios necessarios para configurar o docker com systemd | ||
sudo mkdir -p /etc/systemd/system/docker.service.d | ||
|
||
# cria arquivo de configuracao daemon.json | ||
cat <<EOF | sudo tee /etc/docker/daemon.json | ||
{ | ||
"exec-opts": ["native.cgroupdriver=systemd"], | ||
"log-driver": "json-file", | ||
"log-opts": { | ||
"max-size": "100m" | ||
}, | ||
"storage-driver": "overlay2" | ||
} | ||
EOF | ||
|
||
# inicia e habilita os servicos | ||
sudo systemctl daemon-reload | ||
sudo systemctl restart docker | ||
sudo systemctl enable docker | ||
|
||
# Executa um teste de instalacao | ||
sudo docker run hello-world | ||
|