test-nginx.yaml
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-nginx
spec:
replicas: 2
selector:
matchLabels:
app: test-nginx
template:
metadata:
labels:
app: test-nginx
spec:
containers:
- name: web
image: nginx:1.8
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
```
test-nginx-svc.yaml
```
apiVersion: v1
kind: Service
metadata:
name: test-nginx
labels:
app: tets-nginx
spec:
selector:
app: test-nginx
type: NodePort
ports:
- port: 80
protocol: TCP
name: web
targetPort: http
nodePort: 31180
```
netstat -ntlp |grep 31180
tcp 0 0 0.0.0.0:31180 0.0.0.0:* LISTEN 4057/kube-proxy
### 显示已经成功了 ,pod 也是 running 状态
### 访问节点:192.168.145.146:31180 (wget/curl 都无法访问)
### 之前已经部署了 kubesphere,也是可以访问的,端口不冲突,请问该怎么排查?
# kubectl get pod -l app=test-nginx
NAME READY STATUS RESTARTS AGE
test-nginx-55546c8c-42r5n 1/1 Running 0 13m
test-nginx-55546c8c-5gqk5 1/1 Running 0 13m
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-nginx
spec:
replicas: 2
selector:
matchLabels:
app: test-nginx
template:
metadata:
labels:
app: test-nginx
spec:
containers:
- name: web
image: nginx:1.8
imagePullPolicy: IfNotPresent
ports:
- containerPort: 80
```
test-nginx-svc.yaml
```
apiVersion: v1
kind: Service
metadata:
name: test-nginx
labels:
app: tets-nginx
spec:
selector:
app: test-nginx
type: NodePort
ports:
- port: 80
protocol: TCP
name: web
targetPort: http
nodePort: 31180
```
netstat -ntlp |grep 31180
tcp 0 0 0.0.0.0:31180 0.0.0.0:* LISTEN 4057/kube-proxy
### 显示已经成功了 ,pod 也是 running 状态
### 访问节点:192.168.145.146:31180 (wget/curl 都无法访问)
### 之前已经部署了 kubesphere,也是可以访问的,端口不冲突,请问该怎么排查?
# kubectl get pod -l app=test-nginx
NAME READY STATUS RESTARTS AGE
test-nginx-55546c8c-42r5n 1/1 Running 0 13m
test-nginx-55546c8c-5gqk5 1/1 Running 0 13m