Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用kubernetes部署此项目 #533

Open
LinuxZilong opened this issue Oct 18, 2023 · 7 comments
Open

使用kubernetes部署此项目 #533

LinuxZilong opened this issue Oct 18, 2023 · 7 comments

Comments

@LinuxZilong
Copy link
Contributor

是否可以考虑在项目主页上,添加一个可被k8s直接部署使用的yaml文件;使用wget 或是 自己复制粘贴到文件中,再使用kubectl apply -f XXX.yaml 来快速在k8s集群中部署项目。针对存放md的文件,可以考虑将路径挂载至容器所在node上,这样可以更为便捷的增改md文件,例如一个公司,将此项目部署至内网,此时公司有些自己开发的私有命令,可以自行编辑md文件,并放入至项目中。

@jaywcjlove
Copy link
Owner

@LinuxZilong 可以,欢迎提交 PR

@LinuxZilong
Copy link
Contributor Author

LinuxZilong commented Oct 18, 2023

我写了yaml脚本,还需要做些优化。我使用的是项目主页上的docker镜像,我发现无法通过shell进入到容器内部,我不知道路径是什么,无法将容器内的目录挂载到Node节点上

@jaywcjlove
Copy link
Owner

jaywcjlove commented Oct 18, 2023

这可能是使用最小镜像导致的 @LinuxZilong

# https://github.com/forksss/docker-static-website
FROM wcjiang/docker-static-website:latest

@LinuxZilong
Copy link
Contributor Author

这可能是使用最小镜像导致的 @LinuxZilong

# https://github.com/forksss/docker-static-website
FROM wcjiang/docker-static-website:latest

应该是你构建docker镜像时,使用的基础镜像就没有进入容器的shell,我正在尝试解决这个问题,但没有什么好的思路;根据你的docker file文件,md文件都在 root的家目录下吗?

@LinuxZilong
Copy link
Contributor Author

LinuxZilong commented Oct 18, 2023

apiVersion: v1
kind: Namespace
metadata:
name: linux-command

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: linux-command
namespace: linux-command
labels:
app: linux-command
spec:
replicas: 1
selector:
matchLabels:
app: linux-command
template:
metadata:
labels:
app: linux-command
spec:
containers:
- name: linux-command
image: wcjiang/linux-command:latest
imagePullPolicy: Never
readinessProbe:
httpGet:
port: 3000
---
apiVersion: v1
kind: Service
metadata:
name: svc-linux-command
namespace: linux-command
labels:
app: linux-command
spec:
type: NodePort
ports:
- name: web
port: 9665
targetPort: 3000
nodePort: 9665
selector:
app: linux-command

现在的代码如上,可能nodeport的方式并不适合,如果集群比较大,每个集群的nodeport都会占用一个端口,有端口冲突的风险。可能ingress可以解决这个问题,我对ingress不熟悉。如果真的有人使用k8s搭建此项目,应该不会放到生产集群上吧

@jaywcjlove
Copy link
Owner

这可能是使用最小镜像导致的 @LinuxZilong

# https://github.com/forksss/docker-static-website
FROM wcjiang/docker-static-website:latest

应该是你构建docker镜像时,使用的基础镜像就没有进入容器的shell,我正在尝试解决这个问题,但没有什么好的思路;根据你的docker file文件,md文件都在 root的家目录下吗?

完整 docker file 文件在这里
https://github.com/forksss/docker-static-website/blob/master/Dockerfile

@LinuxZilong
Copy link
Contributor Author

这可能是使用最小镜像导致的 @LinuxZilong

# https://github.com/forksss/docker-static-website
FROM wcjiang/docker-static-website:latest

应该是你构建docker镜像时,使用的基础镜像就没有进入容器的shell,我正在尝试解决这个问题,但没有什么好的思路;根据你的docker file文件,md文件都在 root的家目录下吗?

完整 docker file 文件在这里 https://github.com/forksss/docker-static-website/blob/master/Dockerfile

我这两天想了一下,持久化存储就不定义了吧,这个根据实际情况好写,我怕根据架构的不同,无法兼容。nfs或是固定到一个服务器的路径上,都不太合适。我建议:就用我上面的代码,如果他们有私有化知识库的需求,在自行配置持久化存储。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants