Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- Etherchannel
- Redistribute
- rip
- GLBP
- stp
- ospfv3
- Inter VLAN
- Vlan
- tunneling
- DHCP
- OSI 7 layer
- 명령어
- ipv6
- eigrp
- Chrony
- ACL
- crontab
- 헤더
- ripng
- NAT
- eigrpv2
- vrrp
- 장비
- 스위치
- OSPF
- 라우터
- CKA
Archives
- Today
- Total
Net Eng
[CKA] - NodePort 서비스 생성 본문
[선수 작업]
kubectl config set-context k8s --user=kubernetes-admin --cluster=kubernetes
kubectl apply -f - <<EOF
kind: Deployment
apiVersion: apps/v1
metadata:
name: nginx
spec:
selector:
matchLabels:
app: webui
replicas: 2
template:
metadata:
labels:
app: webui
spec:
containers:
- name: web-container
image: nginx
ports:
- containerPort: 80
EOF
[문제]
Create the service as type NodePort with the port 32767 for the nginx pod with the pod selector app: webui.
작업 클러스터: k8s
[풀이]
kubectl config use-context k8s
* k8s 클러스터 사용
kubectl get pods -l app=webui --show-labels
* app:webui 레이블을 가진 Pod 확인
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
type: NodePort
selector:
app: webui
ports:
- port: 80
targetPort: 80
nodePort: 32767
* yaml 파일 생성
kubectl apply -f myservice.yaml
* yaml 파일 실행
curl node01:32767
* 실행 확인

[참고]
Service
Expose an application running in your cluster behind a single outward-facing endpoint, even when the workload is split across multiple backends.
kubernetes.io
'Cloud > Kubernetes' 카테고리의 다른 글
[CKA] - Secret 운영 (0) | 2024.01.22 |
---|---|
[CKA] - ConfigMap 운영 (1) | 2024.01.22 |
[CKA] - Init Container를 포함한 Pod 운영 (1) | 2024.01.22 |
[CKA] - CPU 사용량이 높은 파드 검색 (1) | 2024.01.21 |
[CKA] - Pod Log 추출 (0) | 2024.01.21 |