0

我在我的 Mac 上运行 minikube 以在本地开发/测试我的微服务。我想知道是否可以通过节点检查器在 minikube 中调试我的 NodeJS?(也欢迎使用其他工具)。我看到有一个使用 docker-compose 使用节点检查器的选项,但是由于我在 k8s 中运行我的所有服务,所以我选择了 Minikube。

先谢谢了!

4

1 回答 1

0

假设你有这个 npm 脚本:

"dev": "concurrently -p \"[{name}]\" -n \"NODE INSPECTOR,NODEMON\" -c \"bgBlue.bold,bgGreen.bold\" \"node-inspector --web-port=8081 --debug-port=5860 --preload\" \"cross-env NODE_ENV=development nodemon ./node_modules/babel-cli/bin/babel-node.js --max-old-space-size=512 --debug=5860 ./index.js\""

节点检查器未在端口 8081 上运行。

现在,您kubernetes.yml可以拥有以下内容:

---

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: helloworld
  name: helloworld
  namespace: application
spec:
  replicas: 1
  selector:
    matchLabels:
      app: helloworld
  template:
    metadata:
      labels:
        app: helloworld
    spec:
      containers:
      - name: helloworld
        imagePullPolicy: Always
        image: fbgrecojr/hello-world:latest
        ports:
        - containerPort: 8080
          protocol: TCP
        - containerPort: 8081
          protocol: TCP

---

kind: Service
apiVersion: v1
metadata:
  labels:
    app: helloworld
  name: helloworld
  namespace: application
spec:
  type: NodePort
  ports:
  - port: 8080
    protocol: TCP
    nodePort: 30000
  - port: 8081
    protocol: TCP
    nodePort: 30001
  selector:
    app: helloworld

您的应用程序无法访问$(minikube ip):30000,节点检查器可从$(minikube ip):30000

于 2016-12-15T07:27:50.433 回答