题目6:Service四层负载
题目6:Service四层负载
设置配置环境kubectl config use-context k8s
请重新配置现有的名为front-end的deployment,添加名为http的端口规范来暴露现有容器nginx的端口80/tcp。
创建一个名为front-end-svc 的service,以暴露容器端口http,service的类型为NodePort。
中文参考地址:Connecting Applications with Services | Kubernetes
英文参考地址:Connecting Applications with Services | Kubernetes
1、切换答题环境(考试环境有多个,每道题要在对应的环境中作答)
kubectl config use-context k8s
2、配置deployment暴露端口
kubectl edit deployment front-end
3、编写service的yaml文件
vi front-end-svc.yml
apiVersion: v1
kind: Service
metadata:
name: front-end-svc
labels:
run: nginx
spec:
ports:
- port: 80
targetPort: http
selector:
run: nginx
type: NodePort
4、执行service的yaml文件
kubectl apply -f front-end-svc.yml
5、验证方法
kubectl describe svc front-end-svc
赏
支付宝打赏
微信打赏


赞赏是不耍流氓的鼓励