티스토리 뷰

▩ kubectl 이 다운로드가 안되었다

[vagrant@ms ~]$ sudo find / -name kubectl
[vagrant@ms ~]$

 

▷install_cluster.sh 에서 kubernetes.repo 부분이 작동이 안된듯 하다

더보기
### bash script for install kubernetes cluster

#Set the time zone to local time and set the exact time
timedatectl set-timezone Asia/Seoul

yum install -y yum-utils
modprobe overlay
modprobe br_netfilter
yum install -y iproute-tc

cat <<EOF | tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF

cat <<EOF | tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
# apply the 99-kubernetes-cri.conf file immediately
sysctl --system

# disable firewall
systemctl disable firewalld
systemctl stop firewalld

yum-config-manager \
    --add-repo \

yum install -y containerd.io

mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml

systemctl restart containerd
systemctl enable containerd

# disable selinux
setenforce 0
sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config

cat <<EOF | tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
enabled=1
gpgcheck=1
exclude=kubelet kubeadm kubectl
EOF
yum install -y kubelet kubeadm kubectl \
--disableexcludes=kubernetes

systemctl enable --now kubelet

# disable swap space
swapoff -a
sed -e '/swap/s/^/#/' -i /etc/fstab

# add cluster nodes in the hosts file
tee /etc/hosts <<EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
:1         localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF

echo "192.168.98.10   ms.example.com      ms" >> /etc/hosts
echo "192.168.98.20   wk1.example.com     wk1" >> /etc/hosts
echo "192.168.98.30   wk2.example.com     wk2" >> /etc/hosts

 

 

▩ kubelet 직접 설치 >> 불가능

 

 

▶ repo 가 바뀌었다 ( 최신버전 )

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/repodata/repomd.xml.key
EOF

 

▶ install_cluster.sh 수정

더보기
### bash script for install kubernetes cluster

#Set the time zone to local time and set the exact time
timedatectl set-timezone Asia/Seoul

yum install -y yum-utils
modprobe overlay
modprobe br_netfilter
yum install -y iproute-tc

cat <<EOF | tee /etc/modules-load.d/containerd.conf
overlay
br_netfilter
EOF

cat <<EOF | tee /etc/sysctl.d/99-kubernetes-cri.conf
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
EOF
# apply the 99-kubernetes-cri.conf file immediately
sysctl --system

# disable firewall
systemctl disable firewalld
systemctl stop firewalld

yum-config-manager \
    --add-repo \

yum install -y containerd.io

mkdir -p /etc/containerd
containerd config default | tee /etc/containerd/config.toml
sed -i 's/SystemdCgroup = false/SystemdCgroup = true/g' /etc/containerd/config.toml

systemctl restart containerd
systemctl enable containerd

# disable selinux
setenforce 0
sed -i 's/^SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
enabled=1
gpgcheck=1
EOF
yum install -y kubelet kubeadm kubectl \
--disableexcludes=kubernetes

systemctl enable --now kubelet

# disable swap space
swapoff -a
sed -e '/swap/s/^/#/' -i /etc/fstab

# add cluster nodes in the hosts file
tee /etc/hosts <<EOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
:1         localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF

echo "192.168.98.10   ms.example.com      ms" >> /etc/hosts
echo "192.168.98.20   wk1.example.com     wk1" >> /etc/hosts
echo "192.168.98.30   wk2.example.com     wk2" >> /etc/hosts

 

● powershell 에서 vagrant provision 으로 다시 올린다

▩ 아래와 같은 오류로 잘 안될 때가 있는데 그럴 때에는 캐시를 삭제하고 다시 provision 해보자

E0307 12:57:47.309816    7240 memcache.go:265]
couldn't get current server API group list: 
Get "http://localhost:8080/api?timeout=32s": 
dial tcp 127.0.0.1:8080: connect: connection refused
sudo rm -r /var/cache/dnf

 

 

● kubernetes 정상 작동

[vagrant@ms ~]$ kubectl get nodes
NAME              STATUS   ROLES           AGE   VERSION
ms.example.com    Ready    control-plane   97s   v1.29.2
wk1.example.com   Ready    <none>          74s   v1.29.2
wk2.example.com   Ready    <none>          68s   v1.29.2

 

 

# kubeadm 이 설치하기 가장 편리할 듯 하다

https://kubernetes.io/ko/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

 

kubeadm 설치하기

이 페이지에서는 kubeadm 툴박스 설치 방법을 보여준다. 이 설치 프로세스를 수행한 후 kubeadm으로 클러스터를 만드는 방법에 대한 자세한 내용은 kubeadm으로 클러스터 생성하기 페이지를 참고한다.

kubernetes.io

 

 

 

● kubectl 자동완성 안될 때 다시 확인

>> .bashrc 가 프로비전 3번했더니 3개가 생겼다

>> 그냥 source .bashrc 입력하여 해결하자

[vagrant@ms ~]$ cat .bashrc
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific environment
if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]
then
    PATH="$HOME/.local/bin:$HOME/bin:$PATH"
fi
export PATH

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
source <(kubectl completion bash)
source <(kubectl completion bash)
source <(kubectl completion bash)

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함