gitea是一个轻量级的私有代码仓库,mysql是关系型数据库的一种。
部署mysql持久化存储pv和pvc.yaml如下,我这里用的ceph做的分布式存储
apiVersion: v1 kind: PersistentVolume metadata: name: mysql-rbd-pv spec: capacity: storage: 1Gi accessModes: - ReadWriteOnce - ReadOnlyMany rbd: monitors: - 192.168.136.129:6789 - 192.168.136.149:6789 - 192.168.136.132:6789 pool: rbd image: rbd1 user: admin secretRef: name: ceph-secret fsType: xfs persistentVolumeReclaimPolicy: Retain --- kind: PersistentVolumeClaim apiVersion: v1 metadata: name: mysql-rbd-pvc spec: accessModes: - ReadWriteOnce - ReadOnlyMany resources: requests: storage: 1Gi
部署mysql的dep.yaml和svc.yaml如下
apiVersion: apps/v1 kind: Deployment metadata: name: mysql spec: selector: matchLabels: app: mysql replicas: 1 template: metadata: labels: app: mysql spec: containers: - name: mysql image: mysql:5.7 imagePullPolicy: IfNotPresent env: - name: MYSQL_ALLOW_EMPTY_PASSWORD value: "1" - name: MYSQL_ROOT_PASSWORD value: "123456" ports: - name: mysql containerPort: 3306 volumeMounts: - name: data mountPath: /var/lib/mysql subPath: mysql resources: requests: cpu: 500m memory: 1Gi volumes: - name: data persistentVolumeClaim: claimName: mysql-rbd-pvc --- apiVersion: v1 kind: Service metadata: name: mysql-svc labels: app: mysql spec: selector: app: mysql type: NodePort ports: - name: database port: 3306 targetPort: mysql nodePort: 30006
部署gitea的dep.yaml和svc.yaml如下
apiVersion: apps/v1 kind: Deployment metadata: name: gitea-dep labels: app: gitea spec: replicas: 1 selector: matchLabels: app: gitea template: metadata: labels: app: gitea spec: terminationGracePeriodSeconds: 35 containers: - name: gitea image: gitea/gitea imagePullPolicy: IfNotPresent env: - name: DEMO_GREETING value: "my-env" ports: - containerPort: 3000 name: app-port protocol: TCP - containerPort: 22 name: ssh-port protocol: TCP volumeMounts: - name: date-time mountPath: /etc/localtime volumes: - name: date-time hostPath: path: /etc/localtime --- apiVersion: v1 kind: Service metadata: name: gitea-svc labels: app: gitea spec: selector: app: gitea type: NodePort ports: - name: web port: 3000 targetPort: app-port nodePort: 30002 - name: ssh port: 222 targetPort: ssh-port nodePort: 30222