alibaba / higress

🤖 AI Gateway | AI Native API Gateway
https://higress.io
Apache License 2.0
3.23k stars 510 forks source link

HEP: add support for `hgctl` cmd #229

Open Xunzhuo opened 1 year ago

Xunzhuo commented 1 year ago

Why do you need it?

Add command line called hgctl, provides abilities for API Gateway operators/cluster developers to manage/debug/analyze higress control plane and data plane.

Features:

Some init commands for hgctl:

CI:

xcbeyond commented 1 year ago

assign to me.

Xunzhuo commented 1 year ago

Thanks @xcbeyond, but there are some pre-tasks I am working on. I will separate this issue into sub-tasks to be assignable.

xcbeyond commented 1 year ago

Thanks @xcbeyond, but there are some pre-tasks I am working on. I will separate this issue into sub-tasks to be assignable.

@Xunzhuo ok, I'll pick up the assignment after we break it down

CH3CHO commented 1 year ago

After discussing with @johnlanni , we think it would be better to add a hgctl ui command to perform port-forward operation on 8080 port of Higress Console and open the console page directly, so user doesn't need to worry about Higress Console being blocked by some incorrect configurations on the Gateway itself, since the Ingress route of Higress Console is also served by the said gateway.

Xunzhuo commented 1 year ago

@CH3CHO LGFM, similar to istioctl dashboard

CH3CHO commented 1 year ago

@CH3CHO LGFM, similar to istioctl dashboard

Then should I create a separate issue for this sub-command?

2456868764 commented 1 year ago

hgctl install demo 如下

  1. 本地 kind 环境安装

    hgctl install --set profile=kind --set global.install=local --set global.enableIstioAPI=true --set gateway.replicas=2  --set console. o11yEnabled=true
  2. 本地 docker 环境安装

hgctl install --set profile=kind --set global.install=docker   --set nacos.url=nacos://192.168.0.1:8848 --set console.adminPassword=admin

关于 hgctl install 具体配置元数据 yaml 结构如下:

profile: kind
global:
  install: local # install mode k8s/local/docker
  ingressClass: higress
  watchNamespace:
  disableAlpnH2: true
  enableStatus: true
  enableIstioAPI: false
  namespace: higress-system

console:
  port: 8080
  replicas: 1
  serviceType: ClusterIP
  domain: console.higress.io
  tlsSecretName:
  webLoginPrompt:
  adminPassword: admin
  o11yEnabled: false
  pvcRwxSupported: true

gateway:
  replicas: 1
  httpPort: 80
  httpsPort: 443
  metricsPort: 15020

controller:
  replicas: 1

nacos:
  useBuiltin: false
  port: 8848
  url: nacos://192.168.0.1:8848 #  file://opt/higress/conf
  ns: higress-system
  username:
  password:
  dataEncKey:

# values passed through to helm
values:

charts:
  higress:
    chartUrl: https://higress.io/helm-charts
    chartName: higress
    chartVersion: 1.1.1
  istio:
    chartUrl: https://istio-release.storage.googleapis.com/charts
    chartName: base
    chartVersion: 1.18.2
johnlanni commented 1 year ago

@2456868764 有两个问题:

  1. 本地K8s环境,kind 是否用 local-k8s 更合理,本地docker环境,kind用 local-docker,未来我们还会提供纯 local 的方式,直接基于binary部署;另外是否这个kind可以无需指定,而是根据当前是否有 kubectl 命令,以及docker命令来自动选择。
  2. nacos 是local-docker/local模式下的配置来源,配置url所属的第一配置层级不应该是nacos,应该是configure,是通过配置的url里的协议头部分决定了是走nacos:nacos://
johnlanni commented 1 year ago

请 @CH3CHO 一起看下这块

2456868764 commented 1 year ago

@2456868764 有两个问题:

  1. 本地K8s环境,kind 是否用 local-k8s 更合理,本地docker环境,kind用 local-docker,未来我们还会提供纯 local 的方式,直接基于binary部署;另外是否这个kind可以无需指定,而是根据当前是否有 kubectl 命令,以及docker命令来自动选择。
  2. nacos 是local-docker/local模式下的配置来源,配置url所属的第一配置层级不应该是nacos,应该是configure,是通过配置的url里的协议头部分决定了是走nacos:nacos://
  1. OK, 四种安装方式 k8s, local-k8s, local-docker, local 分别对应 K8s环境, 本地K8s环境, 本地docker环境, 和 供纯 local ,同时提供不同方式安装默认profile, 用户可以指定profile 就可以安装。 但是用户环境比较复杂,比如同时有 kubectl和docker等,安装方式 profile 还是让用户明确来指定
  2. 关于 nacos 这块整体配置, 这块我理解是非K8环境安装后端存储配置内容。目前支持三种方式,用户指定nacos, buildin nacos, 和文件系统。 可以用URL部分的协议来区分, 可以优化如下配置
storage:
  url: nacos://192.168.0.1:8848 #  file://opt/higress/conf   或者  buildin://127.0.0.1:8848
  ns: higress-system
  username:
  password:
  dataEncKey:
johnlanni commented 1 year ago

@2456868764 用户指定了profile可以按指定的来,没有指定就按约定的来即可,profile不应该是必填的

2456868764 commented 1 year ago

目前支持 K8s环境(k8s), 本地K8s环境(local-k8s) 两个proifle 安装, 安装场景可以参考如下:

  1. 默认安装
    
    hgctl install 

Please select higress install configration profile: 1.Install higress to local kubernetes cluster like kind etc. 2.Install higress to kubernetes cluster Please input 1 or 2 to select, input your selection:

这里会输出 默认安装模式选择,让用户来选择当前安装环境

(如果 profile 没有指定,都会出现这个选择提示)

2. 指定 默认 profile 

hgctl install --set profile=local-k8s

3.指定 默认 profile 同时 简单定制 profile 参数

hgctl install --set profile=local-k8s --set global.enableIstioAPI=true --set gateway.replicas=2

4. 定制 profile 和 安装

生成 profile

hgctl profile dump --output=./custom_profile.yaml

编辑 custom_profile.yaml

指定profile 安装

hgctl install --set profile=./custom_profile.yaml

Xunzhuo commented 1 year ago

Track: https://github.com/alibaba/higress/pull/538