반응형
Notice
Recent Posts
Recent Comments

04-29 13:39
관리 메뉴

SaevOps

[쿠버네티스] Run과 Create의 차이 본문

클라우드/Kubernetes

[쿠버네티스] Run과 Create의 차이

세브웁스 2022. 10. 14. 11:00
반응형

이론

Run과 Create의 차이점

  • Create : 디플로이먼트라는 관리 그룹 내 파드 생성
  • Run : 단일 파드 생성 및 관리
  • 1.18 버전 이전 버전에서 run으로 파드를 생성 시 더 이상 사용을 권고하지 않음을 알림

기본 오브젝트

  •  파드
     - 쿠버네티스에서 실행되는 최소 단위
     - 독립적인 공간과 사용 가능한 IP
     - 하나 이상의 컨테이너를 가지나 범용으로 사용할 때는 1개의 파드에 1개의 컨테이너

  •  네임스페이스
     - 클러스터에서 사용되는 리소스들을 구분해 관리하는 그룹

  •  볼륨
    - 파드가 생성될 때 파드에서 사용할 수 있는 디렉터리

  • 서비스
    - 파드는 접속 정보가 유동적
    - 이 접속을 안정적으로 유지하기 위해 새로운 IP를 기존에 제공하던 기능과 연결

실습

우선, Vagrant를 통해 모든 서버를 실행

PS C:\HashiCorp> vagrant up

Run으로 파드를 생성했을 때와 Create로 생성했을 때 정상적으로 작동하는지 확인 

# 마스터 노드에 접속하기
PS C:\HashiCorp> vagrant ssh m-k8s

[root@m-k8s ~]# kubectl run nginx-pod --image=nginx
pod/nginx-pod created

[root@m-k8s ~]# kubectl get pod
NAME        READY   STATUS    RESTARTS   AGE
nginx-pod   1/1     Running   0          63s


[root@m-k8s ~]# kubectl create nginx --image=nginx
Error: unknown flag: --image

[root@m-k8s ~]# kubectl create deployment dpy-nginx --image=nginx
deployment.apps/dpy-nginx created

[root@m-k8s ~]# kubectl get pods
NAME                       READY   STATUS              RESTARTS   AGE
dpy-nginx-c8d778df-zjgsz   0/1     ContainerCreating   0          11s
nginx-pod                  1/1     Running             0          2m9s

[root@m-k8s ~]# kubectl get pods -o wide
NAME                       READY   STATUS              RESTARTS   AGE     IP               NODE     NOMINATED NODE   READINESS GATES
dpy-nginx-c8d778df-zjgsz   0/1     ContainerCreating   0          19s     172.16.103.129   w2-k8s   <none>           <none>
nginx-pod                  1/1     Running             0          2m17s   172.16.221.129   w1-k8s   <none>           <none>

# curl 을 통해 비교하면 페이지 작동이 정상임을 확인 가능
# curl (Service_IP1)
curl 172.16.103.129

# curl (Service_IP2)
curl 172.16.221.129

트러블슈팅

문제1

PS C:\HashiCorp\_Book_k8sInfra-main\ch3\3.1.3> vagrant up
Bringing machine 'm-k8s' up with 'virtualbox' provider...
Bringing machine 'w1-k8s' up with 'virtualbox' provider...
Bringing machine 'w2-k8s' up with 'virtualbox' provider...
Bringing machine 'w3-k8s' up with 'virtualbox' provider...
==> m-k8s: Importing base box 'sysnet4admin/CentOS-k8s'...
==> m-k8s: Matching MAC address for NAT networking...
==> m-k8s: Checking if box 'sysnet4admin/CentOS-k8s' version '0.7.4' is up to date...
==> m-k8s: Setting the name of the VM: m-k8s(github_SysNet4Admin)
==> m-k8s: Clearing any previously set network interfaces...
==> m-k8s: Preparing network interfaces based on configuration...
    m-k8s: Adapter 1: nat
    m-k8s: Adapter 2: hostonly
==> m-k8s: Forwarding ports...
    m-k8s: 22 (guest) => 60010 (host) (adapter 1)
==> m-k8s: Running 'pre-boot' VM customizations...
A customization command failed:

["modifyvm", :id, "--groups", "/k8s-SgMST-1.13.1(github_SysNet4Admin)"]

The following error was experienced:

#<Vagrant::Errors::VBoxManageError: There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["modifyvm", "b89e9bec-1033-4927-bb91-39392ae8155d", "--groups", "/k8s-SgMST-1.13.1(github_SysNet4Admin)"]

Stderr: VBoxManage.exe: error: Could not rename the directory 'C:\Users\rlatp\VirtualBox VMs\새 그룹\m-k8s(github_SysNet4Admin)' to 'C:\Users\rlatp\VirtualBox VMs\k8s-SgMST-1.13.1(github_SysNet4Admin)\m-k8s(github_SysNet4Admin)' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component SessionMachine, interface IMachine, callee IUnknown
VBoxManage.exe: error: Context: "SaveSettings()" at line 3286 of file VBoxManageModifyVM.cpp
>

Please fix this customization and try again.

해결

에러에서 친절하게 원인을 알려주고 있다.

Stderr: VBoxManage.exe: error: Could not rename the directory 'C:\Users\rlatp\VirtualBox VMs\새 그룹\m-k8s(github_SysNet4Admin)' to 'C:\Users\rlatp\VirtualBox VMs\k8s-SgMST-1.13.1(github_SysNet4Admin)\m-k8s(github_SysNet4Admin)' to save the settings file (VERR_ALREADY_EXISTS) 

 

해당 경로에 있는 VMs 삭제
C - 사용자 - 사용자 이름 VirtualBox VMs

필자의 경로 

C:\Users\rlatp\VirtualBox VMs

모든 파일 삭제


문제 2

kubectl run nginx-pod --image=nginx 명령어 실행 시 다음과 같은 에러가 나옴

The connection to the server localhost:8080 was refused - did you specify the right host or port?

 

해결

이것은 kubectl 명령어를  root 권한으로 실행해주면 해결.

해당 명령어 : [sudo su - ]

반응형
Comments