招聘网站建设初衷,建设银行网址官方网址,google做网站框架,成都航空公司官方网站因为minikube使用service暴露端口是使用nodeIP:nodePort 而不是 localhost:nodePort 公开访问。我们只能使用kubectl的端口转发功能或者使用iptables的转发功能来实现外网服务暴露。 我这里使用shiro来举例
apiVersion: apps/v1
kind: Deployment
metadata:name: shiro550
spe…因为minikube使用service暴露端口是使用nodeIP:nodePort 而不是 localhost:nodePort 公开访问。我们只能使用kubectl的端口转发功能或者使用iptables的转发功能来实现外网服务暴露。 我这里使用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文件可以看到监听得端口号为8080【经过测试不需要将类型改为NodePort】 使用kubectl的端口转发功能
kubectl port-forward --address 0.0.0.0 shiro-75d4475c89-h66vh 20080:80最终浏览器访问http://localhost:20080成功访问到页面。