brunch

7.(온라인) AI워크로드 쿠버네티스-2025-11

by Master Seo

# 실무에서 가장 많이 사용하는 쿠버네티스 사용법 입니다.

# 실습은 쿠버네티스 생성까지만 합니다.

# 컨테이너 레지스트리와 배포는 참고만 하세요


----------------


1

AI Worklod




2

명령어 다운로드



슬라이드1.JPG
슬라이드2.JPG
슬라이드3.JPG
슬라이드4.JPG
슬라이드5.JPG
슬라이드6.JPG
슬라이드7.JPG
슬라이드8.JPG
슬라이드9.JPG
슬라이드10.JPG
슬라이드11.JPG
슬라이드12.JPG
슬라이드13.JPG
슬라이드14.JPG
슬라이드15.JPG
슬라이드16.JPG
슬라이드17.JPG
슬라이드18.JPG
슬라이드19.JPG
슬라이드20.JPG
슬라이드21.JPG
슬라이드22.JPG
슬라이드23.JPG
슬라이드24.JPG
슬라이드25.JPG
슬라이드26.JPG
슬라이드27.JPG
슬라이드28.JPG
슬라이드29.JPG
슬라이드30.JPG
슬라이드31.JPG
슬라이드32.JPG
슬라이드33.JPG
슬라이드34.JPG
슬라이드35.JPG
슬라이드36.JPG
슬라이드37.JPG
슬라이드38.JPG
슬라이드39.JPG
슬라이드40.JPG
슬라이드41.JPG
슬라이드42.JPG
슬라이드43.JPG
슬라이드44.JPG
슬라이드45.JPG
슬라이드46.JPG
슬라이드47.JPG
슬라이드48.JPG
슬라이드49.JPG
슬라이드50.JPG
슬라이드51.JPG
슬라이드52.JPG


슬라이드53.JPG
슬라이드54.JPG
슬라이드55.JPG
슬라이드56.JPG
슬라이드57.JPG
슬라이드58.JPG
슬라이드59.JPG
슬라이드60.JPG
슬라이드61.JPG
슬라이드62.JPG
슬라이드63.JPG
슬라이드64.JPG
슬라이드65.JPG
슬라이드66.JPG
슬라이드67.JPG
슬라이드68.JPG



------------


1

wget https://kr.object.ncloudstorage.com/ncp-script2024/lab_source.zip

unzip lab_source.zip

/root/lab_source/lab2



[root@docker1 lab2]# ls

Dockerfile



2

Docker 설치


sudo dnf config-manager --set-disabled kubernetes

dnf install -y docker-ce --allowerasing

sudo dnf -y install dnf-plugins-core

sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

docker -version

systemctl enable --now docker

systemctl status docker

systemctl start docker

systemctl enable docker


Y

Y



3

docker build -t test-image .



docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

test-image latest 3eaf3b495f1d 11 seconds ago 192MB



docker run -p 8080:80 --name test-nginx test-image


# docker run -p 8080:80 --name 컨테이너_이름 이미지_이름

브라우저에서 접속 : 8080



4

# 컨테이너 레지스트리에 이미지 넣기


# Container Registry 의 Private Endpoint 확인

d9m59u2e.kr.private-ncr.ntruss.com



9

# 도커 로그인

# access-key , secret-key 준비

# Username 는 access-key , Password: 는 secret-key


docker login xxxxxxxxx.kr.ncr.ntruss.com


Username: ncp_iam_BPAMKR2pm0TU1

Password:

Login Succeeded



10

# 태그 붙이기


docker image tag test-image xxxxxxxxxxxx.kr.ncr.ntruss.com/test-image:1.0



# 컨테이너 레지스트리에 이미지 넣기

docker push xxxxxxx.kr.ncr.ntruss.com/test-image:1.0



# 콘솔 에서 컨테이너 레지스트리에서 올라간거 확인


---------------------------------

명령툴들 설치하기


1. 네이버 클라우드에 권한이 있어야 한다.- access-key,secret-key

2. ncloud CLI 다운로드

3. ncloud configure

4. NKS 사용을 위한 인증 - ncp-iam 설치

5. kubectl 명령어 설치

6. alials 단축 명령어

7. 게임 올리기

8. pod증가하기



1

네이버 클라우드에 권한이 있어야 한다.

access-key , secret-key를 알아야 한다.



오른쪽 위 본인 이름 > 이용관리 > 계정 관리 > 인증키 관리


신규 API 인증키 생성

Access- Key ID와 Secret Key 보기 해서 노트패드에 복사해 놓기


ncp_iam_xxxxxxxxxxx

ncp_iam_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



2

ncloud CLI 다운로드


# putty로 서버 로그인

명령 서버의 공인IP 확인


# 신규버전 다운로드



wget https://www.ncloud.com/api/support/download/files/cli/CLI_1.1.26_20250918.zip

unzip CLI_1.1.26_20250918.zip

cd CLI_1.1.26_20250918/

cd cli_linux/

cp ncloud /usr/bin/

ncloud help



# 최신버전 참고 = https://cli.ncloud-docs.com/docs/guide-userguide



3

# ncloud 권한 설정 - Access-key , Secret-key 입력



ncloud configure

ncp_iam_xxxxxxxxxxx

ncp_iam_xxxxxxxxxxx

<엔터>



# 권한 있는지 확인 = 리전에 서버 리스트 확인하기

ncloud vserver getRegionList



4

# 사용을 위한 인증 = ncp-iam 설치



cd

curl -o ncp-iam-authenticator -L https://github.com/NaverCloudPlatform/ncp-iam-authenticator/releases/latest/download/ncp-iam-authenticator_linux_amd64

chmod +x ./ncp-iam-authenticator

mkdir -p $HOME/bin && cp ./ncp-iam-authenticator $HOME/bin/ncp-iam-authenticator &&

export PATH=$PATH:$HOME/bin

echo 'export PATH=$PATH:$HOME/bin' >> ~/.bash_profile

ncp-iam-authenticator help



# 참고 - 매뉴얼 - ncp-iam 설치 - mac 설치법


https://guide.ncloud-docs.com/docs/k8s-iam-auth-ncp-iam-authenticator



# clusterUuid는 콘솔에서 확인하자.



쿠버네티스 클러스터 UUID이다.

아래 명령어에 해당 UUID 를 입력한다.


ncp-iam-authenticator create-kubeconfig --region KR --clusterUuid b01xxxxxxxxxx --output kubeconfig.yaml


ncp-iam-authenticator create-kubeconfig --region KR --clusterUuid 8b45702f-9b81-4857-b178-7940877c7bd1 --output kubeconfig.yaml

ncp-iam-authenticator create-kubeconfig --region KR --clusterUuid 8b45702f-9b81-4857-b178-7940877c7bd1 --output kubeconfig.yaml


예)

ncp-iam-authenticator create-kubeconfig --region KR --clusterUuid 66e08b1e-57b6-4406-98df-c3cf47e4f6c3 --output kubeconfig.yaml



5

# kubectl 명령어 설치



curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

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



6

# alials 단축 명령어



vi ~/.bash_profile


맨 아래줄에 아래 내용 추가

o 눌러 추가한다.


alias k='kubectl --kubeconfig="/root/kubeconfig.yaml"'

alias kw='watch -d kubectl get deploy,svc,pods --kubeconfig="/root/kubeconfig.yaml"'

alias kwn='watch -d kubectl get no,deploy,svc,pods --kubeconfig="/root/kubeconfig.yaml"'



저장하고 나옴

esc 키

:wq!


source ~/.bash_profile


k get nodes


NAME STATUS ROLES AGE VERSION

agame-np-w-f514 Ready <none> 68m v1.33.4

agame-np-w-f864 Ready <none> 69m v1.33.4



# 터미널 2 - 모니터링 하기

kwn



7

모니터링하기, 웹서비스 올리기


# kube-ops-view 설치해 보자.


# 파드와 노드증가를 시각화 하여 확인하는 Kubeops view 설치

1)

# 방법 1 - git 다운로드 설치 - 80 접속



git clone https://codeberg.org/hjacobs/kube-ops-view.git

cd kube-ops-view/

k apply -k deploy



# 외부에서 kube-ops-view를 접속하기 위해서 Service Type을 LoadBalancer 로 변경한다.


k edit svc kube-ops-view


apiVersion: v1

kind: Service

metadata:

annotations:

name: kube-ops-view

spec:

....

sessionAffinity: None

type: LoadBalancer

status:



변경전

type: ClusterIP


변경후

type: LoadBalancer 로 수정. = 로드 밸런서 생성됨.

(3분 걸림)



콘솔에서 로드 밸런서 생성확인

웹 브라우저에서 실행.



2)


# 웹서버 생성



k create deployment websrv --image=nginx --port=80 --replicas=4

k expose deployment websrv --port=80 --type=LoadBalancer

k scale deployment websrv --replicas=20


cd



8


# 쿠버네티스에 게임 올리기 - deployment-2048 게임 올리기



cat <<EOF | k create -f -

apiVersion: apps/v1

kind: Deployment

metadata:

name: deployment-2048

spec:

replicas: 2

selector:

matchLabels:

app.kubernetes.io/name: app-2048

template:

metadata:

labels:

app.kubernetes.io/name: app-2048

spec:

containers:

- name: app-2048

image: alexwhen/docker-2048

ports:

- containerPort: 80

EOF

k expose deployment deployment-2048 --port=80 --type=LoadBalancer




https://brunch.co.kr/@topasvga/4208



-----------------------



cat <<EOF | k create -f -

apiVersion: apps/v1

kind: Deployment

metadata:

name: mario

labels:

app: mario

spec:

replicas: 1

selector:

matchLabels:

app: mario

template:

metadata:

labels:

app: mario

spec:

containers:

- name: mario

image: pengbai/docker-supermario

---

apiVersion: v1

kind: Service

metadata:

name: mario

spec:

selector:

app: mario

ports:

- port: 80

targetPort: 8080

protocol: TCP

type: LoadBalancer

externalTrafficPolicy: Local

EOF

k edit svc mario



(3분)


LoadBalancer


로 수정. = 로드 밸런서 생성됨.


9

Pod 수 변경하기


k scale deployment websrv --replicas=10

k scale deployment mario --replicas=10



---------------------------------------------------------------------



20



k create secret docker-registry regcred --docker-server=t4m.kr.private-ncr.ntruss.com --docker-username=ncp_iam_BPASKZeu8 --docker-password=ncp_iam_BPKSKR1Jd13D4X --docker-email=topasvag@kakao.com



21


cd

cd lab_source/

cd lab3/



[root@docker1 lab3]# vi create_deployment.yaml

apiVersion: apps/v1

kind: Deployment

metadata:

name: apache-deployment

spec:

replicas: 3

selector:

matchLabels:

app: apache

template:

metadata:

labels:

app: apache

spec:

containers:

- name: apache

image: k8s-edu00.kr.ncr.ntruss.com/image_apache:1.0

ports:

- containerPort: 80

imagePullSecrets:

- name: regcred


수정 – 퍼블릭 엔드포인트로


image: k8s-edu-1.kr.ncr.ntruss.com/test-image:1.0


k apply -f create_deployment.yaml


22

k create -f create_service.yaml


로드 밸런서로 접속.


감사합니다.



keyword
매거진의 이전글6. (온라인) 네이버 클라우드 테라폼-2025-11