Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 
(연관된 글이 3개 있습니다.)

Docker Desktop for Windows를 위한 k8s 대시보드 활성화

아래의 글을 보면,

How to set up Kubernetes on Windows 10 with Docker for Windows and run ASP.NET Core
; https://www.hanselman.com/blog/how-to-set-up-kubernetes-on-windows-10-with-docker-for-windows-and-run-aspnet-core

k8s 대시보드를 활성화시키는 방법이 나옵니다. 그런데, 그 글에 나온 방법을 보면,

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/alternative/kubernetes-dashboard.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/influxdb.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/heapster.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/heapster/master/deploy/kube-config/influxdb/grafana.yaml

이제는 yaml에 대한 URL이 모두 없어져서 저 방법을 사용할 수 없는데요, 대신 원래의 github repo와 관련 문서에 따라,

kubernetes/dashboard
; https://github.com/kubernetes/dashboard

쿠버네티스 문서 / 태스크 / 클러스터 내 어플리케이션 접근 / 웹 UI (대시보드)
; https://kubernetes.io/ko/docs/tasks/access-application-cluster/web-ui-dashboard/

URL을 바꿔 다음과 같이 실행하면 됩니다.

c:\temp> kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.2.0/aio/deploy/recommended.yaml
namespace/kubernetes-dashboard created
serviceaccount/kubernetes-dashboard created
service/kubernetes-dashboard created
secret/kubernetes-dashboard-certs created
secret/kubernetes-dashboard-csrf created
secret/kubernetes-dashboard-key-holder created
configmap/kubernetes-dashboard-settings created
role.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
deployment.apps/kubernetes-dashboard created
service/dashboard-metrics-scraper created
deployment.apps/dashboard-metrics-scraper created

이로 인한 변화는 각각 다음과 같이 확인할 수 있고.

c:\temp> kubectl get namespace
NAME                   STATUS   AGE
default                Active   50d
kube-node-lease        Active   50d
kube-public            Active   50d
kube-system            Active   50d
kubernetes-dashboard   Active   123m

c:\temp> kubectl get serviceaccount -n kubernetes-dashboard
NAME                   SECRETS   AGE
default                1         137m
kubernetes-dashboard   1         137m

c:\temp> kubectl get svc -n kubernetes-dashboard
NAME                        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
dashboard-metrics-scraper   ClusterIP   10.111.93.45   <none>        8000/TCP   124m
kubernetes-dashboard        ClusterIP   10.96.4.48     <none>        443/TCP    124m

c:\temp> kubectl get secrets -n kubernetes-dashboard
NAME                               TYPE                                  DATA   AGE
default-token-kxmhk                kubernetes.io/service-account-token   3      127m
kubernetes-dashboard-certs         Opaque                                0      127m
kubernetes-dashboard-csrf          Opaque                                1      127m
kubernetes-dashboard-key-holder    Opaque                                2      127m
kubernetes-dashboard-token-9fhlp   kubernetes.io/service-account-token   3      127m

c:\temp> kubectl get configmap -n kubernetes-dashboard
NAME                            DATA   AGE
kubernetes-dashboard-settings   0      127m

c:\temp> kubectl get role.rbac.authorization.k8s.io -n kubernetes-dashboard
NAME                   CREATED AT
kubernetes-dashboard   2021-03-16T23:43:21Z

c:\temp> kubectl get clusterrole.rbac.authorization.k8s.io | findstr kubernetes-dashboard
kubernetes-dashboard   2021-03-16T23:43:21Z

c:\temp> kubectl get rolebinding.rbac.authorization.k8s.io -n kubernetes-dashboard
NAME                   ROLE                        AGE
kubernetes-dashboard   Role/kubernetes-dashboard   130m

c:\temp> kubectl get clusterrolebinding.rbac.authorization.k8s.io | findstr kubernetes-dashboard
kubernetes-dashboard     ClusterRole/kubernetes-dashboard     131m

c:\temp> kubectl get deployment.apps -n kubernetes-dashboard
NAME                        READY   UP-TO-DATE   AVAILABLE   AGE
dashboard-metrics-scraper   1/1     1            1           132m
kubernetes-dashboard        1/1     1            1           132m

dashboard를 활성화시켰으면, 이제 웹 브라우저로 방문을 해야 하는데요, 간단하게 kubectl proxy 모드를 이용해,

Kubernetes - kube-apiserver와 REST API 통신하는 방법 (Docker Desktop for Windows 환경)
; https://www.sysnet.pe.kr/2/0/12566

다음의 URL 주소로 웹 브라우저에서 방문할 수 있습니다.

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

그럼 다음과 같이 service account token 값을 묻는데,

k8s_dashboard_1.png

Kubernetes - kube-apiserver와 REST API 통신하는 방법 (Docker Desktop for Windows 환경) 글에서 설명한 방법으로 구한 token 값을 입력하면 됩니다.

인증에 성공하면 이후 다음과 같은 화면을 보게 됩니다.

[그럼 출처: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/]
k8s_dashboard_2.png




kubectl proxy는 이전 글에서 설명한 바와 같이 kube-apiserver로의 모든 요청을 허용합니다. 만약 dashboard만을 사용한다면, 이런 경우 kubectl이 중계해 주는 API 영역을 제한하는 것이 바람직할 수 있는데요, 이를 위해 원하는 서비스로만 요청을 전달하는 명령어를 사용하는 것도 가능합니다.

kubectl port-forward -n kubernetes-dashboard service/kubernetes-dashboard 8080:443

위와 같이 port-forward 모드로 실행해 두면 kubernetes-dashboard 서비스로만 중계 역할을 하게 됩니다. 그리고 dashboard에 대한 접속 URL도 (/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/ URL을 지정할 필요 없이) 포트까지만 지정해도 됩니다.

https://localhost:8080/




이외에도 NodePort, Ingress 등의 방법을 이용해 접근할 수 있습니다.

dashboard/docs/user/accessing-dashboard/
; https://github.com/kubernetes/dashboard/tree/master/docs/user/accessing-dashboard

dashboard/docs/user/installation.md
; https://github.com/kubernetes/dashboard/blob/master/docs/user/installation.md#recommended-setup




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 4/9/2021]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 



2021-04-15 11시44분
참고로 dashboard 관련한 모든 작업을 ukubectl 도구(https://github.com/stjeong/Utilities/releases )를 이용해 다음과 같이 간단하게 처리할 수 있습니다.

ukubectl --install-dashboard
ukubectl --set-default-token
ukubectl --register-cert
정성태

... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
12736정성태7/28/20217338오류 유형: 743. Active Azure Directory에서 "API permissions"의 권한 설정이 "Not granted for ..."로 나오는 문제
12735정성태7/27/20217840.NET Framework: 1081. C# - Azure AD 인증을 지원하는 데스크톱 애플리케이션 예제(Windows Forms) [2]파일 다운로드1
12734정성태7/26/202123828스크립트: 20. 특정 단어로 시작하거나/끝나는 문자열을 포함/제외하는 정규 표현식 - Look-around
12733정성태7/23/202111163.NET Framework: 1081. Self-Contained/SingleFile 유형의 .NET Core/5+ 실행 파일을 임베딩한다면? [1]파일 다운로드2
12732정성태7/23/20216453오류 유형: 742. SharePoint - The super user account utilized by the cache is not configured.
12731정성태7/23/20217672개발 환경 구성: 584. Add Internal URLs 화면에서 "Save" 버튼이 비활성화 된 경우
12730정성태7/23/20219177개발 환경 구성: 583. Visual Studio Code - Go 코드에서 입력을 받는 경우
12729정성태7/22/20218125.NET Framework: 1080. xUnit 단위 테스트에 메서드/클래스 수준의 문맥 제공 - Fixture
12728정성태7/22/20217585.NET Framework: 1079. MSTestv2 단위 테스트에 메서드/클래스/어셈블리 수준의 문맥 제공
12727정성태7/21/20218599.NET Framework: 1078. C# 단위 테스트 - MSTestv2/NUnit의 Assert.Inconclusive 사용법(?) [1]
12726정성태7/21/20218421VS.NET IDE: 169. 비주얼 스튜디오 - 단위 테스트 선택 시 MSTestv2 외의 xUnit, NUnit 사용법 [1]
12725정성태7/21/20217119오류 유형: 741. Failed to find the "go" binary in either GOROOT() or PATH
12724정성태7/21/20219801개발 환경 구성: 582. 윈도우 환경에서 Visual Studio Code + Go (Zip) 개발 환경 [1]
12723정성태7/21/20217463오류 유형: 740. SharePoint - Alternate access mappings have not been configured 경고
12722정성태7/20/20217295오류 유형: 739. MSVCR110.dll이 없어 exe 실행이 안 되는 경우
12721정성태7/20/20217915오류 유형: 738. The trust relationship between this workstation and the primary domain failed. - 세 번째 이야기
12720정성태7/19/20217268Linux: 43. .NET Core/5+ 응용 프로그램의 Ubuntu (Debian) 패키지 준비
12719정성태7/19/20216443오류 유형: 737. SharePoint 설치 시 "0x800710D8 The object identifier does not represent a valid object." 오류 발생
12718정성태7/19/20217054개발 환경 구성: 581. Windows에서 WSL로 파일 복사 시 root 소유권으로 적용되는 문제파일 다운로드1
12717정성태7/18/20216998Windows: 195. robocopy에서 파일의 ADS(Alternate Data Stream) 정보 복사를 제외하는 방법
12716정성태7/17/20217799개발 환경 구성: 580. msbuild의 Exec Task에 robocopy를 사용하는 방법파일 다운로드1
12715정성태7/17/20219446오류 유형: 736. Windows - MySQL zip 파일 버전의 "mysqld --skip-grant-tables" 실행 시 비정상 종료 [1]
12714정성태7/16/20218231오류 유형: 735. VCRUNTIME140.dll, MSVCP140.dll, VCRUNTIME140.dll, VCRUNTIME140_1.dll이 없어 exe 실행이 안 되는 경우
12713정성태7/16/20218769.NET Framework: 1077. C# - 동기 방식이면서 비동기 규약을 따르게 만드는 Task.FromResult파일 다운로드1
12712정성태7/15/20218190개발 환경 구성: 579. Azure - 리눅스 호스팅의 Site Extension 제작 방법
12711정성태7/15/20218528개발 환경 구성: 578. Azure - Java Web App Service를 위한 Site Extension 제작 방법
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...