この記事は、Windows で Docker Desktop その2 の続きです。
Windows マシンで、git をインストールします。
こちらの記事を参考にしました。
https://qiita.com/takeru-hirai/items/4fbe6593d42f9a844b1c
こちらも参考にした方がいいかもしれません。
https://learn.microsoft.com/ja-jp/devops/develop/git/install-and-set-up-git
1つの Pod を作成してみました。
PS C:\Users\xxx\TKB\pods> kubectl apply -f pod.yml
pod/hello-pod created
PS C:\Users\xxx\TKB\pods> kubectl get pods
NAME READY STATUS RESTARTS AGE
hello-pod 0/1 ContainerCreating 0 9s
PS C:\Users\xxx\TKB\pods> kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-pod 1/1 Running 0 18s 10.244.2.2 desktop-worker2 <none> <none>
このコマンドを実行してみました。
PS C:\Users\xxx\TKB\pods> kubectl get pods hello-pod -o yaml
apiVersion: v1
kind: Pod
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"labels":{"version":"v1","zone":"prod"},"name":"hello-pod","namespace":"default"},"spec":{"containers":[{"image":"nigelpoulton/k8sbook:1.0","name":"hello-ctr","ports":[{"containerPort":8080}],"resources":{"limits":{"cpu":0.5,"memory":"256Mi"}}}]}}
creationTimestamp: "2025-06-15T00:31:51Z"
labels:
version: v1
zone: prod
name: hello-pod
namespace: default
resourceVersion: "88215"
uid: ea3e7662-d47a-4345-8416-8a169cd324de
spec:
containers:
- image: nigelpoulton/k8sbook:1.0
imagePullPolicy: IfNotPresent
name: hello-ctr
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 500m
memory: 256Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-rf99x
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
nodeName: desktop-worker2
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-rf99x
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: "2025-06-15T00:32:04Z"
status: "True"
type: PodReadyToStartContainers
- lastProbeTime: null
lastTransitionTime: "2025-06-15T00:31:51Z"
status: "True"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2025-06-15T00:32:04Z"
status: "True"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2025-06-15T00:32:04Z"
status: "True"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2025-06-15T00:31:51Z"
status: "True"
type: PodScheduled
containerStatuses:
- containerID: containerd://2715958e1b525eff622cc4afdea695b7850ec1ec76811587e51b99aa05d4fa18
image: docker.io/nigelpoulton/k8sbook:1.0
imageID: docker.io/nigelpoulton/k8sbook@sha256:2209995b11148d3bdf962a9364946cec57d088f831521e0a023085a741a6a1e2
lastState: {}
name: hello-ctr
ready: true
restartCount: 0
started: true
state:
running:
startedAt: "2025-06-15T00:32:04Z"
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-rf99x
readOnly: true
recursiveReadOnly: Disabled
hostIP: 172.18.0.4
hostIPs:
- ip: 172.18.0.4
- ip: fc00:f853:ccd:e793::4
phase: Running
podIP: 10.244.2.2
podIPs:
- ip: 10.244.2.2
qosClass: Guaranteed
startTime: "2025-06-15T00:31:51Z"
describe コマンドを実行してみました。
PS C:\Users\xxx\TKB\pods> kubectl describe pod hello-pod
Name: hello-pod
Namespace: default
Priority: 0
Service Account: default
Node: desktop-worker2/172.18.0.4
Start Time: Sun, 15 Jun 2025 09:31:51 +0900
Labels: version=v1
zone=prod
Annotations: <none>
Status: Running
IP: 10.244.2.2
IPs:
IP: 10.244.2.2
Containers:
hello-ctr:
Container ID: containerd://2715958e1b525eff622cc4afdea695b7850ec1ec76811587e51b99aa05d4fa18
Image: nigelpoulton/k8sbook:1.0
Image ID: docker.io/nigelpoulton/k8sbook@sha256:2209995b11148d3bdf962a9364946cec57d088f831521e0a023085a741a6a1e2
Port: 8080/TCP
Host Port: 0/TCP
State: Running
Started: Sun, 15 Jun 2025 09:32:04 +0900
Ready: True
Restart Count: 0
Limits:
cpu: 500m
memory: 256Mi
Requests:
cpu: 500m
memory: 256Mi
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-rf99x (ro)
Conditions:
Type Status
PodReadyToStartContainers True
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kube-api-access-rf99x:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: Guaranteed
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 37m default-scheduler Successfully assigned default/hello-pod to desktop-worker2
Normal Pulling 37m kubelet Pulling image "nigelpoulton/k8sbook:1.0"
Normal Pulled 37m kubelet Successfully pulled image "nigelpoulton/k8sbook:1.0" in 12.286s (12.286s including waiting). Image size: 63083036 bytes.
Normal Created 37m kubelet Created container hello-ctr
Normal Started 37m kubelet Started container hello-ctr
Windows で Docker Desktop その4に続く。
参考文献
Poulton, N. (2025). The kubernetes book (2025 ed.). Nigel Poulton.