IT 기술/k8s

[cka] namespace

Geunny 2024. 5. 28. 23:28
반응형

1. How many Namespaces exist on the system?

 

$ controlplane ~ ➜  k get ns
NAME              STATUS   AGE
kube-system       Active   6m39s
kube-public       Active   6m39s
kube-node-lease   Active   6m39s
default           Active   6m39s
finance           Active   31s
marketing         Active   31s
dev               Active   31s
prod              Active   31s
manufacturing     Active   31s
research          Active   31s

 

answer : 10

 

2. How many pods exist in the research namespace?

 

$ controlplane ~ ➜  k get pods -n research
NAME    READY   STATUS      RESTARTS      AGE
dna-1   0/1     Completed   3 (39s ago)   60s
dna-2   0/1     Completed   3 (40s ago)   60s

 

answer : 2

 

3. Create a POD in the finance namespace. Use the spec given below.
Name: redis
Image name: redis

 

$ controlplane ~ ✖ k run redis --image redis -n finance
pod/redis created

 

 

4. Which namespace has the blue pod in it?

controlplane ~ ➜  k get pods -A
NAMESPACE       NAME                                      READY   STATUS             RESTARTS       AGE
marketing       blue                                      1/1     Running            0              5m1s

 

answer : marketing

 

6.  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.

 

- 동일한 namespace 에 존재하는 db-service 라는 데이터베이스에 접근시에는 해당 서비스명으로 직접 붙을수 있다.

answer : db-service

 

 

7. 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.

 

- namespace 가 다른 pods 에 접근하려면 FQDN (fully Qualified Domain Name) 으로 접근해야 한다.

https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-sethostnameasfqdn-field

 

DNS for Services and Pods

Your workload can discover Services within your cluster using DNS; this page explains how that works.

kubernetes.io

 

answer : db-service.dev.svc.cluster.local (or db-service.dev)