Browse Source

feat(gogs k8s)

Douglas Andreani 4 years ago
commit
fc41b863b6
2 changed files with 118 additions and 0 deletions
  1. 60 0
      gogs/gogs.yml
  2. 58 0
      gogs/mysql.yaml

+ 60 - 0
gogs/gogs.yml

@@ -0,0 +1,60 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: gogs-default
+spec: 
+  replicas: 3
+  selector:
+    matchLabels:
+      app: gogs-default
+  template:
+    metadata:
+      labels:
+        app: gogs-default
+    spec:
+      nodeSelector:
+        "beta.kubernetes.io/os": linux
+      containers:
+      - name: gogs-default
+        image: gogs/gogs
+        resources:
+          requests:
+            cpu: 100m
+            memory: 256Mi
+        ports:
+          - containerPort: 3000
+        volumeMounts:
+        - name: gogs-pvc
+          mountPath: /data
+      volumes:
+      - name: gogs-pvc
+        persistentVolumeClaim:
+          claimName: gogs-pvc
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: gogs-pvc
+  labels:
+    app: gogs-default
+spec:
+  accessModes:
+    - ReadWriteOnce
+  resources: 
+    requests: 
+      storage: 10Gi
+
+---
+apiVersion: v1
+kind: Service
+metadata: 
+  name: gogs-svc
+  labels:
+    app: gogs-default
+spec:
+  ports: 
+  - port: 3000
+    protocol: TCP
+  selector:
+    app: gogs-default
+  type: LoadBalancer

+ 58 - 0
gogs/mysql.yaml

@@ -0,0 +1,58 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: mysql
+spec:
+  ports:
+  - port: 3306
+  selector:
+    app: mysql
+  clusterIP: None
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: mysql
+spec:
+  selector:
+    matchLabels:
+      app: mysql
+  strategy:
+    type: Recreate
+  template:
+    metadata:
+      labels:
+        app: mysql
+    spec:
+      containers:
+      - image: mysql:5.6
+        name: mysql
+        env:
+          # Use secret in real usage
+        - name: MYSQL_ROOT_PASSWORD
+          value: d5022a
+        ports:
+        - containerPort: 3306
+          name: mysql
+        volumeMounts:
+        - name: mysql-pvc
+          mountPath: /var/lib/mysql
+      volumes:
+      - name: mysql-pvc
+        persistentVolumeClaim:
+          claimName: mysql-pvc
+
+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  name: mysql-pvc
+  labels:
+    app: mysql
+spec:
+  accessModes:
+    - ReadWriteOnce
+  resources: 
+    requests: 
+      storage: 10Gi