Kubernetes: Instalação Online usando repositórios públicos: Difference between revisions

From Wiki
Line 25: Line 25:


  /etc/yum.repos.d/docker-ce.repo
  /etc/yum.repos.d/docker-ce.repo
== Configure Docker with the devicemapper storage driver ==
Parando o docker
systemctl stop docker
Criando o device mapper
pvcreate /dev/xvdf
vgcreate dockerVg /dev/xvdf
lvcreate --wipesignatures y -n thinpoolLv dockerVg -l 95%VG
lvcreate --wipesignatures y -n thinpoolmetaLv dockerVg -l 1%VG
lvconvert -y --zero n -c 512K --thinpool dockerVg/thinpoolLv --poolmetadata dockerVg/thinpoolmetaLv
Definir /etc/lvm/profile/dockerVg-thinpoolLv.profile
activation {
  thin_pool_autoextend_threshold=80
  thin_pool_autoextend_percent=20
}
lvchange --metadataprofile dockerVg-thinpoolmetaLv dockerVg/thinpoolLv
lvs -o+seg_monitor


== Configuração pós-instalação ==
== Configuração pós-instalação ==

Revision as of 14:33, 13 August 2019

Dica: Caso você não tenha acesso ao repositório na internet, veja o artigo Kubernetes: Instalação Offline ou Instalação usando repositórios privados

Docker

Instalando o Docker

1) Criar arquivo /etc/yum.repos.d/docker-ce.repo, com o conteúdo:

[docker-ce]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
#baseurl=http://repomirror.company.com/docker-mirror/linux/centos/7/$basearch/stable/
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
#gpgkey=http://repomirror.company.com/docker-mirror/linux/centos/gpg
 

2) Instalando os pacotes no CentOS

yum install -y docker-ce-18.06

3) Remover o arquivoo

/etc/yum.repos.d/docker-ce.repo

Configure Docker with the devicemapper storage driver

Parando o docker

systemctl stop docker

Criando o device mapper

pvcreate /dev/xvdf
vgcreate dockerVg /dev/xvdf
lvcreate --wipesignatures y -n thinpoolLv dockerVg -l 95%VG
lvcreate --wipesignatures y -n thinpoolmetaLv dockerVg -l 1%VG
lvconvert -y --zero n -c 512K --thinpool dockerVg/thinpoolLv --poolmetadata dockerVg/thinpoolmetaLv

Definir /etc/lvm/profile/dockerVg-thinpoolLv.profile

activation {
 thin_pool_autoextend_threshold=80
 thin_pool_autoextend_percent=20
}
lvchange --metadataprofile dockerVg-thinpoolmetaLv dockerVg/thinpoolLv
lvs -o+seg_monitor


Configuração pós-instalação

1) Tuning do SO

sysctl -a | grep may_detach_mounts

Se o valor for diferente de "fs.may_detach_mounts = 1", ajustar:

echo 1 > /proc/sys/fs/may_detach_mounts
echo fs.may_detach_mounts=1 > /usr/lib/sysctl.d/99-docker.conf

3) Editar o arquivo /etc/docker/daemon.json e configurar o devicemapper storage driver.

Importante: No meu caso precisava utilizar um repositório interno, então adicionei a variável insecure-registries.
mkdir -p /etc/docker
 
cat <<EOF >> /etc/docker/daemon.json
{
    "bip": "1.1.1.1/16",
    "insecure-registries": ["repomirror.company.com:5001"],
    "storage-driver": "devicemapper",
    "storage-opts": [
        "dm.thinpooldev=/dev/mapper/dockerVg-thinpoolLv",
        "dm.use_deferred_removal=true",
        "dm.use_deferred_deletion=true"
    ]
}
EOF
 

4) Start o Docker

systemctl start docker

5) Verificando as configurações

docker info

6) Se tudo estiver correto ajustar para iniciar automaticamente

systemctl enable docker

Verificando problemas

Inspecionando os logs do docker:

journalctl -ul docker

Kubernetes

Instalando o Kubernetes

1) Criar arquivo /etc/yum.repos.d/kubernetes.repo, com o conteúdo:

[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
 

2) Instalando os pacotes no CentOS

yum install -y kubelet-1.11.9 kubeadm-1.11.9 kubectl-1.11.9

3) Remover o arquivoo

/etc/yum.repos.d/kubernetes.repo

4) Start o Kubernetes

systemctl start kubelet

6) Se tudo estiver correto ajustar para iniciar automaticamente

systemctl enable kubelet

Ver também