我正在尝试在Kubernetes集群中实现SonarQube。部署运行正常,并且还通过虚拟服务公开。我可以通过productHierarchy
打开用户界面,但无法通过外部IP访问它。我知道声纳绑定到本地主机,并且不允许从远程服务器外部进行访问。我正在使用MYSQL数据库在GKE上运行此文件。这是我的YAML文件:
localhost:port/sonar
部署成功完成。我的公开服务提供了已映射到主机URL的公共ip,但是我无法通过主机URL访问该服务。
我需要更改映射,以使声纳与服务器ip绑定,但是我不知道该怎么做。我无法将其绑定到群集ip,也无法绑定到内部或外部服务ip。
我该怎么办?请帮忙!
答案 0 :(得分:1)
我最近遇到了同样的问题,今天我设法解决了这个问题。
我希望以下解决方案对遇到相同问题的任何人都适用!。
kubectl logs -n istio-system -l app=istiod
istioctl analyze -n <namespace>
istioctl dashboard kiali
istioctl dashboard prometheus
istio_requests_total
。这会向您显示进入该服务的流量。apiVersion: v1
kind: Service
metadata:
name: sonarqube
namespace: sonarqube
labels:
name: sonarqube
spec:
type: ClusterIP
ports:
- name: http
port: 9000
targetPort: 9000
selector:
app: sonarqube
status:
loadBalancer: {}
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: sonarqube-gateway
namespace: sonarqube
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 9000
name: http
protocol: HTTP
hosts:
- "XXXX.XXXX.com.au"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: sonarqube
namespace: sonarqube
spec:
hosts:
- "XXXX.XXXX.com.au"
gateways:
- sonarqube-gateway
http:
- route:
- destination:
host: sonarqube
port:
number: 9000
kubectl -n istio-system get service istio-ingressgateway
。nslookup <hostname>
),则获得的IP地址必须与分配给istio-ingressgateway服务的IP地址匹配。istioctl analyze -n sonarqube
来确定端口是否引起了问题。您应该收到以下警告; [33mWarn[0m [IST0104] (Gateway sonarqube-gateway.sonarqube) The gateway refers to a port that is not exposed on the workload (pod selector istio=ingressgateway; port 9000) Error: Analyzers found issues when analyzing namespace: sonarqube. See https://istio.io/docs/reference/config/analysis for more information about causes and resolutions.
kubectl logs -n istio-system -l app=istiod
。kubectl edit svc istio-ingressgateway -n istio-system
,然后将以下部分添加到端口中。答案 1 :(得分:0)
不要传递参数,只要对我有用,就不要尝试运行它。
这就是我的部署文件希望对您有帮助的方式
apiVersion: v1
kind: Service
metadata:
name: sonarqube-service
spec:
selector:
app: sonarqube
ports:
- protocol: TCP
port: 9000
targetPort: 9000
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: sonarqube
name: sonarqube
spec:
replicas: 1
template:
metadata:
labels:
app: sonarqube
spec:
containers:
- name: sonarqube
image: sonarqube:7.1
resources:
requests:
memory: "1200Mi"
cpu: .10
limits:
memory: "2500Mi"
cpu: .50
volumeMounts:
- mountPath: "/opt/sonarqube/data/"
name: sonar-data
- mountPath: "/opt/sonarqube/extensions/"
name: sonar-extensions
env:
- name: "SONARQUBE_JDBC_USERNAME"
value: "root" #Put your db username
- name: "SONARQUBE_JDBC_URL"
value: "jdbc:mysql://192.168.112.4:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true" #DB URL
- name: "SONARQUBE_JDBC_PASSWORD"
value : password
ports:
- containerPort: 9000
protocol: TCP
volumes:
- name: sonar-data
persistentVolumeClaim:
claimName: sonar-data
- name: sonar-extensions
persistentVolumeClaim:
claimName: sonar-extensions