mirror of
				https://gitlab.com/game-loader/hugo.git
				synced 2025-10-30 14:18:49 +08:00 
			
		
		
		
	devops update
This commit is contained in:
		| @ -15,6 +15,94 @@ draft: false | ||||
|  | ||||
| minikube start 镜像拉取问题, | ||||
|  | ||||
| ### k8s secret 及 helm chart问题 | ||||
|  | ||||
| 在 Kubernetes 的 Secret 资源中,data 字段下的每个键(key)对应的值都应该是 整个内容 的 base64 编码,而不是对内容的每个部分分别进行 base64 编码。 | ||||
|  | ||||
| 如以下的helm chart中定义的secret.yaml | ||||
|  | ||||
| ```yaml | ||||
| apiVersion: v1 | ||||
| kind: Secret | ||||
| metadata: | ||||
|   name: {{ include "rag-with-es.fullname" . }}-rag-config | ||||
|   labels: | ||||
|     {{- include "rag-with-es.labels" . | nindent 4 }} | ||||
| type: Opaque | ||||
| data: | ||||
|   config.yaml: | | ||||
| {{- with .Values.rag.config }} | ||||
|     ES_HOST: {{ printf "http://%s-es-svc:%d" (include "rag-with-es.fullname" $) $.Values.es.service.port | b64enc }} | ||||
|     ES_USER: {{ .esUser | b64enc }} | ||||
|     ES_PASSWORD: {{ $.Values.es.config.elasticPassword | b64enc }} | ||||
|     ES_INDEX: {{ .esIndex | b64enc }} | ||||
|     EMBEDDING_API_BASE: {{ .embeddingApiBase | b64enc }} | ||||
|     EMBEDDING_API_KEY: {{ .embeddingApiKey | b64enc }} | ||||
|     EMBEDDING_API_MODEL: {{ .embeddingApiModel | b64enc }} | ||||
|     RERANKER_API_BASE: {{ .rerankerApiBase | b64enc }} | ||||
|     RERANKER_API_KEY: {{ .rerankerApiKey | b64enc }} | ||||
|     RERANKER_API_MODEL: {{ .rerankerApiModel | b64enc }} | ||||
| {{- end }} | ||||
|  | ||||
| ``` | ||||
|  | ||||
| 这个secret文件如果使用helm 部署时会显示base64解码错误,错误原因就在于config.yaml对应的值应该是一个完整的base64字符串,而当前的形式会导致仅ES_HOST等键对应的值被编码,ES_HOST等还是明文,故不能正常进行base64解析。正确的做法应为在\_helper.tbl中预定义config.yaml对应的模板然后将整个模板作为一个整体用base64编码,如下 | ||||
|  | ||||
| ```txt | ||||
| // _helper.tbl | ||||
|  | ||||
| {{/* | ||||
| 生成 config.yaml 的内容 | ||||
| */}} | ||||
| {{- define "rag-with-es.config" -}} | ||||
| {{- with .Values.rag.config }} | ||||
| ES_HOST: {{ printf "http://%s-es-svc:%d" (include "rag-with-es.fullname" $) $.Values.es.service.port }} | ||||
| ES_USER: {{ .esUser }} | ||||
| ES_PASSWORD: {{ $.Values.es.config.elasticPassword }} | ||||
| ES_INDEX: {{ .esIndex }} | ||||
| EMBEDDING_API_BASE: {{ .embeddingApiBase }} | ||||
| EMBEDDING_API_KEY: {{ .embeddingApiKey }} | ||||
| EMBEDDING_API_MODEL: {{ .embeddingApiModel }} | ||||
| RERANKER_API_BASE: {{ .rerankerApiBase }} | ||||
| RERANKER_API_KEY: {{ .rerankerApiKey }} | ||||
| RERANKER_API_MODEL: {{ .rerankerApiModel }} | ||||
| {{- end }} | ||||
| {{- end -}} | ||||
|  | ||||
| ``` | ||||
|  | ||||
| ```yaml | ||||
| apiVersion: v1 | ||||
| kind: Secret | ||||
| metadata: | ||||
|   name: {{ include "rag-with-es.fullname" . }}-rag-config | ||||
|   labels: | ||||
|     {{- include "rag-with-es.labels" . | nindent 4 }} | ||||
| type: Opaque | ||||
| data: | ||||
|   config.yaml: {{ include "rag-with-es.config" . | b64enc }} | ||||
| ``` | ||||
|  | ||||
| 这样即可正常使用helm部署。 | ||||
|  | ||||
| 另外可以将secret定义中的data改为使用stringData。stringData 是 Kubernetes Secret 资源中的一个可选字段,它允许用户以明文字符串的形式直接提供 Secret 数据,而不需要像 data 字段那样使用 Base64 编码。 | ||||
|  | ||||
| 当 Secret 被创建或更新时,stringData 中的内容会自动被转换为 Base64 编码, 转换后的内容会存储在 data 字段中,当读取 Secret 时,只能看到 data 字段,stringData 不会出现在 GET 操作的结果中。不需要手动进行 Base64 编码,特别适合在配置文件中直接写入明文值,对于包含多行内容的配置文件特别有用 | ||||
|  | ||||
| ```yaml | ||||
| apiVersion: v1 | ||||
| kind: Secret | ||||
| metadata: | ||||
|   name: mysecret | ||||
| data: | ||||
|   username: YWRtaW4= # Base64 编码 | ||||
| stringData: | ||||
|   config.yaml: | # 多行配置 | ||||
|     apiUrl: "https://api.example.com" | ||||
|     timeout: 3000 | ||||
|     retries: 5 | ||||
| ``` | ||||
|  | ||||
| ## 修复不同节点使用内网ip不互通的问题(异地组网) | ||||
|  | ||||
| ### 修改master节点flannel配置文件 | ||||
| @ -211,3 +299,31 @@ docker官方提供了傻瓜式安装脚本,为你做好所有工作,免去 | ||||
| 如使用阿里云镜像: | ||||
|  | ||||
| > curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun | ||||
|  | ||||
| ## k3s 入门手册 | ||||
|  | ||||
| ### 安装k3s | ||||
|  | ||||
| K3s 提供了一个安装脚本,可以方便地将其作为服务安装在基于 systemd 或 openrc 的系统上。该脚本可在 https://get.k3s.io 获得。要使用这种方法安装 K3s,只需运行: | ||||
|  | ||||
| > curl -sfL https://get.k3s.io | sh - | ||||
|  | ||||
| 备注 | ||||
| 中国用户,可以使用以下方法加速安装: | ||||
|  | ||||
| > curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL | ||||
|  | ||||
| ### 配置k3s镜像拉取镜像 | ||||
|  | ||||
| 参考 [k3s镜像配置](https://docs.k3s.io/zh/installation/private-registry) | ||||
|  | ||||
| 可供参考的registries.yaml为 | ||||
|  | ||||
| ```yaml | ||||
| mirrors: | ||||
|   docker.io: | ||||
|     endpoint: | ||||
|       - "docker-0.unsee.tech" | ||||
|       - "docker.1panel.live" | ||||
|       - "hub.fast360.xyz" | ||||
| ``` | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 gameloader
					gameloader