核心
hostAliases:# 解决服务器内,因路由器配置不全, 不能访问外网问题- hostnames:- graph.requarks.ioip: 104.26.14.122
案例 wiki k8s Deployment
直接 编辑修改 Deployment
kubectl edit Deployment wiki
最后内容如下,如需保存 按 esc
键,最后输入 :wq
保存退出,容器会自动重新生成新的
apiVersion: apps/v1
kind: Deployment
metadata:labels:app: wikiname: wiki
spec:replicas: 1revisionHistoryLimit: 5selector:matchLabels:app: wikitemplate:metadata:labels:app: wikispec:hostAliases:# 解决服务器内,因路由器配置不全, 不能访问外网问题- hostnames:- graph.requarks.ioip: 104.26.14.122containers:- env:- name: TZvalue: Asia/Shanghai- name: DB_USERvalue: fox- name: DB_PASSvalue: password- name: DB_NAMEvalue: wiki- name: DB_HOSTvalue: postgres- name: DB_TYPEvalue: postgres- name: DB_PORTvalue: "5432"image: 'ghcr.io/requarks/wiki:2'name: wikiimagePullPolicy: IfNotPresentports:- containerPort: 3000protocol: TCP
# resources:
# limits:
# memory: 2Gi
# requests:
# memory: 2GivolumeMounts:- name: vm-datamountPath: /wiki/data- name: vm-contentmountPath: /wiki/content- name: vm-definitionmountPath: /wiki/server/modules/search/postgres/definition.ymlrestartPolicy: AlwaysterminationGracePeriodSeconds: 30volumes:- name: vm-datahostPath:# 宿主机目录path: /www/websites/wiki/data# hostPath 卷指定 type,如果目录不存在则创建(可创建多层目录)type: DirectoryOrCreate- name: vm-contenthostPath:# 宿主机目录path: /www/websites/wiki/content# hostPath 卷指定 type,如果目录不存在则创建(可创建多层目录)type: DirectoryOrCreate- name: vm-definitionhostPath:path: /www/websites/wiki/search/definition.ymltype: FileOrCreate