
0단계 - 설명 좀~
- k3s 마스터를 만들다
- CentOS에서 하는 것임

1단계 - 방화벽 룰 추가
########################################################################################
### Firewalld ###
#########################################################################################
## on the master
root:~$ firewall-cmd --permanent --add-port=6443/tcp && firewall-cmd --permanent --add-port=10250-10252/tcp && firewall-cmd --permanent --add-port=8285/udp && firewall-cmd --reload && firewall-cmd --list-all
- 6443/tcp
- 10250-10252/tcp
- 8285/tcp
- 위 포트들을 열어줘야 한다는~~~!!
- 안그러면 뭔가 안되는 것이 나타날것임~~~

2단계 - SELinux off
#########################################################################################
### K3s All Node ###
#########################################################################################
### Set SELinux in permissive mode (effectively disabling it)
root:~$ setenforce 0 \
&& sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
3단계 - swap disable
### Disable swap
root:~$ swapoff -a \
&& sed -e '/swap/s/^/#/g' -i /etc/fstab
4단계 - firewalld off
### Disable firewall starting from Kubernetes v1.19 onwards
root# systemctl stop firewalld \
&& systemctl disable firewalld
5단계 - net.bridge.bridge-no-call-iptables = 1
root:~$ cat << EOF | sudo tee /etc/sysctl.d/k3s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
root:~$ sysctl --system
- CentOS 같은 리눅스 배포판은 net.bridge.bridge-no-call-iptables 값이 디폴트 0 (zero)다
- 이는 bridge 네트워크를 통해 송수신되는 패킷이 iptables 설정을 우회한다는 의미다
- 컨테이너의 네트워크 패킷이 호스트머신의 iptables 설정에 따라 제어되도록 하는 것이 바람직하며 이를 위해서는 이 값을 1로 설정해야 한다
- docker info 명령을 실행했을 때 "bridge-nf-call-iptables is disabled" 워닝이 뜨는 경우가 있다.

6단계 - /etc/hosts 파일 수정
### Master & Node Host Domain Name Regist -------------------------------------------------
root# cat >> /etc/hosts<<EOF
192.168.0.24 vmaster
192.168.0.25 vnode1
192.168.0.26 vnode2
192.168.0.27 vnode3
192.168.0.28 vnode4
192.168.0.29 vnode5
192.168.0.30 vhub
EOF
- 중요한게 있다. host name이 중복되면 절대 안되는다!!!
- 6443/tcp 포트로 접속을 시도하는데, 이름이 같으면 마스터가 접속을 거부한다
- 다음과 같은 에러를 확인하 실 수 있을 것이다!!!
[root@localhost ~]# systemctl status k3s-agent
× k3s-agent.service - Lightweight Kubernetes
Loaded: loaded (/etc/systemd/system/k3s-agent.service; enabled; vendor preset: disabled)
Active: failed (Result: timeout) since Mon 2022-03-21 19:41:31 EDT; 49s ago
Docs: https://k3s.io
Process: 2477 ExecStartPre=/bin/sh -xc ! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup.service (code=exited, status=0/SUCCESS)
Process: 2481 ExecStartPre=/sbin/modprobe br_netfilter (code=exited, status=0/SUCCESS)
Process: 2482 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Process: 2483 ExecStart=/usr/local/bin/k3s agent (code=killed, signal=KILL)
Main PID: 2483 (code=killed, signal=KILL)
CPU: 2.307s
Mar 21 19:41:11 localhost.localdomain k3s[2483]: time="2022-03-21T19:41:11-04:00" level=info msg="Waiting to retrieve agent configuration; server is not ready: Node password rejected, duplicate hostname or >

7단계 - k3s 설치
root:~$ curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" INSTALL_K3S_EXEC="server --no-deploy traefik" sh -s -
- "traefik"포함시지 않고 설치하도록 하였다.
- "traefik"이라는 것은 router(ingress처럼)역할을 해주는 것인데,
- "traefik"을 뺴는 대신 "nginx ingress controller"를 설치한다.
- "traefik" 사용법을 잘 몰라서 설치 하지 않는 것이다.
- 사용법만 잘 알아도 설치하면 아주 좋을 것 같으나;;;
- tcp/udp port 라우팅이 잘 안되었다? 뭘 잘 못하였는지 파악이 안된다;;;;ㅜ,.ㅜ

더보기
root:~$ mkdir -p /etc/rancher/k3s
root:~$ cat << EOF | sudo tee /etc/rancher/k3s/config.yaml
disable:
- traefik
#### DISABLE LEADER ELECTION : reduces CPU usage, but DO NOT DO THIS if you are going to run
#### a multi-node cluster!!!!
kube-controller-manager-arg:
- "leader-elect=false"
- "node-monitor-period=60s"
kubelet-arg:
- 'eviction-hard=imagefs.available<1%,nodefs.available<1%'
- 'eviction-minimum-reclaim=imagefs.available=1%,nodefs.available=1%'
EOF
root:~$ curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644" sh -s -
root:~$ systemctl status k3s
root:~$ kubectl get node
root:~$ kubectl get pod --all-namespaces
이렇게도 설치할 수 있습니다.
8단계 - auto complete 설정하기
##Install Kubectl Auto-Complete
root:~$ kubectl completion bash > /etc/bash_completion.d/kubectl
root:~$ source /usr/share/bash-completion/bash_completion
- 이걸 해줘야 편하지 않겠는가?
- tab으로 명령이 알아서 들어가잖아요 ^^
- "/etc/bash_complete.d/" 이 디렉토리가 중요하구먼!!!
- "source"는 무슨 명령이가요?
- 스크립트 파일을 수정한 후에 수정된 값을 바로 적용하기 위해 사용하는 명령어이다.
- baseh_completion을 바로 적용하겠다는 거군요!!!ㅎㅎㅎㅎㅎ
9단계 - ~/.kube/config 만들기
### Server Token Check
user:~$ kubectl config view --raw >~/.kube/config
user:~$ chmod 600 ~/.kube/config
- 위 config를 만들지 않으면 kubectl이 정상작동하지 않는 것 같다
- 왜그러는지는 모르겠습니다. T T
- 왜그러긴^^ 니가 무식하니까...그렇지...;;;;;자책중...
- 왜그러는지는 모르겠습니다. T T

10단계 - k3s 노드 토큰 확인
[root@master ~]# sudo cat /var/lib/rancher/k3s/server/node-token
K10343525c00ffbf2be0b3c9adb0a48f3636cb85af556abb488989be70f192772ca::server:1d048b2fe2f970cc9db344d58112b38d
- 위 토큰으로 k3s 노드들이 마스터에 달라 붙을 수 있다는^^!
100단계 - 결론
- k3s를 그냥 설치하면 잘 안될 것이라는!!!
- selinux 꺼주고
- 방화벽 꺼주고
- swap 도 꺼주고
- hosts에 노드들 이름 등록해주고
- k3s설치하고
- k3s 노드토큰 확인까지~~~아이구 단순하진 않음~~
- 이걸 한방에 해주는 것은 없나요?ㅎㅎㅎ
- 누군가 했을거야 github을 뒤져보면 나올 것 같지 않아요?^^
'kubernetes' 카테고리의 다른 글
| Ubuntu 22.04에 k3s설치하기 (0) | 2022.09.08 |
|---|---|
| 왜? pod에 한개의 VSCode만 attach되는 거여? (0) | 2022.07.20 |
| Visual Studio Code - KUBERNETES 확장으로 파드(POD) 터미널 접 (0) | 2022.03.20 |
| 쿠버네티스 - pod 생성 시 명령 실행하기 (0) | 2022.03.19 |
| helm install bitnami/postgresql 및 id/pw는 뭐여 (0) | 2022.03.19 |
