6.Ingress 七层负载

发布时间 2024-01-11 16:26:05作者: 杨梅冲
官方文档:https://kubernetes.io/zh-cn/docs/concepts/services-networking/ingress/
题目
: 设置配置环境: [candidate@node
-1] $ kubectl config use-context k8s Task 如下创建一个新的 nginx Ingress 资源: 名称: ping Namespace: ing-internal 使用服务端口 5678 在路径 /hello 上公开服务 hello 可以使用以下命令检查服务 hello 的可用性,该命令应返回 hello: curl -kL <INTERNAL_IP>/hello
解题:
# 1.切换答题环境
kubectl config use-context k8s

# 2.编译配置文件ingress.yaml
[root@master2 ingres]# cat ingress.yaml 
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ping
  namespace: ing-internal
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - path: /hello
        pathType: Prefix  # Exact
        backend:
          service:
            name: hello
            port:
              number: 5678

[root@master2 ingres]# kubectl apply -f ingress.yaml 
ingress.networking.k8s.io/pong created

[root@master2 ingres]# kubectl get ingress -n ing-internal
如果单独只有这个配置文件,没有其余环境会出现没有IP的情况