DevOps_k8s

[CKAD/Lab] - namespace

최선을 다하자! 2023. 9. 24. 13:07
 

namespace

 

 예제 1)

Create a POD in the finance namespace.

Use the spec given below.


Name: redis
Image name: redis

 

$ kubectl get pods --namespace=finance 

$ kubectl get pods -n=finance

=> 네임스페이스 finance 내의 pod를 확인하는 커맨드 

 

$ kubectl run redis --image=redis --namespace=finance

=> 네임스페이스 finance 내에 redis 라는 이름으로 redis를 생성하는 커맨드

 

 

 

예제 2) 

Access the Blue web application using the link above your terminal!!


From the UI you can ping other services

 

 

$ kubectl get ns 

=> 네임스페이스 확인하기

 

$ kubectl get pods --all-namespaces

$ kubectl get pods -A

=> 네임스페이스 내의 모든 파드를 확인하기

kubectl get pods --all-namespaces
NAMESPACE     NAME                               READY   STATUS             RESTARTS   AGE
default       myapp-pod                          1/1     Running            0          10d
kube-system   coredns-5d78c9869d-smgl9           1/1     Running            0          10d
kube-system   etcd-minikube                      1/1     Running            0          10d
kube-system   kube-apiserver-minikube            1/1     Running            0          10d
kube-system   kube-controller-manager-minikube   1/1     Running            0          10d
kube-system   kube-proxy-wl26h                   1/1     Running            0          10d
kube-system   kube-scheduler-minikube            1/1     Running            0          10d
kube-system   storage-provisioner                1/1     Running            0          10d
prod          nginx                              1/1     Running            0          76m
prod          nginx-77b4fdf86c-4svbg             0/1     ImagePullBackOff   0          64m
prod          nginx-77b4fdf86c-8hmkd             0/1     ImagePullBackOff   0          64m
prod          nginx-77b4fdf86c-ffggl             0/1     ImagePullBackOff   0          64m
prod          nginx-77b4fdf86c-k4hsn             0/1     ErrImagePull       0          64m
prod          nginx-pod                          1/1     Running            0          84m
prod          redis                              0/1     ImagePullBackOff   0          58m

 

$ kubectl get pods --namespace

=> 네임스페이스 내에 존재하는 pod를 확인하기 

 

$ kubectl get pods --namespace=marketing blue -o wide

-> 네임스페이스 marketing에 존재하는 pod를 확인하고, blue 파드의 상세정보를 확인하기

NAME   READY   STATUS    RESTARTS   AGE   IP           NODE           NOMINATED NODE   READINESS GATES
blue   1/1     Running   0          21m   10.42.0.15   controlplane   <none>           <none>

=> IP를 확인하고 ping 테스트를 한다.

 

 

 

 

예제3)

What DNS name should the Blue application use to access the database db-service in its own namespace - marketing?


You can try it in the web application UI. Use port 6379.

$ kubectl get svc -n=marketing

NAME           TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
blue-service   NodePort   10.43.134.31    <none>        8080:30082/TCP   2m35s
db-service     NodePort   10.43.233.164   <none>        6379:31313/TCP   2m35s

db-service

 

 

 

예제4)

What DNS name should the Blue application use to access the database db-service in the dev namespace?


You can try it in the web application UI. Use port 6379.