根據(jù)一些參考文檔,學習部署 ingress-http服務,出現(xiàn)了一些error信息,網(wǎng)上難找直接的處理方式,最后才發(fā)現(xiàn)是資源清單使用問題,還是得看官方文檔說明。
創(chuàng)建ingress-http.yaml
使用的基本yaml配置如下——
# 文件名稱: ingress-http.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-http
namespace: dev
spec:
rules:
- host: nginx.itheima.com
http:
paths:
- path: /
backend:
serviceName: nginx-service
servicePort: 80
- host: tomcat.itheima.com
http:
paths:
- path: /
backend:
serviceName: tomcat-service
servicePort: 8080
部署ingress服務
# 部署服務
kubectl create -f ingress-http.yaml
出現(xiàn)error信息
錯誤一:
error: resource mapping not found for name: "ingress-http" namespace: "dev" from "ingress-http.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
ensure CRDs are installed first
處理方式——
根據(jù)官方文檔:Ingress對象資源清單說明
apiVersion: networking.k8s.io/v1
重新部署,仍然出現(xiàn)error信息
錯誤二:
* spec.rules[0].http.paths[0].pathType: Required value: pathType must be specified
paths下必須有pathType,否則創(chuàng)建就會失敗,官方文檔中也有說明文章來源:http://www.zghlxwxcb.cn/news/detail-737285.html
PS:附上官方文檔的對應的截圖
文章來源地址http://www.zghlxwxcb.cn/news/detail-737285.html
正確的yaml配置
apiVersion: networking.k8s.io/v1 # 注意最新的官方給定
kind: Ingress
metadata:
name: ingress-http
namespace: dev
spec:
rules:
- host: nginx.itheima.com
http:
paths:
- path: /
pathType: Prefix # required
backend:
serviceName: nginx-service
servicePort: 80
- host: tomcat.itheima.com
http:
paths:
- path: /
pathType: Prefix # required
backend:
serviceName: tomcat-service
servicePort: 8080
# 最終部署情況查看——
$ kubectl get ing -n dev
NAME CLASS HOSTS ADDRESS PORTS AGE
ingress-http <none> nginx.itheima.com,tomcat.itheima.com 80 12m
$ kubectl describe ing ingress-http -n dev
Name: ingress-http
Labels: <none>
Namespace: dev
Address:
Ingress Class: <none>
Default backend: <default>
Rules:
Host Path Backends
---- ---- --------
nginx.itheima.com
/ nginx-service:80 (10.244.1.91:80,10.244.1.92:80,10.244.1.93:80)
tomcat.itheima.com
/ tomcat-service:8080 (10.244.2.100:8080,10.244.2.101:8080,10.244.2.102:8080)
Annotations: <none>
Events: <none>
到了這里,關于ingress-http部署error: resource mapping not found for name...no matches for kind “Ingress“ in version的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!