LoginSignup
0
1

More than 1 year has passed since last update.

Kubernetesクラスタ(microk8s)環境にweave scopeをデプロイしてみるよ

Last updated at Posted at 2023-05-04

こんにちは
株式会社クラスアクト インフラストラクチャ事業部の大塚です。

今回はweave scopeと呼ばれるdocker/kubernetes環境管理用のWebUIサービスをmicrok8sでクラスタ化しているk8s環境にデプロイしてみたので、簡単にメモっておこうと思います。

weave scopeとは?

Weaveworks社が開発しているdocker/Kubernetes用のWebUI管理ツールのようです。
公式のドキュメントには以下のことが出来ると書いているっぽい。。。?

Topology Mapping
Views in Scope
Graphic or Table Mode
Flexible Filtering
Powerful Search
Real-time App and Container Metrics
Troubleshoot and Manage Containers
Generate Custom Metrics using the Plugin API

以下がWeaveworks社公式サイトです。
会社はアメリカとイギリスにありそうです。

導入した環境

今回導入した環境はubuntu22.04とMicroK8s v1.26.4の4台構成となるk8sクラスタ環境になります。

root@k8s-master:~# kubectl get node -o wide
NAME           STATUS   ROLES    AGE     VERSION   INTERNAL-IP    EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION      CONTAINER-RUNTIME
k8s-worker01   Ready    <none>   46h     v1.26.4   192.168.2.31   <none>        Ubuntu 22.04.2 LTS   5.15.0-71-generic   containerd://1.6.15
k8s-master     Ready    <none>   2d14h   v1.26.4   192.168.2.30   <none>        Ubuntu 22.04.2 LTS   5.15.0-71-generic   containerd://1.6.15
k8s-worker03   Ready    <none>   11h     v1.26.4   192.168.2.33   <none>        Ubuntu 22.04.2 LTS   5.15.0-71-generic   containerd://1.6.15
k8s-worker02   Ready    <none>   46h     v1.26.4   192.168.2.32   <none>        Ubuntu 22.04.2 LTS   5.15.0-71-generic   containerd://1.6.15

構築

以下2点を参照しています。

まずmaster nodeにおいて以下を実行。
外部ネットワーク上にあるyamlファイルを参照して、環境をデプロイしています。

root@k8s-master:~# kubectl apply -f https://github.com/weaveworks/scope/releases/download/v1.13.2/k8s-scope.yaml
namespace/weave created
clusterrole.rbac.authorization.k8s.io/weave-scope created
clusterrolebinding.rbac.authorization.k8s.io/weave-scope created
deployment.apps/weave-scope-app created
daemonset.apps/weave-scope-agent created
deployment.apps/weave-scope-cluster-agent created
serviceaccount/weave-scope created
service/weave-scope-app created

これを実行するとweaveとネームドされたnamespaceが作成され、その中に色々作成されます。

root@k8s-master:~# kubectl get all -n weave -o wide
NAME                                             READY   STATUS    RESTARTS   AGE   IP             NODE           NOMINATED NODE   READINESS GATES
pod/weave-scope-agent-zmq79                      1/1     Running   0          95s   192.168.2.31   k8s-worker01   <none>           <none>
pod/weave-scope-agent-nzdg9                      1/1     Running   0          95s   192.168.2.30   k8s-master     <none>           <none>
pod/weave-scope-agent-hgmhs                      1/1     Running   0          95s   192.168.2.33   k8s-worker03   <none>           <none>
pod/weave-scope-cluster-agent-84f7b6767c-fx47q   1/1     Running   0          95s   10.1.39.197    k8s-worker03   <none>           <none>
pod/weave-scope-app-658845597b-w62j2             1/1     Running   0          95s   10.1.79.73     k8s-worker01   <none>           <none>
pod/weave-scope-agent-cjx72                      1/1     Running   0          95s   192.168.2.32   k8s-worker02   <none>           <none>

NAME                      TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)   AGE   SELECTOR
service/weave-scope-app   ClusterIP   10.152.183.83   <none>        80/TCP    95s   app=weave-scope,name=weave-scope-app,weave-cloud-component=scope,weave-scope-component=app

NAME                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE   CONTAINERS    IMAGES                    SELECTOR
daemonset.apps/weave-scope-agent   4         4         4       4            4           <none>          95s   scope-agent   weaveworks/scope:1.13.2   app=weave-scope

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS            IMAGES                              SELECTOR
deployment.apps/weave-scope-cluster-agent   1/1     1            1           95s   scope-cluster-agent   docker.io/weaveworks/scope:1.13.2   app=weave-scope,name=weave-scope-cluster-agent,weave-cloud-component=scope,weave-scope-component=cluster-agent
deployment.apps/weave-scope-app             1/1     1            1           95s   app                   weaveworks/scope:1.13.2             app=weave-scope

NAME                                                   DESIRED   CURRENT   READY   AGE   CONTAINERS            IMAGES                              SELECTOR
replicaset.apps/weave-scope-cluster-agent-84f7b6767c   1         1         1       95s   scope-cluster-agent   docker.io/weaveworks/scope:1.13.2   app=weave-scope,name=weave-scope-cluster-agent,pod-template-hash=84f7b6767c,weave-cloud-component=scope,weave-scope-component=cluster-agent
replicaset.apps/weave-scope-app-658845597b             1         1         1       95s   app                   weaveworks/scope:1.13.2             app=weave-scope,pod-template-hash=658845597b

以下コマンドを使ってpodをexposeします。

root@k8s-master:~# kubectl port-forward -n weave "$(kubectl get -n weave pod --selector=weave-scope-component=app -o jsonpath='{.items..metadata.name}')" 4040 --address 0.0.0.0
Forwarding from 0.0.0.0:4040 -> 4040
Handling connection for 4040
Handling connection for 4040
Handling connection for 4040

http://"nodeのIP":4040をwebブラウザで検索するとweave scopeのWebUIが表示されます。i
以下はプロセス連携を示す画面です。
image.png

k8sクラスタ上のpod一覧です。
image.png

podのdescribeを見れたりします。確認出来ていませんがコンテナをこの画面で操作することも出来るッぽいですね。
image.png

各nodeのCPU/Memoryのusageも確認出来ます。

image.png

環境が邪魔になったら以下コマンドを実行して、一掃しましょう。

root@k8s-master:~# kubectl delete  -f https://github.com/weaveworks/scope/releases/download/v1.13.2/k8s-scope.yaml
namespace "weave" deleted
clusterrole.rbac.authorization.k8s.io "weave-scope" deleted
clusterrolebinding.rbac.authorization.k8s.io "weave-scope" deleted
deployment.apps "weave-scope-app" deleted
daemonset.apps "weave-scope-agent" deleted
deployment.apps "weave-scope-cluster-agent" deleted
serviceaccount "weave-scope" deleted
service "weave-scope-app" deleted

感想的なサムシング

機能がたくさんあり、k8sの勉強をしながら触ってみて使えそうかどうかを判断していきたいと思いました。特にプロセス間連携やネットワーク周りがきれいに可視化されると煩雑なk8s環境を把握するのに大変役立ちそう。そのあたりに期待です。kubernetes dashboardにはそのあたりの機能が無い認識なので・・・
k8s関連は色々WebUIがあるので、それぞれ触ってみて自分の目的が果たせそうなものを使用していくのが良いんでしょうね。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1