部署和检查ingress-nginx;
#部署ingress-nginxkubectl apply -f v1.0.0-deploy.yaml
#查看相关pod状态
kubectl get pods -n ingress-nginx -owide
#查看service
kubectl get service -n ingress-nginx
新建nginx-service.yaml,将方式改变为ClusterIP形式;
apiVersion: v1kind: Service
metadata:
name: nginx-service
spec:
#定义后端pod标签为app=backend
selector:
app: backend
ports:
#service端口号
- port: 80
#pod的端口号
targetPort: 80
创建nginx-service,并检查资源情况;
#创建nginx-servicekubectl apply -f nginx-service.yaml
#检查资源状况
kubectl get svc
#资源的绑定情况
kubectl describe service nginx-service
#通过curl访问
curl 10.96.53.148
image.png