아래 저장소 주소(
packages.cloud.google.com·apt.kubernetes.io)는 2024년 3월에 닫혔다. 그대로 따라 하면 패키지를 받을 수 없다.
현행 버전 설치는 Kubernetes v1.37 설치 가이드 를 볼 것. 아래 내용은 절차 참고용으로 남긴다.
# 최신 버전 다운로드
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
#특정 버전 다운로드 (ex. V1.22.0)
curl -LO https://dl.k8s.io/release/v1.22.0/bin/linux/amd64/kubectl
파일 검증
# Checksum 다운로드
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
#검증
echo "$(<kubectl.sha256) kubectl" | sha256sum --check
root 권한이 있는 경우
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
root 권한이 없는 경우
chmod +x kubectl
mkdir -p ~/.local/bin/kubectl
mv ./kubectl ~/.local/bin/kubectl
# and then add ~/.local/bin/kubectl to $PATH
Update the apt package index and install packages needed to use the Kubernetes apt repository
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl
Download the Google Cloud public signing key:
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
Add the Kubernetes apt 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
설치
sudo apt-get update
sudo apt-get install -y kubectl
리포지터리 추가
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
설치
yum install -y kubectl
kubectl version --client
Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.4", GitCommit:"e87da0bd6e03ec3fea7933c4b5263d151aafd07c", GitTreeState:"clean", BuildDate:"2021-02-18T16:12:00Z", GoVersion:"go1.15.8", Compiler:"gc", Platform:"linux/amd64"}