不能通过istio虚拟服务访问Sonar,但是可以在端口转发后在本地访问Sonar [英] Sonar cannot be access via istio virtual service but can be locally accessed after port forwarding

查看:234
本文介绍了不能通过istio虚拟服务访问Sonar,但是可以在端口转发后在本地访问Sonar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Kubernetes集群中实现SonarQube.部署运行正常,并且还通过虚拟服务公开.我可以通过localhost:port/sonar打开UI,但是无法通过外部ip访问它.我知道声纳绑定到本地主机,并且不允许从远程服务器外部进行访问.我在带有MYSQL数据库的GKE上运行此程序.这是我的YAML文件:

I am trying to implement SonarQube in a Kubernetes cluster. The deployment is running properly and is also exposed via a Virtual Service. I am able to open the UI via the localhost:port/sonar but I am not able to access it through my external ip. I understand that sonar binds to localhost and does not allow access from outside the remote server. I am running this on GKE with a MYSQL database. Here is my YAML file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: sonarqube
  namespace: sonar
  labels:
    service: sonarqube
    version: v1
spec:
  replicas: 1
  template:
    metadata:
      name: sonarqube
      labels:
        name: sonarqube
    spec:
      terminationGracePeriodSeconds: 15
      initContainers:
        - name: volume-permission
          image: busybox
          command:
            - sh
            - -c
            - sysctl -w vm.max_map_count=262144
          securityContext:
            privileged: true
      containers:
        - name: sonarqube
          image: sonarqube:6.7
          resources:
            limits:
              memory: 4Gi
              cpu: 2
            requests:
              memory: 2Gi
              cpu: 1
          args:
            - -Dsonar.web.context=/sonar
            - -Dsonar.web.host=0.0.0.0
          env:
            - name: SONARQUBE_JDBC_USERNAME
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: username
            - name: SONARQUBE_JDBC_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cloudsql-db-credentials
                  key: password
            - name: SONARQUBE_JDBC_URL
              value: jdbc:mysql://***.***.**.*:3306/sonar?useUnicode=true&characterEncoding=utf8
          ports:
            - containerPort: 9000
              name: sonarqube-port
---
apiVersion: v1
kind: Service
metadata:
  labels:
    service: sonarqube
    version: v1
  name: sonarqube
  namespace: sonar
spec:
  selector:
    name: sonarqube
  ports:
    - name: http
      port: 80
      targetPort: sonarqube-port
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sonarqube-internal
  namespace: sonar
spec:
  hosts:
    - sonarqube.staging.jeet11.internal
    - sonarqube
  gateways:
    - default/ilb-gateway
    - mesh
  http:
    - route:
        - destination:
            host: sonarqube
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: sonarqube-external
  namespace: sonar
spec:
  hosts:
    - sonarqube.staging.jeet11.com
  gateways:
    - default/elb-gateway
  http:
    - route:
        - destination:
            host: sonarqube
---

部署成功完成.我的公开服务提供了已映射到主机URL的公共ip,但是我无法通过主机URL访问该服务.

The deployment completes successfully. My exposed services gives a public ip that has been mapped to the host url but I am unable to access the service at the host url.

我需要更改映射,以使声纳与服务器ip绑定,但是我不知道该怎么做.我无法将其绑定到群集ip,也无法绑定到内部或外部服务ip.

I need to change the mapping such that sonar binds with the server ip but I am unable to understand how to do that. I cannot bind it to my cluster ip, neither to my internal or external service ip.

我该怎么办?请帮忙!

推荐答案

我最近遇到了同样的问题,今天我设法解决了这个问题.

I had the same issue recently and I managed to get this resolved today.

我希望以下解决方案对遇到相同问题的任何人都有效!.

I hope the following solution will work for anyone facing the same issue!.

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆