microk8s 및 helm을 사용하여 로컬 Kubernetes 클러스터 구축 (추가 설정)
소개
마지막 기사 에서 Windows10에 microk8s를 사용하여 Kubernetes 클러스터를 구축했습니다.
일부 관련 기사를 읽고 있으면 부족한 것 같은 설정이 있었으므로 이 기사에서 보충합니다.
개요
다음 추가 설정을 수행합니다.
다음 추가 설정을 수행합니다.
설정 절차
절차는 우분투에서의 작업, 그 후 Windows에서의 작업의 두 단계입니다.
우분투 측
microk8s.enable
명령 한 번에 여러가지 유효하게 됩니다.storage
를 활성화하면 var 폴더에 파일이 생성되므로 sudo를 부여해야합니다.
우분투의 bash# microk8sのstorage,dns,dashboard,metrics-serverを有効にする
$ sudo microk8s.enable storage dns dashboard metrics-server
# Kubernetesクラスタの状態を確認する(storage,dns,metrics-server,dashboardがenableになっている)
$ microk8s.status
microk8s is running
addons:
jaeger: disabled
fluentd: disabled
gpu: disabled
storage: enabled
registry: disabled
ingress: disabled
dns: enabled
metrics-server: enabled
prometheus: disabled
istio: disabled
dashboard: enabled
# Kubernetesクラスタの全ての状態を取得する(いろいろ増えている)
$ kubectl get all --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/heapster-v1.5.2-64874f6bc6-dw7vs 4/4 Running 4 3m59s
kube-system pod/hostpath-provisioner-599db8d5fb-lh4rn 1/1 Running 2 32m
kube-system pod/kube-dns-6ccd496668-rwtd9 3/3 Running 11 88m
kube-system pod/kubernetes-dashboard-654cfb4879-n9v2d 1/1 Running 1 5m19s
kube-system pod/metrics-server-v0.2.1-6f76659f47-2grd2 2/2 Running 2 4m11s
kube-system pod/monitoring-influxdb-grafana-v4-6679c46745-xr8js 2/2 Running 2 5m19s
kube-system pod/tiller-deploy-664d6bdc7b-bvjrb 1/1 Running 4 3h3m
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 3h4m
kube-system service/heapster ClusterIP 10.152.183.55 <none> 80/TCP 5m19s
kube-system service/kube-dns ClusterIP 10.152.183.10 <none> 53/UDP,53/TCP 88m
kube-system service/kubernetes-dashboard ClusterIP 10.152.183.163 <none> 443/TCP 5m19s
kube-system service/metrics-server ClusterIP 10.152.183.231 <none> 443/TCP 4m53s
kube-system service/monitoring-grafana ClusterIP 10.152.183.57 <none> 80/TCP 5m19s
kube-system service/monitoring-influxdb ClusterIP 10.152.183.49 <none> 8083/TCP,8086/TCP 5m19s
kube-system service/tiller-deploy ClusterIP 10.152.183.165 <none> 44134/TCP 3h3m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/heapster-v1.5.2 1/1 1 1 5m19s
kube-system deployment.apps/hostpath-provisioner 1/1 1 1 32m
kube-system deployment.apps/kube-dns 1/1 1 1 88m
kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 5m19s
kube-system deployment.apps/metrics-server-v0.2.1 1/1 1 1 4m54s
kube-system deployment.apps/monitoring-influxdb-grafana-v4 1/1 1 1 5m19s
kube-system deployment.apps/tiller-deploy 1/1 1 1 3h3m
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/heapster-v1.5.2-56c546dbb8 0 0 0 4m14s
kube-system replicaset.apps/heapster-v1.5.2-64874f6bc6 1 1 1 3m59s
kube-system replicaset.apps/heapster-v1.5.2-6bc7c4965d 0 0 0 5m19s
kube-system replicaset.apps/hostpath-provisioner-599db8d5fb 1 1 1 32m
kube-system replicaset.apps/kube-dns-6ccd496668 1 1 1 88m
kube-system replicaset.apps/kubernetes-dashboard-654cfb4879 1 1 1 5m19s
kube-system replicaset.apps/metrics-server-v0.2.1-6f76659f47 1 1 1 4m12s
kube-system replicaset.apps/metrics-server-v0.2.1-7d7d77666c 0 0 0 4m53s
kube-system replicaset.apps/monitoring-influxdb-grafana-v4-6679c46745 1 1 1 5m19s
kube-system replicaset.apps/tiller-deploy-664d6bdc7b 1 1 1 3h3m
# cluster-infoを確認し、サービスへアクセスするURLが生成されていることを確認する
$ kubectl cluster-info
Kubernetes master is running at http://127.0.0.1:8080
Heapster is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
Grafana is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
InfluxDB is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy
다음 단계에서 필요하므로 kubectl 구성 정보를 덤프합니다.
$ cat /snap/microk8s/current/client.config
apiVersion: v1
clusters:
- cluster:
server: http://127.0.0.1:8080
name: microk8s-cluster
contexts:
- context:
cluster: microk8s-cluster
user: admin
name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
user:
username: admin
Windows10측
Chocolatey 설치
관리자 권한으로 명령 프롬프트를 시작한 상태에서 조작합니다.
Chocolatey의 공식 사이트 를 참고해 주세요.
다음 문자열을 명령 프롬프트에 붙여넣고 엔터키 한 번에 설치됩니다.
관리자 권한 명령 프롬프트C:\> @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
kubectl 설치
chocolatey를 설치한 명령 프롬프트에서 계속 실행합니다.
관리자 권한 명령 프롬프트C:\> choco install kubernetes-cli
kubectl과 kubectl 연결
Ubuntu상(IP주소:192.168.33.10)에서 동작하는 microk8s로 구축한 Kubernetes 클러스터에 액세스하기 위한 정보를 kubectl로 설정한다.
일반 명령 프롬프트# 現在の設定を表示(有効なKubernetesクラスタはひとつもない状態)
C:\> kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []
# ユーザ(admin)を作成する。
C:\> kubectl config set-credentials admin --username=admin
user "admin" set.
# クラスタを作成する。
C:\> kubectl config set-cluster microk8s-cluster --server=http://192.168.33.10:8080
cluster "microk8s-cluster" set.
# コンテキスト(microk8s)を作成する。ユーザ(admin)とクラスタ(cluster)を関係付ける。
C:\> kubectl config set-context microk8s --user=admin --cluster=microk8s-cluster
context "microk8s" set.
# 利用するコンテキストを選択する。ここでは、microk8sを使う。
C:\> kubectl config use-context microk8s
switched to context "microk8s-cluster".
# 現在利用中のコンテキストを確認する。microk8sであることがわかる。
C:\> kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* microk8s cluster admin
# microk8sで構築したKubernetesクラスタのcluster-infoを確認する
C:\> kubectl cluster-info
Kubernetes master is running at http://192.168.33.10:8080
Heapster is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
Grafana is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
InfluxDB is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Grafana 화면 표시
Host PC인 Windows10상에서 kubectl cluster-info
에서 확인한 Grafana의 URL을 브라우저로부터 액세스한다.
cluster-info에서 확인한 Grafana URLGrafana is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
아래의 표시가 나오면 액세스가 성공하고 있습니다.
사이고에게
기사를 쓰고 생각하는 것이 microk8s의 단순함에 솔직하게 놀랐습니다.
사실 이전 기사의 이어서이 기사를 썼지만 VirtualBox의 Ubuntu에 할당 된 메모리 1GB는 2GB로 충분하지 않습니다.
아직 유효하게 한 add-on의 사용법도 모르겠지만, 서서히 그 근처는 공부해 나갈까 생각합니다.
참고 기사
# microk8sのstorage,dns,dashboard,metrics-serverを有効にする
$ sudo microk8s.enable storage dns dashboard metrics-server
# Kubernetesクラスタの状態を確認する(storage,dns,metrics-server,dashboardがenableになっている)
$ microk8s.status
microk8s is running
addons:
jaeger: disabled
fluentd: disabled
gpu: disabled
storage: enabled
registry: disabled
ingress: disabled
dns: enabled
metrics-server: enabled
prometheus: disabled
istio: disabled
dashboard: enabled
# Kubernetesクラスタの全ての状態を取得する(いろいろ増えている)
$ kubectl get all --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/heapster-v1.5.2-64874f6bc6-dw7vs 4/4 Running 4 3m59s
kube-system pod/hostpath-provisioner-599db8d5fb-lh4rn 1/1 Running 2 32m
kube-system pod/kube-dns-6ccd496668-rwtd9 3/3 Running 11 88m
kube-system pod/kubernetes-dashboard-654cfb4879-n9v2d 1/1 Running 1 5m19s
kube-system pod/metrics-server-v0.2.1-6f76659f47-2grd2 2/2 Running 2 4m11s
kube-system pod/monitoring-influxdb-grafana-v4-6679c46745-xr8js 2/2 Running 2 5m19s
kube-system pod/tiller-deploy-664d6bdc7b-bvjrb 1/1 Running 4 3h3m
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 3h4m
kube-system service/heapster ClusterIP 10.152.183.55 <none> 80/TCP 5m19s
kube-system service/kube-dns ClusterIP 10.152.183.10 <none> 53/UDP,53/TCP 88m
kube-system service/kubernetes-dashboard ClusterIP 10.152.183.163 <none> 443/TCP 5m19s
kube-system service/metrics-server ClusterIP 10.152.183.231 <none> 443/TCP 4m53s
kube-system service/monitoring-grafana ClusterIP 10.152.183.57 <none> 80/TCP 5m19s
kube-system service/monitoring-influxdb ClusterIP 10.152.183.49 <none> 8083/TCP,8086/TCP 5m19s
kube-system service/tiller-deploy ClusterIP 10.152.183.165 <none> 44134/TCP 3h3m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/heapster-v1.5.2 1/1 1 1 5m19s
kube-system deployment.apps/hostpath-provisioner 1/1 1 1 32m
kube-system deployment.apps/kube-dns 1/1 1 1 88m
kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 5m19s
kube-system deployment.apps/metrics-server-v0.2.1 1/1 1 1 4m54s
kube-system deployment.apps/monitoring-influxdb-grafana-v4 1/1 1 1 5m19s
kube-system deployment.apps/tiller-deploy 1/1 1 1 3h3m
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/heapster-v1.5.2-56c546dbb8 0 0 0 4m14s
kube-system replicaset.apps/heapster-v1.5.2-64874f6bc6 1 1 1 3m59s
kube-system replicaset.apps/heapster-v1.5.2-6bc7c4965d 0 0 0 5m19s
kube-system replicaset.apps/hostpath-provisioner-599db8d5fb 1 1 1 32m
kube-system replicaset.apps/kube-dns-6ccd496668 1 1 1 88m
kube-system replicaset.apps/kubernetes-dashboard-654cfb4879 1 1 1 5m19s
kube-system replicaset.apps/metrics-server-v0.2.1-6f76659f47 1 1 1 4m12s
kube-system replicaset.apps/metrics-server-v0.2.1-7d7d77666c 0 0 0 4m53s
kube-system replicaset.apps/monitoring-influxdb-grafana-v4-6679c46745 1 1 1 5m19s
kube-system replicaset.apps/tiller-deploy-664d6bdc7b 1 1 1 3h3m
# cluster-infoを確認し、サービスへアクセスするURLが生成されていることを確認する
$ kubectl cluster-info
Kubernetes master is running at http://127.0.0.1:8080
Heapster is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
Grafana is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
InfluxDB is running at http://127.0.0.1:8080/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy
$ cat /snap/microk8s/current/client.config
apiVersion: v1
clusters:
- cluster:
server: http://127.0.0.1:8080
name: microk8s-cluster
contexts:
- context:
cluster: microk8s-cluster
user: admin
name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
user:
username: admin
C:\> @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
C:\> choco install kubernetes-cli
# 現在の設定を表示(有効なKubernetesクラスタはひとつもない状態)
C:\> kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []
# ユーザ(admin)を作成する。
C:\> kubectl config set-credentials admin --username=admin
user "admin" set.
# クラスタを作成する。
C:\> kubectl config set-cluster microk8s-cluster --server=http://192.168.33.10:8080
cluster "microk8s-cluster" set.
# コンテキスト(microk8s)を作成する。ユーザ(admin)とクラスタ(cluster)を関係付ける。
C:\> kubectl config set-context microk8s --user=admin --cluster=microk8s-cluster
context "microk8s" set.
# 利用するコンテキストを選択する。ここでは、microk8sを使う。
C:\> kubectl config use-context microk8s
switched to context "microk8s-cluster".
# 現在利用中のコンテキストを確認する。microk8sであることがわかる。
C:\> kubectl config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
* microk8s cluster admin
# microk8sで構築したKubernetesクラスタのcluster-infoを確認する
C:\> kubectl cluster-info
Kubernetes master is running at http://192.168.33.10:8080
Heapster is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/heapster/proxy
KubeDNS is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
Grafana is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
InfluxDB is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/monitoring-influxdb:http/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Grafana is running at http://192.168.33.10:8080/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
기사를 쓰고 생각하는 것이 microk8s의 단순함에 솔직하게 놀랐습니다.
사실 이전 기사의 이어서이 기사를 썼지만 VirtualBox의 Ubuntu에 할당 된 메모리 1GB는 2GB로 충분하지 않습니다.
아직 유효하게 한 add-on의 사용법도 모르겠지만, 서서히 그 근처는 공부해 나갈까 생각합니다.
참고 기사
Reference
이 문제에 관하여(microk8s 및 helm을 사용하여 로컬 Kubernetes 클러스터 구축 (추가 설정)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hidenki/items/13f84e6e60b9b542848c텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)