1 # 기존 디폴트에 서버 생성 확인 watch -d kubectl get ns,svc,pods,deploy,rs,pods 2 cd mkdir 7 cd 7 3 # 나는 game-2048 네임스페이스로 만들고, 그곳에 서버를 재배치 하고자 한다. vi deployment.yaml # 1. 네임스페이스 생성 apiVersion: v1 kind: Namespace metadata: name: game-2048 --- # 2. 디플로이먼트 설정 apiVersion: apps/v1 kind: Deployment metadata: name: game-2048-deployment namespace: game-2048 # 변경된 네임스페이스 labels: app: 2048-game spec: replicas: 5 selector: matchLabels: app: 2048-game template: metadata: labels: app: 2048-game spec: containers: - name: 2048-container image: public.ecr.aws/l6m2t8p7/docker-2048:latest ports: - containerPort: 80 --- # 3. 서비스 설정 apiVersion: v1 kind: Service metadata: name: game-2048-service namespace: game-2048 # 변경된 네임스페이스 spec: ports: - port: 80 targetPort: 80 protocol: TCP selector: app: 2048-game type: LoadBalancer cat < game-2048.yaml # 1. 네임스페이스 생성 apiVersion: v1 kind: Namespace metadata: name: game-2048 --- # 2. 디플로이먼트 설정 apiVersion: apps/v1 kind: Deployment metadata: name: game-2048-deployment namespace: game-2048 labels: app: 2048-game spec: replicas: 5 selector: matchLabels: app: 2048-game template: metadata: labels: app: 2048-game spec: containers: - name: 2048-container image: public.ecr.aws/l6m2t8p7/docker-2048:latest ports: - containerPort: 80 --- # 3. 서비스 설정 apiVersion: v1 kind: Service metadata: name: game-2048-service namespace: game-2048 spec: type: LoadBalancer ports: - port: 80 targetPort: 80 protocol: TCP selector: app: 2048-game EOF kubectl apply -f game-2048.yaml 4 k ns game-2048 --------------------------- 5 # 아래는 참고 kubectl create namespace game-2048 6 # 특정 네임스페이스의 파드 확인 kubectl get pods -n game-2048 # 서비스 주소(LoadBalancer IP) 확인 kubectl get svc -n game-2048 7 kubectl config set-context --current --namespace=game-2048