Skip to content

Commit

Permalink
perf: modify k8s session
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeEirc committed Jan 21, 2025
1 parent a9dd165 commit a306b7a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ RUN set -ex \
&& mkdir -p /opt/koko/bin \
&& wget ${DOWNLOAD_URL}/public/kubectl-linux-${TARGETARCH}.tar.gz -O kubectl.tar.gz \
&& tar -xf kubectl.tar.gz -C /opt/koko/bin/ \
&& mv /opt/koko/bin/kubectl /opt/koko/bin/rawkubectl \
&& wget -O helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-${TARGETARCH}.tar.gz \
&& tar -xf helm.tar.gz --strip-components=1 -C /opt/koko/bin/ linux-${TARGETARCH}/helm \
&& mv /opt/koko/bin/helm /opt/koko/bin/rawhelm \
&& \
if [ "${TARGETARCH}" == "amd64" ] || [ "${TARGETARCH}" == "arm64" ]; then \
wget ${DOWNLOAD_URL}/files/clickhouse/22.20.2.11/clickhouse-client-linux-${TARGETARCH}.tar.gz; \
Expand Down Expand Up @@ -71,9 +69,7 @@ RUN --mount=type=cache,target=/root/.cache \
set +x \
&& make build -s \
&& set -x && ls -al . \
&& mv /opt/koko/build/koko-linux-${TARGETARCH} /opt/koko/koko \
&& mv /opt/koko/build/helm-linux-${TARGETARCH} /opt/koko/bin/helm \
&& mv /opt/koko/build/kubectl-linux-${TARGETARCH} /opt/koko/bin/kubectl
&& mv /opt/koko/build/koko-linux-${TARGETARCH} /opt/koko/koko

RUN mkdir /opt/koko/release \
&& mv /opt/koko/locale /opt/koko/release \
Expand Down
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ endef

build:
$(KOKOBUILD) -o $(BUILDDIR)/$(NAME)-$(CURRENT_OS_ARCH) $(KOKOSRCFILE)
$(K8SCMDBUILD) -o $(BUILDDIR)/kubectl-$(CURRENT_OS_ARCH) $(KUBECTLFILE)
$(K8SCMDBUILD) -o $(BUILDDIR)/helm-$(CURRENT_OS_ARCH) $(HELMFILE)

all: koko-ui
$(call make_artifact_full,darwin,amd64)
Expand Down
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@ init_jms_k8s_user

# 放开部分需要的可执行权限
chmod 755 `which mysql` `which psql` `which mongosh` `which tsql` `which redis` `which clickhouse-client`
chmod 755 `which kubectl` `which rawkubectl` `which helm` `which rawhelm`
chmod 755 `which kubectl` `which helm`

# k8s 集群连接需要的命令
chown :jms_k8s_user `which jq` `which less` `which vim` `which ls` `which bash` `which grep`
chmod 750 `which jq` `which less` `which vim` `which ls` `which bash` `which grep`
# 创建 server.key server.crt
if [ ! -f /opt/koko/server.key ]; then
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /opt/koko/server.key -out /opt/koko/server.crt -subj "/C=CN/ST=Beijing/L=Beijing/O=JumpServer/OU=JumpServer/CN=JumpServer"
fi

# /opt/koko to 700 disable other user access
chmod 700 /opt/koko

cd /opt/koko
./koko
2 changes: 0 additions & 2 deletions pkg/httpd/tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"io"
"sync"

"github.com/jumpserver/koko/pkg/srvconn"

"github.com/gliderlabs/ssh"
"github.com/jumpserver/koko/pkg/exchange"
"github.com/jumpserver/koko/pkg/jms-sdk-go/common"
Expand Down
6 changes: 0 additions & 6 deletions pkg/httpd/userwebsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import (
"io"
"time"

"github.com/jumpserver/koko/pkg/proxy"
"github.com/jumpserver/koko/pkg/srvconn"

"github.com/gin-gonic/gin"
gorilla "github.com/gorilla/websocket"

Expand Down Expand Up @@ -103,9 +100,6 @@ func (userCon *UserWebsocket) Run() {
case <-ctx.Done():
}
userCon.handler.CleanUp()
if userCon.k8sClient != nil {
userCon.k8sClient.Close()
}

logger.Infof("Ws[%s] done with exit %s", userCon.Uuid, errMsg)
}
Expand Down

0 comments on commit a306b7a

Please sign in to comment.