kubernetes-yaml/examples/kiwix-serve/kiwix-serve.yaml

164 lines
4.0 KiB
YAML
Raw Normal View History

2023-12-15 16:39:01 +08:00
---
# 创建 Namespace
apiVersion: v1
kind: Namespace
metadata:
name: hty1024-app
---
# 创建 StorageClass
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: storage-local-kiwix-serve
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: storageClass
provisioner: kubernetes.io/no-provisioner
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
---
# 创建 PersistentVolume
apiVersion: v1
kind: PersistentVolume
metadata:
name: hty1024-app-kiwix-serve-pv
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: persistentVolume
spec:
capacity:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: storage-local-kiwix-serve
local:
path: /app/kiwix-serve/data
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: node.k8s.hty1024.com/type
operator: In
values:
- app
---
# 创建 PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hty1024-app-kiwix-serve-pvc
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: persistentVolumeClaim
spec:
resources:
requests:
storage: 100Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
storageClassName: storage-local-kiwix-serve
---
# 创建 Service
apiVersion: v1
kind: Service
metadata:
name: hty1024-app-kiwix-serve-service
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: service
spec:
type: NodePort
ports:
- port: 10080
targetPort: 10080
nodePort: 30000
selector:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: pod
---
# 创建 Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: hty1024-app-kiwix-serve-deployment
namespace: hty1024-app
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: deployment
spec:
replicas: 1
minReadySeconds: 30
selector:
matchLabels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: pod
template:
metadata:
labels:
app.k8s.hty1024.com/env: prod
app.k8s.hty1024.com/type: app
app.k8s.hty1024.com/name: kiwix-serve
app.k8s.hty1024.com/version: 3.6.0-alpine
app.k8s.hty1024.com/resources: pod
spec:
terminationGracePeriodSeconds: 60
volumes:
- name: localtime
hostPath:
path: /etc/localtime
- name: hty1024-app-kiwix-serve-data
persistentVolumeClaim:
claimName: hty1024-app-kiwix-serve-pvc
containers:
- name: kiwix-serve
image: hub.hty1024.com/hty1024/kiwix-serve:3.6.0-alpine
ports:
- name: tcp
containerPort: 10080
volumeMounts:
- name: localtime
mountPath: /etc/localtime
readOnly: true
- name: hty1024-app-kiwix-serve-data
mountPath: /data
nodeSelector:
node.k8s.hty1024.com/type: app