zhong (钟鹏群) 2 weeks ago
parent
commit
44b4cc7476
1 changed files with 77 additions and 0 deletions
  1. 77 0
      deployments/gogs-nodeport-deployment.yaml

+ 77 - 0
deployments/gogs-nodeport-deployment.yaml

@@ -0,0 +1,77 @@
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: gogs-config
+  namespace: nginx-app
+data:
+  app.ini: |
+    [server]
+    HTTP_ADDR = 0.0.0.0
+    HTTP_PORT = 3000
+    ROOT_URL = http://gogs2.9981.tech/
+    DOMAIN = gogs2.9981.tech
+
+    [database]
+    DB_TYPE = sqlite3
+    PATH = /data/gogs.db
+
+    [repository]
+    ROOT = /data/git/gogs-repo
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: gogs
+  namespace: nginx-app
+  labels:
+    app: gogs
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: gogs
+  template:
+    metadata:
+      labels:
+        app: gogs
+    spec:
+      containers:
+      - name: gogs
+        image: registry.cn-hangzhou.aliyuncs.com/zhongpengqun/wanderer:linux-amd64-gogs-0.13
+        command: ["/app/gogs/gogs"]
+        args: ["web", "--config", "/data/gogs/conf/app.ini"]
+        ports:
+        - containerPort: 3000
+        env:
+        - name: GOGS_SERVER_HTTP_ADDR
+          value: "0.0.0.0"
+        volumeMounts:
+        - name: gogs-data
+          mountPath: /data
+        - name: gogs-config
+          mountPath: /data/gogs/conf/app.ini
+          subPath: app.ini
+      volumes:
+      - name: gogs-data
+        persistentVolumeClaim:
+          claimName: gogs-pvc
+      - name: gogs-config
+        configMap:
+          name: gogs-config
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: gogs-service
+  namespace: nginx-app
+spec:
+  type: NodePort      # <--- 改成这个
+  selector:
+    app: gogs
+  ports:
+  - name: http
+    port: 3000
+    targetPort: 3000
+    nodePort: 30300   # <--- 固定端口