STUDY/Data Engineering

[kodekloud] 01 Core Concepts : Imperative-Commands 풀이

wonpick 2023. 1. 21. 20:10
Q1. Deploy a pod named nginx-pod using the nginx:alpine image.                                                                                         
 k run nginx-pod --image=nginx:alpine

Q2. Deploy a redis pod using the redis:alpine image with the labels set to tier=db.                                                             
k run redis --image=redis:alpine --labels=tier=db

Q3. Create a service redis-service to expose the redis application within the cluster on port 6379.                                 
명령어 예시 공식문서
kubectl expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP|SCTP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]
k expose pods redis --port=6379 --name=redis-service

[공식문서] 쿠버네티스 서비스 객체로 클러스터에 접근하기 

# service 정보 표시하기 
kubectl describe services  redis-service
'''서비스 생성시 포트를 6379로 했어야했는데 6370으로 잘못침..'''

삭제하고 재생성

Q4. Create a deployment named webapp using the image kodekloud/webapp-color with 3 replicas.                              
k create deployment webapp --image=kodekloud/webapp-color --replicas=3

 

Q5. Create a new pod called custom-nginx using the nginx image and expose it on container port 8080.                      
k run custom-nginx --image=nginx --port=8080

Q6.Create a new namespace called dev-ns. Use imperative commands.

Q7. Create a new deployment called redis-deploy in the dev-ns namespace with the redis image. It should               have 2 replicas                                                                                                                                                                           
k create deployment redis-deploy --namespace=dev-ns --image=rdis --replicas=2

Q8. Create a pod called httpd using the image httpd:alpine in the default namespace. Next, create a service of type    ClusterIP by the same name (httpd). The target port for the service should be 80.                                                        
k run httpd --image=httpd:alpine --port=80 --expose