核心
hostAliases:
# 解決服務(wù)器內(nèi),因路由器配置不全, 不能訪問(wèn)外網(wǎng)問(wèn)題
- hostnames:
- graph.requarks.io
ip: 104.26.14.122
案例 wiki k8s Deployment
直接 編輯修改 Deployment文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-663441.html
kubectl edit Deployment wiki
最后內(nèi)容如下,如需保存 按 esc
鍵,最后輸入 :wq
保存退出,容器會(huì)自動(dòng)重新生成新的文章來(lái)源地址http://www.zghlxwxcb.cn/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:
# 解決服務(wù)器內(nèi),因路由器配置不全, 不能訪問(wèn)外網(wǎng)問(wèn)題
- 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:
# 宿主機(jī)目錄
path: /www/websites/wiki/data
# hostPath 卷指定 type,如果目錄不存在則創(chuàng)建(可創(chuàng)建多層目錄)
type: DirectoryOrCreate
- name: vm-content
hostPath:
# 宿主機(jī)目錄
path: /www/websites/wiki/content
# hostPath 卷指定 type,如果目錄不存在則創(chuàng)建(可創(chuàng)建多層目錄)
type: DirectoryOrCreate
- name: vm-definition
hostPath:
path: /www/websites/wiki/search/definition.yml
type: FileOrCreate
到了這里,關(guān)于k8s(Kubernetes)設(shè)置 pod,Deployment 域名自定義映射ip,hosts 解析 HostAliases的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!