yaml如下:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: gitlab
name: gitlab
namespace: moonfdd
spec:
replicas: 1
selector:
matchLabels:
app: gitlab
template:
metadata:
labels:
app: gitlab
spec:
containers:
- image: 'gitlab/gitlab-ce'
imagePullPolicy: IfNotPresent
name: gitlab
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab
name: volv1
- mountPath: /var/log/gitlab
name: volv2
- mountPath: /var/opt/gitlab
name: volv3
volumes:
- hostPath:
path: /root/k8s/moonfdd/gitlab/etc/gitlab
type: DirectoryOrCreate
name: volv1
- hostPath:
path: /root/k8s/moonfdd/gitlab/var/log/gitlab
type: DirectoryOrCreate
name: volv2
- hostPath:
path: /root/k8s/moonfdd/gitlab/var/opt/gitlab
type: DirectoryOrCreate
name: volv3
---
apiVersion: v1
kind: Service
metadata:
labels:
app: gitlab
name: gitlab
namespace: moonfdd
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: gitlab
type: NodePort
结果如下:
gitlab的yaml