k3s 部署应用小案例 - gogs

编辑一个 yaml,命名为 gogs.yaml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gogs
labels:
app: gogs
spec:
replicas: 3
selector:
matchLabels:
app: gogs
template:
metadata:
labels:
app: gogs
spec:
containers:
- name: gogs
image: gogs/gogs
ports:
- containerPort: 3000
volumeMounts:
- mountPath: /etc/localtime
name: local-time
- mountPath: /etc/timezone
name: time-zone
volumes:
- name: local-time
hostPath:
path: /etc/localtime
- name: time-zone
hostPath:
path: /etc/timezone
---
apiVersion: v1
kind: Service
metadata:
name: gogs
spec:
ports:
- port: 3000
targetPort: 3000
nodePort: 32000
protocol: TCP
selector:
app: gogs
type: NodePort

部署:

1
kubectl apply -f gogs.yaml

删除:

1
kubectl delete -f gogs.yaml

仅作实验,gogs 真的要运行还得做 /data 盘符的共享映射。所以此处通过访问 http://192.168.88.131:32000/ 可以访问到页面即为成功。