DEV Community

drake
drake

Posted on

用Kind 安装k8s和k8s dashboard


  • 2、 创建指定端口的集群

    • 2.1 编辑配置文件 'kind-example-config.yaml'
    kind: Cluster
    apiVersion: kind.x-k8s.io/v1alpha4
    networking:
    # WARNING: It is _strongly_ recommended that you keep this the default
    # (127.0.0.1) for security reasons. However it is possible to change this.
    apiServerAddress: "0.0.0.0"
    # By default the API server listens on a random open port.
    # You may choose a specific port but probably don't need to in most cases.
    # Using a random port makes it easier to spin up multiple clusters.
    apiServerPort: 6443
    nodes:
    - role: control-plane
    extraPortMappings:
    - containerPort: 30001
      hostPort: 30001
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30002
      hostPort: 30002
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30003
      hostPort: 30003
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30004
      hostPort: 30004
      listenAddress: "0.0.0.0"
      protocol: tcp
    - containerPort: 30005
      hostPort: 30005
      listenAddress: "0.0.0.0"
      protocol: tcp
    
    
    • 2.2 根据配置文件创建集群
    kind create cluster --config kind-example-config.yaml --name mycluster
    

  • 3、安装k8s dashboard

    • 3.1 下载配置文件
    wget https://raw.githubusercontent.com/kubernetes/dashboard/v2.7.0/aio/deploy/recommended.yaml
    
    • 3.2 编辑配置文件

    Image description

    • 3.3 根据配置文件执行安装
    kubectl apply -f recommended.yaml
    

  • 4、校验dashboard是否拉起
kubectl get deployments -n kubernetes-dashboard
Enter fullscreen mode Exit fullscreen mode

说明没毛病


  • 5、校验端口是否启用 netstat -tlnp > 能够看到30001端口在用,就是没毛病的 Image description


  • 7、生成token 参考官方文档

  • 8、登录态过期时间优化(默认15分钟)

    需要说明的是,登录态过期时间不是token过期时间,按照第7步生成的token是永久有效的,网上都说成了token过期时间,有歧义!
    修改流程参考 其中的43200 这个参数表示43200秒,也就是12小时;
    修改完配置后,重启下才能生效
    Image description

Top comments (0)