728x90
쿠버네티스 볼륨(Volume)
사용 사능한 볼륨 목록
- emptyDir
임시로 데이터를 저장하는 빈 볼륨(디렉터리) - gitRepo
내부적으로 emptyDir 기능을 이용하여 초기에 git 리포지토리의 내용을 채워서 제공하는 볼륨. 더 이상 사용되지 않음(Deprecated) - hostPath
쿠버네티스 클러스터 노드(호스트)의 파일 시스템을 제공하는 볼륨 - 네트워크 스토리지 볼륨
nfs, cinder, cephfs, iscsi, glusterfs, quobyte, rbd, flexVolume, vsphereVolume, photonPersistentDisk - 클라우드 스토리지 볼륨
gcePersistentDisk(GCE Persistent Disk), awsElasticBlockStore(AWS EBS Volume), azureDist(MS Azure Disk Volume) - 정적/동적 프로비저닝 볼륨
persistentVolumeClaim - 특수 유형 볼륨
configMap, secret, downwardAPI
emptyDir 볼륨
emptyDir 볼륨 생성
emptyDir1.yaml 파일 작성
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp-rs-fortune
spec:
replicas: 1
selector:
matchLabels:
app: myapp-rs-fortune
template:
metadata:
labels:
app: myapp-rs-fortune
spec:
containers:
- name: web-server
image: nginx:alpine
volumeMounts:
- name: web-fortune
mountPath: /usr/share/nginx/html
readOnly: true
ports:
- containerPort: 80
protocol: TCP
- name: html-generator
image: ghcr.io/c1t1d0s7/fortune
volumeMounts:
- name: web-fortune
mountPath: /var/htdocs
volumes:
- name: web-fortune
emptyDir: {}
emptyDir1-svc.yaml 파일 작성
apiVersion: v1
kind: Service
metadata:
name: myapp-svc-fortune
spec:
selector:
app: myapp-rs-fortune
ports:
- port: 80
targetPort: 80
kubectl create -f emptyDir1.yaml -f emptyDir1-svc.yaml
kubectl get all
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/myapp-rs-fortune-szsvx 2/2 Running 0 5m12s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.233.0.1 <none> 443/TCP 2d22h
service/myapp-svc-fortune ClusterIP 10.233.18.172 <none> 80/TCP 15m
NAME DESIRED CURRENT READY AGE
replicaset.apps/myapp-rs-fortune 1 1 1 5m12s
$ curl 10.233.18.172
Delay not, Caesar. Read it instantly.
-- Shakespeare, "Julius Caesar" 3,1
Here is a letter, read it at your leisure.
-- Shakespeare, "Merchant of Venice" 5,1
[Quoted in "VMS Internals and Data Structures", V4.4, when
referring to I/O system services.]
kubectl describe pods myapp-rs-fortune-szsvx
$ kubectl describe pods myapp-rs-fortune-szsvx
Name: myapp-rs-fortune-szsvx
Namespace: default
Priority: 0
Node: kube-node2/192.168.56.22
Start Time: Mon, 10 Oct 2022 21:15:07 +0900
Labels: app=myapp-rs-fortune
Annotations: cni.projectcalico.org/containerID: d283c73f18888dd7e6d6f662d21545636a67f4b13672ab4f83d5340388969f59
cni.projectcalico.org/podIP: 10.233.74.12/32
cni.projectcalico.org/podIPs: 10.233.74.12/32
Status: Running
IP: 10.233.74.12
IPs:
IP: 10.233.74.12
Controlled By: ReplicaSet/myapp-rs-fortune
Containers:
web-server:
Container ID: docker://3eb112432b707a4fb08e7f99106d2f4e9458ece426c59082d4b1a9242e290561
Image: nginx:alpine
Image ID: docker-pullable://nginx@sha256:b87c350e6c69e0dc7069093dcda226c4430f3836682af4f649f2af9e9b5f1c74
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Mon, 10 Oct 2022 21:15:08 +0900
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/usr/share/nginx/html from web-fortune (ro)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-zqldt (ro)
html-generator:
Container ID: docker://0e4148c711512bb83e98d2edf5f0256e31cf76d9ac92290ca52222d5c2c8dabc
Image: ghcr.io/c1t1d0s7/fortune
Image ID: docker-pullable://ghcr.io/c1t1d0s7/fortune@sha256:7f2d656f90921b2cb94faeac0798fe8bca94e91d85fb8c1d335866b16c581eec
Port: <none>
Host Port: <none>
State: Running
Started: Mon, 10 Oct 2022 21:15:21 +0900
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/htdocs from web-fortune (rw)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-zqldt (ro)
...
kubectl exec myapp-rs-fortune-szsvx -c web-server -- cat /usr/share/nginx/html/index.html
$ kubectl exec myapp-rs-fortune-szsvx -c web-server -- cat /usr/share/nginx/html/index.html
You will live a long, healthy, happy life and make bags of money.
참고URL
- 임시 볼륨 : https://kubernetes.io/ko/docs/concepts/storage/ephemeral-volumes/
- MSA School : https://www.msaschool.io/operation/operation/operation-two/
728x90
'리눅스' 카테고리의 다른 글
[kubernetes] 쿠버네티스 볼륨(Volume) - 정적 프로비저닝(Static Provisioning) / nfs (0) | 2022.10.12 |
---|---|
[kubernetes] 쿠버네티스 볼륨(Volume) - hostPath 볼륨 (0) | 2022.10.10 |
우분투에서 NFS Server를 설치하고 NFS 볼륨을 마운트하는 방법 (0) | 2022.10.07 |
[kubernetes] 쿠버네티스 워크로드 - 워크로드 리소스 (0) | 2022.10.04 |
쿠버네티스 네임스페이스를 생성하고 확인하고 삭제하는 방법(namespaces) (0) | 2022.10.03 |