본문 바로가기
Compute/kubernetis

[CKA] 04. kubectl describe 명령어 사용 문제

by 조청유곽 2025. 1. 11.
반응형

01. 환경 변수를 가진 pod를 생성하고 pod 내부에서 환경 변수를 확인한다. 

 

[solve]

[root@k8s-master ~]# vi 4-test.yaml

apiVersion: v1
kind: Pod
metadata:
  name: env-pod
spec:
  containers:
  - name: envar-demo-container
    image: gcr.io/google-samples/hello-app:2.0
    env:
    - name: var1
      value: value1

[root@k8s-master ~]# kubectl apply -f 4-test.yaml 
pod/env-pod created
[root@k8s-master ~]# 
[root@k8s-master ~]# kubectl describe pods env-pod 
Name:             env-pod
Namespace:        default
Priority:         0
Service Account:  default
Node:             k8s-node2/192.168.56.32
Start Time:       Thu, 26 Dec 2024 23:48:30 +0900
Labels:           <none>
Annotations:      cni.projectcalico.org/containerID: 010732ce5cb1f61a0b8328942f42159bb7a0df3e0b246627b3a15eb561cd6a35
                  cni.projectcalico.org/podIP: 20.96.169.133/32
                  cni.projectcalico.org/podIPs: 20.96.169.133/32
Status:           Running
IP:               20.96.169.133
IPs:
  IP:  20.96.169.133
Containers:
  envar-demo-container:
    Container ID:   containerd://74fbbd8c6eeb495e5c43e56d640f09e29953770254386b7999f10eafe81948f7
    Image:          gcr.io/google-samples/hello-app:2.0
    Image ID:       gcr.io/google-samples/hello-app@sha256:b510f29de2dfd80b88f7cd569db177a514117081bc8825eb64e423bd3db0fe64
    Port:           <none>
    Host Port:      <none>
    State:          Running
      Started:      Thu, 26 Dec 2024 23:48:39 +0900
    Ready:          True
    Restart Count:  0
    Environment:
      var1:  value1
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-wgpvm (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  kube-api-access-wgpvm:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  96s   default-scheduler  Successfully assigned default/env-pod to k8s-node2
  Normal  Pulling    95s   kubelet            Pulling image "gcr.io/google-samples/hello-app:2.0"
  Normal  Pulled     87s   kubelet            Successfully pulled image "gcr.io/google-samples/hello-app:2.0" in 8.28254355s (8.282549476s including waiting)
  Normal  Created    87s   kubelet            Created container envar-demo-container
  Normal  Started    87s   kubelet            Started container envar-demo-container
[root@k8s-master ~]#

 

 

** Kubernetes Pod의 Environment Variable 이란??

Kubernetes Pod의 **Environment Variable(환경 변수)**는 컨테이너에 실행 시점의 환경 설정값을 제공한다. 환경 변수는 컨테이너 내부에서 애플리케이션이 동작하는 데 필요한 설정값이나 메타데이터를 전달하는 중요한 도구이다.

 

eg) 


 

반응형