创建集群外访问的 Ingress
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: wikijs
spec:
ingressClassName: nginx
rules:
- host: wiki.ipincloud.cn
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: wikijs
port:
number: 3000
完整的 yaml 文件
以下是完整的通过 deployment 部署 mysql 数据库和 xwiki 的 yaml 文件,保存为 xwiki.yaml 。
apiVersion: v1
items:
- apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
cas.openebs.io/config: |
- name: StorageType
value: "hostpath"
- name: BasePath
value: "/var/openebs/localretain/"
openebs.io/cas-type: local
storageclass.beta.kubernetes.io/is-default-class: "false"
storageclass.kubesphere.io/supported-access-modes: '["ReadWriteOnce"]'
name: localretain
provisioner: openebs.io/local
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
kind: List
metadata:
resourceVersion: ""
selfLink: ""
---
kind: Secret
apiVersion: v1
metadata:
name: postgres-prod
data:
POSTGRES_PASSWORD: 自行填写
type: Opaque
---
apiVersion: v1
kind: ConfigMap
metadata:
name: wikijs-postgres-init
data:
init.sql: |-
CREATE DATABASE wikijs;
CREATE USER wikijs with password '自行填写';
GRANT CONNECT ON DATABASE wikijs to wikijs;
GRANT USAGE ON SCHEMA public TO wikijs;
GRANT SELECT,update,INSERT,delete ON ALL TABLES IN SCHEMA public TO wikijs;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO wikijs;
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-prod-data
finalizers:
- kubernetes.io/pvc-protection
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: localretain
volumeMode: Filesystem
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: postgres-prod
name: postgres-prod
spec:
replicas: 1
selector:
matchLabels:
app: postgres-prod
template:
metadata:
labels:
app: postgres-prod
spec:
containers:
- name: db
imagePullPolicy: IfNotPresent
image: 'postgres:14.2-alpine'
ports:
- name: tcp-5432
protocol: TCP
containerPort: 5432
envFrom:
- secretRef:
name: postgres-prod
volumeMounts:
- name: postgres-prod-data
readOnly: false
mountPath: /var/lib/postgresql/data
- name: wikijs-postgres-init
readOnly: true
mountPath: /docker-entrypoint-initdb.d
volumes:
- name: postgres-prod-data
persistentVolumeClaim:
claimName: postgres-prod-data
- name: wikijs-postgres-init
configMap:
name: wikijs-postgres-init
---
apiVersion: v1
kind: Service
metadata:
name: postgres-prod
spec:
selector:
app: postgres-prod
ports:
- protocol: TCP
port: 5432
targetPort: tcp-5432
---
apiVersion: v1
kind: ConfigMap
metadata:
name: adminer
data:
ADMINER_DESIGN: pappu687
ADMINER_PLUGINS: tables-filter
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: adminer
name: adminer
spec:
replicas: 1
selector:
matchLabels:
app: adminer
template:
metadata:
labels:
app: adminer
spec:
containers:
- name: adminer
image: 'adminer'
ports:
- name: http-9000
protocol: TCP
containerPort: 9000
envFrom:
- configMapRef:
name: adminer
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: adminer
name: adminer
spec:
replicas: 1
selector:
matchLabels:
app: adminer
template:
metadata:
labels:
app: adminer
spec:
containers:
- name: adminer
image: 'adminer'
ports:
- name: http-9000
protocol: TCP
containerPort: 9000
envFrom:
- configMapRef:
name: adminer
---
apiVersion: v1
kind: Service
metadata:
name: adminer
spec:
selector:
app: adminer
ports:
- protocol: TCP
port: 9000
targetPort: http-9000
---
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: adminer
spec:
ingressClassName: nginx
rules:
- host: adminer.ipincloud.cn
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: adminer
port:
number: 9000
---
apiVersion: v1
kind: Secret
metadata:
name: wikijs
data:
DB_USER: d2lraWpz
DB_PASS: 自行填写
type: Opaque
---
apiVersion: v1
kind: ConfigMap
metadata:
name: wikijs
data:
DB_TYPE: postgres
DB_HOST: postgres-prod.infra
DB_PORT: "5432"
DB_NAME: wikijs
HA_ACTIVE: "true"
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: wikijs
name: wikijs
spec:
replicas: 1
selector:
matchLabels:
app: wikijs
template:
metadata:
labels:
app: wikijs
spec:
containers:
- name: wikijs
image: 'requarks/wiki:2'
ports:
- name: http-3000
protocol: TCP
containerPort: 3000
envFrom:
- secretRef:
name: wikijs
- configMapRef:
name: wikijs
---
apiVersion: v1
kind: Service
metadata:
name: wikijs
spec:
selector:
app: wikijs
ports:
- protocol: TCP
port: 3000
targetPort: http-3000
---
kind: Ingress
apiVersion: networking.k8s.io/v1
metadata:
name: wikijs
spec:
ingressClassName: nginx
rules:
- host: wiki.ipincloud.cn
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: wikijs
port:
number: 3000