Skip to content

Commit

Permalink
chore: add simple k8s config
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed May 10, 2023
1 parent fc19096 commit 8818c03
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docker/simple/k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Its doc will tell you how to deploy `Tailchat` in kubeneters.

## One Command

```bash
kubectl apply -f namespace.yml -f pv.yml -f mongo.yml -f minio.yml -f redis.yml -f tailchat.yml
```

## Setup one by one

### Create Namespace

```bash
kubectl apply -f namespace.yml
```

### Create Persistent Volume

```bash
kubectl apply -f pv.yml
```

### Create Mongodb

```bash
kubectl apply -f mongo.yml
```

### Create Minio

```bash
kubectl apply -f minio.yml
```

### Create Redis

```bash
kubectl apply -f redis.yml
```

### Create Tailchat

```bash
kubectl apply -f tailchat.yml
```
55 changes: 55 additions & 0 deletions docker/simple/k8s/minio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: minio
namespace: tailchat
spec:
selector:
matchLabels:
app: minio
serviceName: minio
replicas: 1
template:
metadata:
labels:
app: minio
spec:
containers:
- name: minio
image: minio/minio
imagePullPolicy: IfNotPresent
env:
- name: MINIO_ROOT_USER
value: tailchat
- name: MINIO_ROOT_PASSWORD
value: com.msgbyte.tailchat
command:
- minio
- server
- /data/storage
- '--console-address'
- ':9001'
ports:
- containerPort: 9000
- containerPort: 9001
volumeMounts:
- name: minio-persistent-storage
mountPath: /data/tailchat/storage
volumes:
- name: minio-persistent-storage
persistentVolumeClaim:
claimName: minio-pvc
---
apiVersion: v1
kind: Service
metadata:
name: minio-service
namespace: tailchat
spec:
type: ClusterIP
selector:
app: minio
ports:
- protocol: TCP
port: 9000
targetPort: 9000
43 changes: 43 additions & 0 deletions docker/simple/k8s/mongo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
namespace: tailchat
spec:
selector:
matchLabels:
app: mongo
serviceName: mongo
replicas: 1
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:4
imagePullPolicy: IfNotPresent
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/tailchat/db
volumes:
- name: mongo-persistent-storage
persistentVolumeClaim:
claimName: mongo-pvc
---
apiVersion: v1
kind: Service
metadata:
name: mongo-service
namespace: tailchat
spec:
type: ClusterIP
selector:
app: mongo
ports:
- protocol: TCP
port: 27017
targetPort: 27017
4 changes: 4 additions & 0 deletions docker/simple/k8s/namespace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: tailchat
51 changes: 51 additions & 0 deletions docker/simple/k8s/pv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: mongo-pv
spec:
storageClassName: tailchat-db
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/tailchat/db
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-pvc
namespace: tailchat
spec:
storageClassName: tailchat-db
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: minio-pv
spec:
storageClassName: tailchat-storage
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /data/tailchat/storage
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minio-pvc
namespace: tailchat
spec:
storageClassName: tailchat-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
36 changes: 36 additions & 0 deletions docker/simple/k8s/redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis
namespace: tailchat
spec:
selector:
matchLabels:
app: redis
serviceName: redis
replicas: 1
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: redis:alpine
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
name: redis-service
namespace: tailchat
spec:
type: ClusterIP
selector:
app: redis
ports:
- protocol: TCP
port: 6379
targetPort: 6379
59 changes: 59 additions & 0 deletions docker/simple/k8s/tailchat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: tailchat
namespace: tailchat
spec:
selector:
matchLabels:
app: tailchat
replicas: 3
template:
metadata:
labels:
app: tailchat
spec:
containers:
- name: tailchat
image: moonrailgun/tailchat
imagePullPolicy: Always
env:
- name: SERVICEDIR
value: services
- name: TRANSPORTER
value: redis://redis-service:6379
- name: REDIS_URL
value: redis://redis-service:6379
- name: MONGO_URL
value: mongodb://mongo-service/tailchat
- name: SECRET
value: any-secret-keywords
- name: MINIO_URL
value: minio-service:9000
- name: MINIO_USER
value: tailchat
- name: MINIO_PASS
value: com.msgbyte.tailchat
ports:
- containerPort: 11000
resources:
requests:
cpu: 50m
memory: 51Mi
limits:
cpu: 500m
memory: 256Mi
---
apiVersion: v1
kind: Service
metadata:
name: tailchat-service
namespace: tailchat
spec:
type: ClusterIP
selector:
app: tailchat
ports:
- protocol: TCP
port: 11000
targetPort: 11000

0 comments on commit 8818c03

Please sign in to comment.