Установка docker, kebernates кластера
Установка и настройка docker kebernates 1. Установка и запуск сервиса docker
- yum install docker docker-containerd
- systemctl start docker
- systemctl enable docker
2. Проверка и запуск контейнера
- docker pull debian
- docker run -it --rm --name pekonkin debian bash
3. Создание Dockerfile
- touch Dockerfile
- vi Dockerfile
Вставить фрагмент:
FROM debian RUN apt-get update && apt-get install ntp –y
Создание image из Dockerfile
- docker build .
4.Установка kubernates master-node
- yum install -y kubelet kubeadm kubectl
- systemctl enable kubelet
- systemctl start kubelet
- hostnamectl set-hostname master-node
- vi /etc/hosts
10.45.4.58 master-node 10.45.4.59 worker-node
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- kubeadm init
Установщик даст токен подключения к master node, у вас будет свой токен подключения kubeadm join 10.45.4.58:6443 --token ncb63c.pugf9xehkjakptqp --discovery-token-ca-cert-hash sha256:73cb40755a49b40f2a724984392f32fd7ff607a437da524619d4aba43a2c31b6
- mkdir -p $HOME/.kube
- cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
- chown $(id -u):$(id -g) $HOME/.kube/config
- export kubever=$(kubectl version | base64 | tr -d '\n'
- kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"
- systemctl restart kubelet
5.Установка kubernates worker-nodes (pods контейнеры)
- yum install docker docker-containerd
- systemctl start docker
- systemctl enable docker
- yum install -y kubelet kubeadm kubectl
- systemctl enable kubelet
- hostnamectl set-hostname worker-node
- vi /etc/hosts
10.45.4.58 master-node 10.45.4.59 worker-node
- sed -i '/swap/d' /etc/fstab
- swapoff -a
Присоединяем worker-node к master:
- kubeadm join 10.45.4.58:6443 --token ncb63c.pugf9xehkjakptqp --discovery-token-ca-cert-hash sha256:73cb40755a49b40f2a724984392f32fd7ff607a437da524619d4aba43a2c31b6
- systemctl restart kubelet.service
5.Проверка работоспособности Создание deployment
- vi deploy.yml
apiVersion : apps/v1 kind: Deployment metadata:
name: my-web-deployment labels: app : my-k8s-application
spec:
selector: matchLabels: project: kgb template: metadata: labels: project: kgb spec: containers: - name : kgb-web image: debian ports: - containerPort: 80
- kubectl apply –f deploy.yml