石家莊搜索排名提升杭州seo整站優(yōu)化
因?yàn)閙inikube使用service暴露端口是使用nodeIP:nodePort 而不是 localhost:nodePort 公開訪問。我們只能使用kubectl的端口轉(zhuǎn)發(fā)功能或者使用iptables的轉(zhuǎn)發(fā)功能來實(shí)現(xiàn)外網(wǎng)服務(wù)暴露。
我這里使用shiro來舉例
apiVersion: apps/v1
kind: Deployment
metadata:name: shiro550
spec:selector:matchLabels:app: shiro550replicas: 1template:metadata:labels:app: shiro550spec:containers:- name: shiro550imagePullPolicy: IfNotPresentimage: vulhub/shiro:1.2.4ports:- containerPort: 8080name: web
通過yaml文件可以看到監(jiān)聽得端口號(hào)為8080,【經(jīng)過測試,不需要將類型改為NodePort】
使用kubectl的端口轉(zhuǎn)發(fā)功能
kubectl port-forward --address 0.0.0.0 shiro-75d4475c89-h66vh 20080:80
最終瀏覽器訪問,http://localhost:20080,成功訪問到頁面。