Less than 1 minute
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hellok8s-ingress
annotations: # 键值对形式的注解 可以进一步配置控制器的行为,比如rewrite路由、强制https等
# nginx ingress提供的注解选项:https://kubernetes.github.io/ingress-nginx/examples/rewrite/#deployment
nginx.ingress.kubernetes.io/ssl-redirect: "false" # 禁用https重定向到http,若ingress配置了证书则默认true
spec:
ingressClassName: nginx # 指定ingress控制器
tls:
- hosts:
- hellok8s.foo.com
secretName: hellok8s-tls # 引用 secret-hellok8s-cert.yaml 中配置的secret name
rules:
- host: hellok8s.foo.com
- http:
paths:
- path: /hello
pathType: Prefix
backend:
service:
name: service-hellok8s-clusterip
port:
number: 3000