我正在尝试创建以下内容:
Deployment
对于蒙戈Deployment
对于 mongo-expressClusterIp
对于蒙戈ClusterIp
对于 mongo-express- 将请求路由到 mongo-express 的入口服务
我希望能够去xyz.com/admin/auth-db-gui
看看 mongo-express gui。
我在 Linux minikube 上运行它。
去时xyz.com/admin/auth-db-gui
,我得到 503 Service Temporarily Unavailable,但是在执行时kubectl get pods
,我可以看到 2 个 Pod 正在运行。
我将手动设置映射,xyz.com
因为/etc/hosts
这仅用于开发目的
数据库.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-db-deployment
spec:
selector:
matchLabels:
app: auth-db
template:
metadata:
labels:
app: auth-db
spec:
containers:
- name: auth-db
image: mongo
---
apiVersion: v1
kind: Service
metadata:
name: auth-db-service
spec:
selector:
app: auth-db
ports:
- name: auth-db
protocol: TCP
port: 27017
targetPort: 27017
数据库-gui
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-db-gui-deployment
spec:
selector:
matchLabels:
app: auth-db-gui
template:
metadata:
labels:
app: auth-db-gui
spec:
containers:
- name: auth-db-gui
image: mongo-express
env:
- name: ME_CONFIG_MONGODB_SERVER
value: auth-db-service
---
apiVersion: v1
kind: Service
metadata:
name: auth-db-gui-service
spec:
selector:
app: auth-db-gui
ports:
- name: auth-db-gui
protocol: TCP
port: 27017
targetPort: 27017
入口.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: xyz-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
rules:
- host: xyz.com
http:
paths:
- path: /admin/auth-db-gui
backend:
serviceName: auth-db-gui-service
servicePort: 8081
对不起,如果上面有明显的错误。