kubernetes

kubernetes localhost 연결 - sonarqube

PSAwesome 2022. 7. 21. 10:28
반응형

 

local-sonar.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: local-sonar-deployment
  labels:
    app: local-sonar
spec:
  replicas: 1
  template:
    metadata:
      name: local-sonar
      labels:
        app: local-sonar
    spec:
      containers:
        - name: sonar
          image: sonarqube
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 9000
              protocol: TCP
              name: local-sonar-svc
      restartPolicy: Always
  selector:
    matchLabels:
      app: local-sonar

---

apiVersion: v1
kind: Service
metadata:
  name: local-sonar-service
spec:
  selector:
    app: local-sonar
  ports:
    - port: 9000
      targetPort: local-sonar-svc
      protocol: TCP
  type: NodePort

 

create

kubectl create -f local-sonar.yaml
deployment.apps/local-sonar-deployment created
service/local-sonar-service created

 

 

port-forward

kubectl port-forward svc/local-sonar-service 9000
Forwarding from 127.0.0.1:9000 -> 9000
Forwarding from [::1]:9000 -> 9000

 

svc LoadBalancer 접근은 minikube에서 tunnel 오픈으로 가능하긴 하지만,

mac에서 오픈할 경우 port-forward와 동일한 액션(터미널 창을 킨 상태로 유지)

추가로, 한번 tunnel 을 실행 및 종료 후 재실행에 문제가 있어서 미사용 중.

 

ingress를 통해 open을 시도했지만 접근이 되지 않음.

편하게 docker desktop 설치해도 될텐데.. 비효율의 극치

 

참고 docker image

https://hub.docker.com/_/sonarqube

반응형