v2
nano go-http-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: http-go # 포드의 이름
spec:
containers:
- name: http-go # 컨테이너의 이름
image: gasbugs/http-go
ports:
- containerPort: 8080
imkunyoung@master-1:~/yaml$ kubectl create -f go-http-pod.yaml
pod/http-go created
imkunyoung@master-1:~/yaml$ kubectl get pods
NAME READY STATUS RESTARTS AGE
http-go 1/1 Running 0 10s
static-web-master-1 1/1 Running 0 3m11s
imkunyoung@master-1:~/yaml$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
http-go 1/1 Running 0 33s 10.0.1.12 worker-3 <none> <none>
static-web-master-1 1/1 Running 0 3m34s 10.0.0.106 master-1 <none> <none>
imkunyoung@master-1:~/yaml$ kubectl get pod http-go -o yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2023-07-31T23:53:12Z"
name: http-go
namespace: default
resourceVersion: "3625070"
uid: c13e3dd9-9bee-48a5-b031-a41aec15542c
spec:
containers:
- image: gasbugs/http-go
imagePullPolicy: Always
name: http-go
ports:
- containerPort: 8080
protocol: TCP
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-dq6k9
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: worker-3
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: kube-api-access-dq6k9
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2023-07-31T23:53:12Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2023-07-31T23:53:14Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2023-07-31T23:53:14Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2023-07-31T23:53:12Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: containerd://51c91f3016763dd6093cadccb1adc71746631bc0abf5ea1458b2e0b2dc6886d5
image: docker.io/gasbugs/http-go:latest
imageID: docker.io/gasbugs/http-go@sha256:5cf243f818caf7a750761cfe2ff822a284d6eb459356318d3f0bd4b1efe141d9
lastState: {}
name: http-go
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2023-07-31T23:53:14Z"
hostIP: 10.138.0.5
phase: Running
podIP: 10.0.1.12
podIPs:
- ip: 10.0.1.12
qosClass: BestEffort
startTime: "2023-07-31T23:53:12Z"
imkunyoung@master-1:~/yaml$ kubectl describe pods http-go
Name: http-go
Namespace: default
Priority: 0
Service Account: default
Node: worker-3/10.138.0.5
Start Time: Mon, 31 Jul 2023 23:53:12 +0000
Labels: <none>
Annotations: <none>
Status: Running
IP: 10.0.1.12
IPs:
IP: 10.0.1.12
Containers:
http-go:
Container ID: containerd://51c91f3016763dd6093cadccb1adc71746631bc0abf5ea1458b2e0b2dc6886d5
Image: gasbugs/http-go
Image ID: docker.io/gasbugs/http-go@sha256:5cf243f818caf7a750761cfe2ff822a284d6eb459356318d3f0bd4b1efe141d9
Port: 8080/TCP
Host Port: 0/TCP
State: Running
Started: Mon, 31 Jul 2023 23:53:14 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-dq6k9 (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-dq6k9:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 118s default-scheduler Successfully assigned default/http-go to worker-3
Normal Pulling 117s kubelet Pulling image "gasbugs/http-go"
Normal Pulled 116s kubelet Successfully pulled image "gasbugs/http-go" in 575.414659ms (575.426579ms including waiting)
Normal Created 116s kubelet Created container http-go
Normal Started 116s kubelet Started container http-go
imkunyoung@master-1:~/yaml$ kubectl delete -f go-http-pod.yaml
pod "http-go" deleted
imkunyoung@master-1:~/yaml$ kubectl logs http-go
imkunyoung@master-1:~/yaml$ kubectl annotate pod http-go key=hi
pod/http-go annotate
imkunyoung@master-1:~/yaml$ kubectl get pods http-go -o yaml
apiVersion: v1
kind: Pod
metadata:
annotations:
key: hi
imkunyoung@master-1:~/yaml$ kubectl delete pod --all
pod "http-go" deleted
pod "static-web-master-1" deleted
imkunyoung@master-1:~/yaml$ kubectl get ppods
error: the server doesn't have a resource type "ppods"
imkunyoung@master-1:~/yaml$ kubectl get pods
NAME READY STATUS RESTARTS AGE
static-web-master-1 0/1 Pending 0 7s
v1
go-http-pod.yaml
mkdir yaml
cd yaml
touch go-http-pod.yaml
vim go-http-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: http-go
spec:
containers:
- name: http-go
image: gasbugs/http-go
ports:
- containerPort: 8080
kubectl create -f go-http-pod.yaml
kubectl get pods
watch kubectl get pods
kubectl get pod http-go -o yaml
kubectl logs http-go
kubectl delete -f go-http-pod.yaml
kubectl annotate pod http-go test1234=test1234
kubectl delete pod --all
kubectl delete pod http-go