[Kubernetes]구성형 쿠버네티스 설치

2023. 4. 20. 11:56· Kubernetes
목차
  1. 개  요
  2. 설치 조건 사항
  3. Runtime 설치
  4. Kubernetes 설치
  5. 설치 후 공통 작업
728x90

kubernetes

개  요

CnetOS 환경과 Ubuntu 환경에서의 설치 방법을 설명

설치 조건 사항

1. firewalld 설정

  • 6443, 10250/tcp port를 OPEN 하거나 방화벽을 종료
$ firewall-cmd --add-port=6443-10250/tcp
$ systemctl stop firewlld.service

2. selinux off 설정

$ setenforce=0
$ vi /etc/sysconfig/selinux 파일에서 아래 옵션 부분 설정
...
SELINUX=disabled
...

 

3. swap 설정

  • RSS 메모리 + 페이지 메모리 (swap off)
$ swapoff -a
## 영구적용 ##
$ vi /etc/fstab에서 swap줄을 주석으로 설정

4. hostname과 IP mapping 설정

  • /etc/hosts 파일에서 hostname과 IP mapping 설정

5. Kernel module and parameters 설정

  • OS 모듈 설정
$ modprobe br_netfilter // 해당 모듈 기동 
$ lsmod | grep br_netfilter // 모듈 기동 확인
  • 영구적으로 모듈 기동 설정
$ vi /etc/modules-load.d/99-Kubernetes.conf 파일에서 아래 내용 작성 후 저장
br_netfilter 
overlay 
ip_vs_rr 
ip_vs_wrr 
ip_vs_sh 
ip_vs 
nf_conntrack_ipv4
  • 네트워크 파라미터 설정
$ vi /etc/sysctl.d/99-k8s.conf 파일에서 아래 내용 작성 후 저장
net.bridge.bridge-nf-call-iptables=1 
net.ipv4.ip_forward=1 
net.bridge.bridge-nf-call-ip6tables=1

$ sysctl --system -p

Runtime 설치

1. containerd 설치

  • docker-ce.repo 다운로드
$ cd /etc/yum.repose.d
$ wget https://download.docker.com/linux/centos/docker-ce.repo
$ yum –y install containerd
  • 설정 초기화
$ containerd config default > /etc/containerd/config.toml
  • containerd 기동 후 확인
$ systemctl enable -now containerd
$ systemctl status containerd

2. CRI-O (CentOS)

참고 URL : https://cri-o.io/ 

 

cri-o

Try Now Minikube: Use CRI-O as the container runtime kubeadm: Checkout this kubeadm guide to setup kubeadm to use CRI-O Kubic: Configured to use CRI-O out of the box in both its kubeadm and microOS system roles Join #crio on Kubernetes Slack Distribution P

cri-o.io

  • 환경 변수 설정 (CentOS8_stream, crio version 1.17.3 기준)
$ export OS=CentOS_8_stream
$ export VERSION=1.17:1.17.3
  • Repository 다운로드
$ curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/devel:/kubic:/libcontainers:/stable.repo
$ curl -L -o /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:$VERSION.repo https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/devel:kubic:libcontainers:stable:cri-o:$VERSION.repo
  • CRI-O 설치
$ yum install -y cri-o
  • CRI-O 기동 및 확인
$ systemctl start crio
$ systemctl enable crio
$ systemctl status crio

3. CRI-O (Ubuntu)

  • 환경 변수 설정 (Ubuntu 20.04, crio version 1.17.3 기준)
$ export OS=xUbuntu_20.04
$ export VERSION=1.17:/1.17.3
  • Repository 다운로드
$ echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
$ echo "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/ /" > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable:cri-o:1.17:1.17.3.list

$ curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/$VERSION/$OS/Release.key | apt-key add -
$ curl -L https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/$OS/Release.key | apt-key add -
  • CRI-O 설치
$ apt-get update
$ apt-get install cri-o cri-o-runc
  • CRI-O 기동 및 확인
$ systemctl start crio
$ systemctl enable crio
$ systemctl status crio

Kubernetes 설치

Kubernetes 설치(CentOS/Redhat)

  • repository 설정
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo 
[kubernetes] 
name=Kubernetes 
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-\$basearch 
enabled=1 
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=kubelet kubeadm kubectl 
EOF
  • kubeadm 설치
$ yum install –y kubelet kubeadm kubectl --disableexcludes=kubernetes

Kubernetes 설치(Ubuntu)

  • kubernetes 설치 진행 위해 저장소 업데이트 및 필수 패키지 추가
$ apt-get update
$ apt-get install –y apt-transport-https ca-certificates curl
  • Google 클라우드 퍼블릭 키 다운로드
$ curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
  • Repository 추가
$ echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
  • kubeadm 설치
$ apt-get update
$ apt-get install –y kubelet kubectl kubeadm
$ apt-mark hold kubelet kubectl kubeadm

설치 후 공통 작업

설치 후 공통 작업

  • kubeadm init 실행
$ kubeadm init --control-plane-endpoint=[master 주소 / 내부 ip 주소] --upload-certs --apiserver-advertise-address=[master 주소 / 내부 ip 주소] --pod-network-cidr=[pod 내에서 사용할 주소]

….
Then you can join any number of worker nodes by running the following on each as root:

kubeadm join [ip주소]:6443 --token v1nfh1.hjlkza7z630egrgy \
--discovery-token-ca-cert-hash sha256:37cc731e72892e2c0a10dc1139ab2a399e77de8ea8fe539995097234d2361ff2

위와 같이 나오면 설치 성공
  • root 계정을 이용해서 kubectl을 사용하기 위해 환경 변수 설정
$ mkdir –p ~/.kube/
$ cp /etc/Kubernetes/admin.conf ~/.kube/config
  • kubectl 명령어 자동 완성 설정
$ yum install bash-completion –y
$ source <(kubectl completion bash)
$ echo “source <(kubectl completion bash)” >> ~/.bashrc

Kubernetes Cluster

  • kubeadm init 후 나온 Join 명령어를 kubernetes가 설치된 각 worker node에서 실행
$ kubeadm join [ip주소]:6443 --token v1nfh1.hjlkza7z630egrgy \
--discovery-token-ca-cert-hash sha256:37cc731e72892e2c0a10dc1139ab2a399e77de8ea8fe539995097234d2361ff2
  • kubeadm token 명령어로도 join 문 생성 가능
$ kubeadm toke create –print-join-command

Kubernetes 초기화

  • kubeadm reset 명령어로 초기화 가능
$ kubeadm reset --force
728x90
저작자표시 비영리 변경금지 (새창열림)

'Kubernetes' 카테고리의 다른 글

[Kubernetes]에러 모음집  (0) 2023.08.30
[kubernetes]Private Registy  (0) 2023.05.15
[kubernetes]Metallb 설치  (1) 2023.05.11
[kubernetes]Calico 설치  (0) 2023.04.25
Kubernetes  (0) 2023.04.19
  1. 개  요
  2. 설치 조건 사항
  3. Runtime 설치
  4. Kubernetes 설치
  5. 설치 후 공통 작업
'Kubernetes' 카테고리의 다른 글
  • [kubernetes]Private Registy
  • [kubernetes]Metallb 설치
  • [kubernetes]Calico 설치
  • Kubernetes
JOTAN
JOTAN
기술 블로그
조탄 기술블로그기술 블로그
JOTAN
조탄 기술블로그
JOTAN
전체
오늘
어제
  • 목 록
    • Security
    • WEB
      • WebtoB
      • Apache
      • Nginx
    • WAS
      • Tomcat
      • JEUS
      • Wildfly
    • Observability
      • Fluentd
    • CI CD
    • DataBase
      • Redis
      • PostgreSQL
      • Victoria Metrics
    • Container Registry
      • Harbor
    • Docker
    • Kubernetes
    • Message Queue
      • Kafka
    • 개발
      • Spring Boot
      • Java
      • Shell Script
    • 기본지식
    • OS
      • Debian
      • Red Hat

블로그 메뉴

  • 홈

공지사항

  • 조'S IT 영역

인기 글

태그

  • webtob
  • fluentd
  • apache ssl 설정
  • 인증서
  • kubernetes install
  • Redis Cache
  • harbor
  • redis 설정
  • 설치
  • KAFKA
  • nginx
  • tomcat
  • SSL
  • 쿠버네티스 대시보드
  • wildfly14
  • Redis TEST
  • hostaliases
  • redis
  • 레디스
  • Wildfly Session Clustering
  • 레디스 설정
  • apache vhosts
  • Kubernetes
  • 쿠버네티스 설치
  • ssl vhosts
  • Redis 기능 검증
  • kubernetes dns
  • 쿠버네티스
  • jboss session clustering
  • apache

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.2
JOTAN
[Kubernetes]구성형 쿠버네티스 설치
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.