https://sunsh0602@github.com/sunsh0602/study.git
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_ns.yaml
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_configmap.yaml
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_hpa.yaml
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_secret.yaml
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_svc.yaml
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_pvc.yaml
kubectl apply -f ./k8s-study/sprint1_anotherclass-123_deploy.yaml
1~4. local 동작 확인
// 1번 API - 파일 생성
curl http://192.168.56.30:31231/create-file-pod
curl http://192.168.56.30:31231/create-file-pv
// 2번 - Container 임시 폴더 확인 (안 생김)
[root@k8s-master ~]# kubectl exec -n anotherclass-123 -it <pod-name> -- ls /usr/src/myapp/tmp
// 2번 - Container 영구저장 폴더 확인
[root@k8s-master ~]# kubectl exec -n anotherclass-123 -it <pod-name> -- ls /usr/src/myapp/files/dev
// 2번 - master node 폴더 확인
[root@k8s-master ~]# ls -al /root/k8s-local-volume/1231
// 3번 - Pod 삭제
[root@k8s-master ~]# kubectl delete -n anotherclass-123 pod <pod-name>
// 4번 API - 파일 조회
curl http://192.168.56.30:31231/list-file-pod
curl http://192.168.56.30:31231/list-file-pv
5. hostPath 동작 확인 - Deployment 수정 후 [1~4] 실행
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: anotherclass-123
name: api-tester-1231
spec:
template:
spec:
nodeSelector:
kubernetes.io/hostname: k8s-master
containers:
- name: api-tester-1231
volumeMounts:
- name: files
mountPath: /usr/src/myapp/files/dev
- name: secret-datasource
mountPath: /usr/src/myapp/datasource
volumes:
- name: files
persistentVolumeClaim: // 삭제
claimName: api-tester-1231-files // 삭제
// 아래 hostPath 추가
hostPath: // 추가
path: /root/k8s-local-volume/1231 // 추가
- name: secret-datasource
secret:
secretName: api-tester-1231-postgresql
kubectl edit deployment api-tester-1231 -n anotherclass-123
1-3. 레퍼런스
▶ nodeAffinity
https://kubernetes.io/ko/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity/
'Kubernetes > Study' 카테고리의 다른 글
[K8s-1pro] Rolling update 테스트 시나리오 (0) | 2025.06.20 |
---|---|
[K8s] HPA 동작 (0) | 2025.06.20 |
[K8s] Pod 생성 및 Probe (2) | 2025.06.20 |
[K8s] 쿠버네티스에서 pod들이 서로 다른 가상 L2에 있는데 통신 되는 이유? (비오버레이 네트워크) (0) | 2025.06.19 |
[K8s] 쿠버네티스에서 pod들이 서로 다른 가상 L2에 있는데 통신 되는 이유? (오버레이 네트워크) (0) | 2025.06.19 |