11. スモークテスト
作成したKubernetesクラスタの動作確認を行います。
データの暗号化
Secretを作成します。
kubectl create secret generic kubernetes-the-hard-way --from-literal="mykey=mydata"
etcdに保存されている秘密情報の16進ダンプを出力し、データが暗号化されていることを確認します。
ssh nob@kube-c01 "etcdctl get /registry/secrets/default/kubernetes-the-hard-way | hexdump -C"
$ ssh nob@kube-c01 "etcdctl get /registry/secrets/default/kubernetes-the-hard-way | hexdump -C"
00000000 2f 72 65 67 69 73 74 72 79 2f 73 65 63 72 65 74 |/registry/secret|
00000010 73 2f 64 65 66 61 75 6c 74 2f 6b 75 62 65 72 6e |s/default/kubern|
00000020 65 74 65 73 2d 74 68 65 2d 68 61 72 64 2d 77 61 |etes-the-hard-wa|
00000030 79 0a 6b 38 73 3a 65 6e 63 3a 61 65 73 63 62 63 |y.k8s:enc:aescbc|
00000040 3a 76 31 3a 6b 65 79 31 3a 15 21 b6 53 93 72 01 |:v1:key1:.!.S.r.|
00000050 c9 bc 8b bf 75 1e 35 f5 80 99 fc a5 69 98 ad 67 |....u.5.....i..g|
00000060 81 ec 22 0d 73 26 b0 d8 b4 ec a2 a0 47 89 da 5c |..".s&......G..\|
00000070 3e 26 1b 7b 9b e9 ce 50 47 4e 62 80 7c d3 44 d6 |>&.{...PGNb.|.D.|
00000080 cc 2f 56 34 15 2d ad f0 3c ab ed 82 c6 fe c2 40 |./V4.-..<......@|
00000090 eb bb 55 6d 0f 16 de d9 df c1 67 b3 30 67 9e a3 |..Um......g.0g..|
000000a0 25 3b bc 00 34 4f 64 c6 33 ec ef 4a a1 ea 6b 95 |%;..4Od.3..J..k.|
000000b0 d9 7e 5f a5 20 36 bd f5 4b 91 2c e1 76 d6 35 f6 |.~_. 6..K.,.v.5.|
000000c0 75 36 c2 47 d2 73 95 6f 53 13 6f 61 d1 c4 2e 0b |u6.G.s.oS.oa....|
000000d0 ea 7e e5 5b 7d bc 26 37 9f 72 58 78 d0 5c 07 f0 |.~.[}.&7.rXx.\..|
000000e0 65 83 a8 97 d7 c2 6f b2 06 85 66 a7 a0 dc 78 18 |e.....o...f...x.|
000000f0 e8 2a 79 c5 9e a4 b6 6c e3 8c b4 80 94 43 35 b7 |.*y....l.....C5.|
00000100 21 76 27 f9 13 78 8d 0d 95 7f 70 be 98 01 ab 75 |!v'..x....p....u|
00000110 a0 b2 53 9b 1c 2a 05 d1 cb 59 59 1a ae e2 35 3b |..S..*...YY...5;|
00000120 74 d0 41 07 21 bd 0f 96 35 e1 b9 05 67 0e f0 24 |t.A.!...5...g..$|
00000130 0c eb 38 16 c7 e8 eb 20 ec bc 36 e2 cc e6 ed 70 |..8.... ..6....p|
00000140 bc 92 69 ea c7 5c ae 5c ed 17 9f be 67 b1 8d 8e |..i..\.\....g...|
00000150 14 48 64 65 30 2a 8d 71 0e 0a |.Hde0*.q..|
0000015a
作成したSecretを削除します。
kubectl delete secret kubernetes-the-hard-way
Deploymentの作成
nginxのDeploymentを作成します。
kubectl create deployment nginx --image=nginx:latest
Podが作成されていることを確認します。
kubectl get pods -l app=nginx
$ kubectl get pods -l app=nginx
NAME READY STATUS RESTARTS AGE
nginx-54c98b4f84-74nxt 1/1 Running 0 10s
Serviceの作成
nginx向けServiceを作成します。
kubectl expose deployment nginx --port 80 --type NodePort
Serviceが作成されていることを確認します。
kubectl get service -l app=nginx
$ kubectl get service -l app=nginx
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx NodePort 10.0.0.197 <none> 80:32378/TCP 12s
割り当てられたNodePortを取得します。
NODE_PORT=$(kubectl get svc nginx --output=jsonpath='{range .spec.ports[0]}{.nodePort}')
Podを実行しているノードのホスト名を取得します。
NODE_NAME=$(kubectl get pods \
-l app=nginx \
-o jsonpath="{.items[0].spec.nodeName}")
nginxへの疎通確認を行います。
curl -I http://${NODE_NAME}:${NODE_PORT}
$ curl -I http://${NODE_NAME}:${NODE_PORT}
HTTP/1.1 200 OK
Server: nginx/1.31.2
Date: Sun, 28 Jun 2026 08:51:28 GMT
Content-Type: text/html
Content-Length: 896
Last-Modified: Wed, 17 Jun 2026 14:40:35 GMT
Connection: keep-alive
ETag: "6a32b1e3-380"
Accept-Ranges: bytes
nginxのログを確認します。
kubectl logs `kubectl get pods -l app=nginx -o jsonpath="{.items[0].metadata.name}"`
$ kubectl logs `kubectl get pods -l app=nginx -o jsonpath="{.items[0].metadata.name}"`
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2026/06/28 08:51:03 [notice] 1#1: using the "epoll" event method
2026/06/28 08:51:03 [notice] 1#1: nginx/1.31.2
2026/06/28 08:51:03 [notice] 1#1: built by gcc 14.2.0 (Debian 14.2.0-19)
2026/06/28 08:51:03 [notice] 1#1: OS: Linux 7.0.0-1006-aws
2026/06/28 08:51:03 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2026/06/28 08:51:03 [notice] 1#1: start worker processes
2026/06/28 08:51:03 [notice] 1#1: start worker process 29
2026/06/28 08:51:03 [notice] 1#1: start worker process 30
10.200.0.1 - - [28/Jun/2026:08:51:28 +0000] "HEAD / HTTP/1.1" 200 0 "-" "curl/8.18.0" "-"
作成したDeployment、Serviceを削除します。
kubectl delete deployment nginx
kubectl delete service nginx