Skip to main content

Bastion에서 Kubectl 쓰기 (수정 중)

References:

Installting Kubectl: https://kubernetes.io/docs/tasks/tools/

curl -LO https://dl.k8s.io/release/v1.24.6/bin/linux/amd64/kubectl
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0    666      0 --:--:-- --:--:-- --:--:--   666
100 43.6M  100 43.6M    0     0  21.0M      0  0:00:02  0:00:02 --:--:-- 29.6M

ls
kubectl  kubespray  kubesprayv2.20  original-ks.cfg

curl -LO https://dl.k8s.io/release/v1.24.6/bin/linux/amd64/kubectl.sha256
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   138  100   138    0     0    650      0 --:--:-- --:--:-- --:--:--   650
100    64  100    64    0     0    122      0 --:--:-- --:--:-- --:--:--   122

ls
kubectl  kubectl.sha256  kubespray  kubesprayv2.20  original-ks.cfg

echo "$(cat kubectl.sha256)  kubectl" | sha256sum --check
kubectl: OK

sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

kubectl version --client
WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.6", GitCommit:"b39bf148cd654599a52e867485c02c4f9d28b312", GitTreeState:"clean", BuildDate:"2022-09-21T13:19:24Z", GoVersion:"go1.18.6", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.4

# Master노드에 있는 '.kube/config' 파일을 복붙
mkdir .kube
cd .kube
vi config

# 그대로 복붙 하면 안됨, 왜냐면 거기에서는 로컬 호스트로 지정 되어 있음
kubectl get nodes
The connection to the server 127.0.0.1:6443 was refused - did you specify the right host or port?

# 그래서 5번째 줄에서 서버 IP를 Master노드 IP로 지정
vi config
server: https://192.168.122.8:6443


kubectl get nodes
NAME    STATUS   ROLES           AGE   VERSION
node1   Ready    control-plane   13d   v1.24.6
node2   Ready    <none>          13d   v1.24.6
node3   Ready    <none>          13d   v1.24.6