【Kubernetes】Octant部署

时间:2022-07-23
本文章向大家介绍【Kubernetes】Octant部署,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

去年 InfoQ 上发表了一篇 Octant: Local and Real-Time Dashboard for Kubernetes Workloads,Octant 是 VMvare 开源的类似 Kubernetes Dashboard 的一个工具,最近尝试在集群里部署了一下。 官方的部署文档没有给容器化的部署方式,因为我是在集群里部署的 Deployment,所以这里简单介绍一下。 部署是通过官方提供的 Dockerfile 来运行的容器,直接使用就可以了。主要需要注意一些参数。通过 docker run -it octant:latest bash 看下 octant 命令的 help 信息。

root@7acc99872bc8:/# ./octant -h
octant is a dashboard for high bandwidth cluster analysis operations

Usage:
  octant [flags]
  octant [command]

Available Commands:
  help        Help about any command
  version     Show version

Flags:
      --context string                initial context
      --disable-cluster-overview      disable cluster overview
      --enable-feature-applications   enable applications feature
      --kubeconfig string             absolute path to kubeConfig file
  -n, --namespace string              initial namespace
      --namespace-list strings        a list of namespaces to use on start
      --plugin-path string            plugin path
  -v, --verbose                       turn on debug logging
      --accepted-hosts string         accepted hosts list [DEV]
      --client-qps float32            maximum QPS for client [DEV] (default 200)
      --client-burst int              maximum burst for client throttle [DEV] (default 400)
      --disable-open-browser          disable automatic launching of the browser [DEV]
  -c, --enable-opencensus             enable open census [DEV]
      --klog-verbosity int            klog verbosity level [DEV]
      --listener-addr string          listener address for the octant frontend [DEV]
      --local-content string          local content path [DEV]
      --proxy-frontend string         url to send frontend request to [DEV]
      --ui-url string                 dashboard url [DEV]
      --browser-path string           the browser path to open the browser on
  -h, --help                          help for octant

这里需要注意的是 --disable-open-browser 这个参数要设置成 false,因为部署在容器里,所以就不需要直接打开你本地的浏览器了。其他的就是设置一下 --kubeconfig 就可以了。另外可以设置一下 OCTANT_LISTENER_ADDR 这个环境变量,完整的 Deplyment 的 Yaml 文件如下。

apiVersion: extensions/v1beta1
kind: Deployment
spec:
  template:
      containers:
      - args:
        - --kubeconfig
        - /kube.conf
        - --disable-open-browser
        command:
        - /octant
        env:
        - name: OCTANT_LISTENER_ADDR
          value: 0.0.0.0:8900
        image: hub.oa.com/runzhliu/octant:latest
        imagePullPolicy: Always
        resources:
          limits:
            cpu: "1"
            memory: 4Gi
          requests:
            cpu: "1"
            memory: 4Gi

最后通过创建 loadbalance 就可以在本地访问了。

Octant 跟 Dashboard 的定位是略有不同的,按照 Octant 官方的描述,他是想做一个可视化的 kubectl,所以简单感受一下,觉得暂时没有比 Dashboard 功能和展示丰富。 通过 Octant 的 Apply 功能来创建资源对象。

下面这个页面就很 kubectl 了。