kubesphere使用ssh客户端连接到node

背景

在kubesphere的多集群环境中,web终端是可以执行kubectl命令的,因为有每个集群的kubeconfig配置。但它不能连接到具体某个节点上查看文件或者排查问题等。这时就需要一个ssh客户端来连接到节点上去。同时它还得以pod的形式存在。在每套环境中部署一个这样的客户端,这样就可以实现登录到这个pod,再ssh到node节点了。

当然,单集群环境中使用也是可以的。

打包镜像

只需要一个基础镜像,再安装一个ssh客户端即可。下面是一个示例的Dockerfile:

FROM alpine:latest
MAINTAINER wgh

RUN echo "http://mirrors.aliyun.com/alpine/v3.18/main/" > /etc/apk/repositories && \
    apk update && \
    apk add --no-cache ca-certificates openssh-client

打包

docker build -t xxx/ssh-client:latest .

查看镜像

docker images | grep ssh-client

部署deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: ssh-client
  name: ssh-client
  namespace: default
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: ssh-client
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: ssh-client
    spec:
      containers:
      - command:
        - sleep
        - infinity
        image: xxx/ssh-client:latest
        imagePullPolicy: IfNotPresent
        name: ssh-client
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30

kubectl apply -f ssh-client.yaml -n default

使用

使用web终端,登录到pod,再连接到node节点。

file

0 0 投票数
文章评分
订阅评论
提醒
guest

0 评论
内联反馈
查看所有评论

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部
0
希望看到您的想法,请您发表评论x