이번엔 Service 에 대해 정리하고자 한다.
1. 정의
- Pod 들을 안정적인 네트워크 엔드포인트로 묶어주는 오브젝트
> Pod 집합 앞에 놓는 고정된 접근 지점
2. 특징
- Pod 들의 고정 DNS / IP 제공
- Pod 라벨 셀렉터로 트래픽 라우팅
- 로드밸런싱
- 서비스 디스커버리 제공
3. 관련 문제 (KodeKloud 에서 제공하는 샘플 문제를 정리)
- How many Services exist on the system?
kubectl get service
- How many labels are configured on the kubernetes service?
kubectl describe service kubernetes
- How many Deployments exist on the system now?
kubectl get deployment
- Create a new service to access the web application using the service-definition-1.yaml file.
> Name: webapp-service / Type: NodePort / targetPort: 8080 / port: 8080 / nodePort: 30080 / selector: name: simple-webapp
apiVersion: v1
kind: Service
metadata:
name: webapp-service
namespace: default
spec:
ports:
- nodePort: 30080
port: 8080
targetPort: 8080
selector:
name: simple-webapp
type: NodePort
kubectl apply -f service-definition-1.yaml
- Create a service named redis-service to expose the existing redis pod within the cluster on port 6379.
kubectl expose pod redis --port=6379 --name=redis-service --type=ClusterIP
- Create a pod named httpd using the image httpd:alpine in the default namespace. Then, create a service of type ClusterIP with the same name (httpd) that exposes the pod on port 80.
kubectl run httpd --image=httpd:alpine --port=80 --expose
- Use kubectl explain with the --recursive flag to explore the service.spec.ports structure. Looking at the recursive output, which of these fields is not available under service.spec.ports?
kubectl explain service.spec.ports —recursive
4. 출처
'IT > Kubernetes' 카테고리의 다른 글
| [CKA] HPA(Horizontal Pod Autoscaler) 란? (0) | 2025.11.24 |
|---|---|
| [CKA] Multi Container 란? (0) | 2025.11.24 |
| [CKA] NetworkPolicy 란? (0) | 2025.11.22 |
| [CKA] PV(PersistentVolume) 란? (0) | 2025.11.22 |
| [CKA] StorageClass 란? (0) | 2025.11.21 |