sansae@sansaeAir15m2 k8s-lab-workspace % k apply -f statefulset.yaml
service/nginx created
statefulset.apps/web created
sansae@sansaeAir15m2 k8s-lab-workspace % k get all
NAME TYPE CLUSTER-IP READY EXTERNAL-IP STATUS PORT(S) RESTARTSAGE
service/kubernetes AGE
pod/web-0ClusterIP 10.0/.0.1 Pending<none> 0 443/TCP 3s
NAME3m13s
service/nginx-stps ClusterIP None TYPE <none> CLUSTER-IP EXTERNAL-IP80/TCP PORT(S) AGE
service/kubernetes 2m47s
NAME ClusterIP 10.0.0.1 <none> READY 443/TCPAGE
statefulset.apps/web 29s
service/nginx3/3 2m47s
sansae@sansaeAir15m2 k8s-lab-workspace % k ClusterIPget statefulset
NAME None READY AGE
web 3/3 <none> 48m
sansae@sansaeAir15m2 k8s-lab-workspace % k 80/TCPdescribe statefulset web 3s
NAMEName: web
Namespace: READY AGE
statefulset.apps/web 0/3default
CreationTimestamp: Sat, 09 Mar 3s
sansae@sansaeAir15m2 k8s-lab-workspace % k get all2024 21:52:14 +0900
Selector:
NAMEapp=nginx
Labels: READY STATUS <none>
Annotations: RESTARTS AGE
pod/web-0 1/1 <none>
Replicas: Running 0 3 desired | 3 total
Update 2m47s
pod/web-1Strategy: 1/1RollingUpdate
Partition: Running 0 0
Pods Status: 117s
pod/web-2 3 Running 1/1 0 Waiting / 0 RunningSucceeded / 0 Failed
Pod Template:
Labels: app=nginx
97s
NAMEContainers:
nginx:
Image: registry.k8s.io/nginx-slim:0.8
TYPE Port: CLUSTER-IP EXTERNAL-IP80/TCP
PORT(S) Host Port: AGE
service/kubernetes ClusterIP0/TCP
10.0.0.1 Environment: <none>
Mounts:
443/TCP 3m13s
service/usr/share/nginx/html from www (rw)
Volumes: ClusterIP<none>
Volume Claims:
Name: None <none>www
StorageClass: azurefile
80/TCP Labels: 2m47s
NAME <none>
Annotations: <none>
Capacity: READY1Gi
AGE
statefulset.apps/web 3/3 Access Modes: [ReadWriteOnce]
Events:
Type 2m47s
sansae@sansaeAir15m2 k8s-lab-workspace % k get statefulset
NAMEReason READY AGE
web Age 3/3From 48m
sansae@sansaeAir15m2 k8s-lab-workspace % k describe statefulset web
Name: Message
---- ------ web
Namespace: default
CreationTimestamp: Sat, 09 Mar 2024 21:52:14 +0900
Selector:---- ---- app=nginx
Labels: -------
Normal SuccessfulCreate 48m <none>
Annotations:statefulset-controller create Claim www-web-0 Pod web-0 in <none>
Replicas:StatefulSet web success
Normal SuccessfulCreate 48m 3statefulset-controller desired |create 3 total
Update Strategy: RollingUpdatePod web-0 in StatefulSet web successful
Partition:Normal SuccessfulCreate 47m statefulset-controller 0
Pods Status:create Claim www-web-1 Pod web-1 in StatefulSet web 3success
Running /Normal 0 WaitingSuccessfulCreate / 047m Succeeded / 0 Failed
Pod Template:
Labels: app=nginx
Containers:
nginx:
Image: registry.k8s.io/nginx-slim:0.8
Port: 80/TCP
Host Port: 0/TCP
Environment: <none>
Mounts:
/usr/share/nginx/html from www (rw)
Volumes: <none>
Volume Claims:
Name: www
StorageClass: azurefile
Labels: <none>
Annotations: <none>
Capacity: 1Gi
Access Modes: [ReadWriteOnce]
Events:
Type Reason Age From Message
---- ------ ---- ---- statefulset-controller create Pod web-1 in StatefulSet web successful
Normal SuccessfulCreate 47m statefulset-controller create Claim www-web-2 Pod web-2 in StatefulSet web success
Normal SuccessfulCreate 47m statefulset-controller create Pod web-2 in StatefulSet web successful
# Headless Service확인
sansae@sansaeAir15m2 k8s-lab-workspace % k exec -it util -- bash
root@util:/# curl nginx-stps
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.11.1</center>
</body>
</html>
root@util:/# nslookup nginx-stps
Server: 10.0.0.10
Address: 10.0.0.10#53
Name: nginx-stps.default.svc.cluster.local
Address: 10.244.0.106
Name: nginx-stps.default.svc.cluster.local
Address: 10.244.0.107
Name: nginx-stps.default.svc.cluster.local
Address: 10.244.0.108
root@util:/# exit
sansae@sansaeAir15m2 k8s-lab-workspace % k get pod -o wide
NAME READY STATUS RESTARTS AGE IP -------
Normal SuccessfulCreateNODE 48m statefulset-controller create Claim www-web-0 Pod web-0 in StatefulSet web success
Normal SuccessfulCreate 48m statefulset-controller create Pod web-0 in StatefulSet web successful
NOMINATED NODE Normal SuccessfulCreateREADINESS GATES
util 47m statefulset-controller1/1 create Claim www-web-1 PodRunning web-1 in StatefulSet0 web success
Normal SuccessfulCreate 47m 14m statefulset-controller create Pod web-1 in StatefulSet web successful
Normal SuccessfulCreate 47m statefulset-controller create Claim www-web-2 Pod web-2 in StatefulSet web success
Normal SuccessfulCreate 47m statefulset-controller create Pod web-2 in StatefulSet web successful |