核心
hostAliases:
# 解决服务器内,因路由器配置不全, 不能访问外网问题
- hostnames:
- graph.requarks.io
ip: 104.26.14.122
案例 wiki k8s Deployment
直接 编辑修改 Deployment文章来源:https://www.toymoban.com/news/detail-663441.html
kubectl edit Deployment wiki
最后内容如下,如需保存 按 esc
键,最后输入 :wq
保存退出,容器会自动重新生成新的文章来源地址https://www.toymoban.com/news/detail-663441.html
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: wiki
name: wiki
spec:
replicas: 1
revisionHistoryLimit: 5
selector:
matchLabels:
app: wiki
template:
metadata:
labels:
app: wiki
spec:
hostAliases:
# 解决服务器内,因路由器配置不全, 不能访问外网问题
- hostnames:
- graph.requarks.io
ip: 104.26.14.122
containers:
- env:
- name: TZ
value: Asia/Shanghai
- name: DB_USER
value: fox
- name: DB_PASS
value: password
- name: DB_NAME
value: wiki
- name: DB_HOST
value: postgres
- name: DB_TYPE
value: postgres
- name: DB_PORT
value: "5432"
image: 'ghcr.io/requarks/wiki:2'
name: wiki
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
protocol: TCP
# resources:
# limits:
# memory: 2Gi
# requests:
# memory: 2Gi
volumeMounts:
- name: vm-data
mountPath: /wiki/data
- name: vm-content
mountPath: /wiki/content
- name: vm-definition
mountPath: /wiki/server/modules/search/postgres/definition.yml
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- name: vm-data
hostPath:
# 宿主机目录
path: /www/websites/wiki/data
# hostPath 卷指定 type,如果目录不存在则创建(可创建多层目录)
type: DirectoryOrCreate
- name: vm-content
hostPath:
# 宿主机目录
path: /www/websites/wiki/content
# hostPath 卷指定 type,如果目录不存在则创建(可创建多层目录)
type: DirectoryOrCreate
- name: vm-definition
hostPath:
path: /www/websites/wiki/search/definition.yml
type: FileOrCreate
到了这里,关于k8s(Kubernetes)设置 pod,Deployment 域名自定义映射ip,hosts 解析 HostAliases的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!