在 Kubernetes 中运行和测试微服务
1. 服务配置与启动 Minikube
首先,我们有一个 MongoDB 服务的配置示例:
spec:
selector:
app: mongo
ports:
- protocol: TCP
port: 27017
targetPort: 27017
---
apiVersion: v1
kind: Service
metadata:
name: mongo-nodeport
spec:
selector:
app: mongo
ports:
- nodePort: 30001
port: 27017
targetPort: 27017
type: NodePort
这里除了常规的 ClusterIP,还定义了 NodePort,后续会说明其优势。
接下来,要在 Kubernetes 中运行微服务,第一步是启动 Minikube 单节点 Kubernetes 集群:
(base) binildass-MacBook-Pro:~ binil$ pwd
/Users/binil
(base) binildass-MacBook-Pro:~ binil$ minikube start
minikube v1.25.2 on Darwin 12.4
...
Done! kubectl is now configured to use "minikube" clu
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



