题干
For this question, please set this context (In exam, diff cluster name)
kubectl config use-context kubernetes-admin@kubernetes
There exists a deployment named nginx-deployment exposed through a service called nginx-service . Create an ingress resource named nginx-ingress-resource to efficiently distribute incoming traffic with the following settings: pathType: Prefix , path: /shop , Backend Service Name: nginx-service , Backend Service Port: 80 , ssl-redirect should be configured as false .
存在一个名为
nginx-deployment
的部署,它通过一个名为nginx-service
的服务公开。创建一个名为nginx-ingress-resource
的入口资源,通过以下设置来高效地分配传入的流量:pathType: Prefix
,path: /shop
,后端服务名称:nginx-service
,后端服务端口:80,ssl-redirect
应该配置为false。
解题思路
- 部署Ingress
kubectl apply -f \
> https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.0/deploy/static/provider/cloud/deploy.yaml
- 参考官方文档Ingress编写
nginx-ingress-resource
资源清单,内容如下
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress-resource
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /shop
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 80
ingressClassName
: 通过kubectl get ingressclasses
获取
- 提交资源
nginx-ingress-resource
资源清单
kubectl apply -f nginx-ingress-resource.yaml
- 验证结果
controlplane $ k get ingress
NAME CLASS HOSTS ADDRESS PORTS AGE
nginx-ingress-resource nginx * 80 27m
标签:Ingress,resource,service,必看,ingress,模拟题,nginx,kubernetes
From: https://blog.csdn.net/sinat_28521487/article/details/137048686