Kubernetes: Instalação Offline ou Instalação usando repositórios privados

From Wiki

Trabalhei em uma empresa onde as regras de segurança bloqueava o acesso a sites/repositórios externos. Essa situação dificulta em muito a instalação do Docker e Kubernetes.

Neste artigo descrevo como driblei essa situação e consegui instalar o meu cluster Kubernetes.

Criando o repositório para Arquivos e RPMs

Faça o download dos arquivos em uma estação que tenha acesso à Internet

Opção 1 - Download dos arquivos

Arquivos do Docker


mkdir -p /tmp/docker-mirror/linux/centos/7/x86_64/stable/repodata/
mkdir -p /tmp/docker-mirror/linux/centos/7/x86_64/stable/Packages/
 
cd /tmp/docker-mirror/linux/centos/7/x86_64/stable/repodata/
 
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/repomd.xml
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/27151177db68b47d024022599f6cdb8d0758feaefd8c65e43e8313af62eed131-filelists.xml.gz
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/2811439ca3c66a6cb946abe2a8e4cfea7f364e09ca9ab0f4ba10f2333b74b911-filelists.sqlite.bz2
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080-updateinfo.xml.gz
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/83a7f2e6c4dffb21fe0cc818e572bb4bf2bbb8dbd860dad66179a8bbc06f64d9-other.xml.gz
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/b292d47325588b6eb4f589e04bbf0f95727fa1755d8fa65d6978e1294f11b167-primary.sqlite.bz2
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/c2d756b11328eaa080323355c4b1c1d9442bbe8798b183b79fa53841274f1633-other.sqlite.bz2
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/repodata/ff7792a80a96a8fd9eb9843f830bf7ffc031e67eef965d918f724f250b9e38bc-primary.xml.gz

cd /tmp/docker-mirror/linux/centos/7/x86_64/stable/Packages/
 
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.03.3.ce-1.el7.x86_64.rpm
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.3.ce-1.el7.noarch.rpm
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.06.3.ce-3.el7.x86_64.rpm
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-18.09.6-3.el7.x86_64.rpm
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-cli-18.09.6-3.el7.x86_64.rpm
wget -c https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.5-3.1.el7.x86_64.rpm
 

Copiar para o servidor http interno

Na máquina de destino basta usar

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

</small>
[docker-ce]
name=Docker CE Stable - $basearch
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
 


mkdir -p /tmp/kubernetes-mirror/yum/repos/kubernetes-el7-x86_64/repodata/ mkdir -p /tmp/kubernetes-mirror/yum/pool cd /tmp/kubernetes-mirror/yum/repos/kubernetes-el7-x86_64/repodata/

wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/filelists.xml wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/filelists.xml.gz wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/other.xml wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/other.xml.gz wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/primary.xml wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/primary.xml.gz wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml wget -c https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml.gz

cd /tmp/kubernetes-mirror/yum/pool

wget -c https://packages.cloud.google.com/yum/pool/542cbe1b886808a7f025595b2bfe776fd08de5d2dab0a80f22947cf400b89a2c-kubectl-1.11.9-0.x86_64.rpm wget -c https://packages.cloud.google.com/yum/pool/2d3fea397e599d94ec3d67582c522719ca3e9bd946c0f89a33caa07a49e1b883-kubeadm-1.11.9-0.x86_64.rpm wget -c https://packages.cloud.google.com/yum/pool/b82b358f2951dc396af6e2e56f9b1ca6ab5b494208996a5788682d9e49312d7b-kubelet-1.11.9-0.x86_64.rpm cd ../..

</nowiki>

cfssl mirror

Download dos arquivos

mkdir -p /tmp/cfssl-mirror/R1.2
cd /tmp/cfssl-mirror/R1.2
wget -c http://pkg.cfssl.org/R1.2/cfssl_linux-amd64
 wget -c http://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
 wget -c http://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
cd ../..

Copiar para o servidor http interno. E utilizar

wget -c http://<servidor_interno>/cfssl-mirror/R1.2/cfssl_linux-amd64
wget -c http://<servidor_interno>/cfssl-mirror/R1.2/cfssljson_linux-amd64
wget -c http://<servidor_interno>/cfssl-mirror/R1.2/cfssl-certinfo_linux-amd64

Etcd mirror

Download dos arquivos

mkdir -p /tmp/etcd-mirror/etc/v3.1.13
cd /tmp/etcd-mirror/etc/v3.1.13
wget -c https://storage.googleapis.com/etcd/v3.1.13/etcd-v3.1.13-linux-amd64.tar.gz
cd ../..

Copiar para o servidor http interno. E utilizar

wget -c http://<servidor_interno>/cfssl-mirror/R1.2/cfssl_linux-amd64
wget -c http://<servidor_interno>/cfssl-mirror/R1.2/cfssljson_linux-amd64
wget -c http://<servidor_interno>/cfssl-mirror/R1.2/cfssl-certinfo_linux-amd64

Ver também