Kubernetes Dashboard 部署 gitea ,请给出示例代码
时间: 2024-02-01 14:13:01 浏览: 170
以下是一个简单的 Kubernetes Deployment YAML 文件示例,用于在 Kubernetes Dashboard 上部署 Gitea:
```
apiVersion: apps/v1
kind: Deployment
metadata:
name: gitea-deployment
spec:
replicas: 1
selector:
matchLabels:
app: gitea
template:
metadata:
labels:
app: gitea
spec:
containers:
- name: gitea
image: gitea/gitea:latest
ports:
- containerPort: 3000
volumeMounts:
- name: gitea-storage
mountPath: /data
volumes:
- name: gitea-storage
persistentVolumeClaim:
claimName: gitea-pvc
---
apiVersion: v1
kind: Service
metadata:
name: gitea-service
spec:
selector:
app: gitea
ports:
- name: http
port: 80
targetPort: 3000
type: ClusterIP
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gitea-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
```
这个示例文件中包含三个 Kubernetes 资源:Deployment、Service 和 PersistentVolumeClaim。Deployment 定义了 Gitea 的 Pod 模板,Service 公开了 Gitea 应用程序的端口并将其暴露在 Kubernetes 群集内,而 PersistentVolumeClaim 提供了持久化存储用于 Gitea 数据存储。
你可以将以上 YAML 文件保存为 `gitea-deployment.yaml` 文件,然后通过 Kubernetes Dashboard 运行以下命令进行部署:
```
kubectl apply -f gitea-deployment.yaml
```
阅读全文