CKA 模拟真题 Killer.sh | Question 21 | Create a Static Pod and Service
Use context: kubectl config use-context k8s-c3-CCC
Create a Static Pod named my-static-pod in Namespace default on cluster3-controlplane1 . It should be of image nginx:1.16-alpine and have resource requests for 10m CPU and 20Mi memory.
Then create a NodePort Service named static-pod-service which exposes that static Pod on port 80 and check if it has Endpoints and if it’s reachable through the cluster3-controlplane1 internal IP address. You can connect to the internal node IPs from your main terminal.
译文
在 cluster3-controlplane1 的名称空间 default 中创建一个名为 my-static-pod 的静态 Pod。 镜像为 nginx:1.16-alpine ,并有 10m CPU 和 20Mi 内存的资源请求
然后创建一个名为 static-pod-service 的 NodePort 服务,通过 80 端口公开该静态 Pod,并检查它是否有端点,以及是否可以通过 cluster3-controlplane1 内部 IP 地址访问。 您可以从主终端连接到内部节点 IP 地址
解答
kubectl config use-context k8s-c3-CCC |
连接到cluster3-controlplane1 并新建一个pod
ssh cluster3-controlplane1 |
my-static-pod.yaml
# /etc/kubernetes/manifests/my-static-pod.yaml |
返回操作节点,检查pod
k get pod -A | grep my-static |
暴露端口
k expose pod my-static-pod-cluster3-controlplane1 \ |
检查
k get svc,ep -l run=my-static-pod |



