Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added k8s manifests #158

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions k8s/00_namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: cronicle
spec:
finalizers:
- kubernetes
status:
phase: Active

13 changes: 13 additions & 0 deletions k8s/01_pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: cronicle-server-data
namespace: cronicle
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 512m

16 changes: 16 additions & 0 deletions k8s/02_netpol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-all
namespace: cronicle
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress:
- {}
egress:
- {}

38 changes: 38 additions & 0 deletions k8s/03_ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cronicle-ui-primary
namespace: cronicle
annotations:
kubernetes.io/ingress.class: traefik
# Uncomment if use nginx-ingress controller
# kubernetes.io/ingress.class: nginx
spec:
rules:
- host: cronicle.example.com
http:
paths:
- backend:
serviceName: cronicle-ui-primary
servicePort: http

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cronicle-ui-secondary
namespace: cronicle
annotations:
kubernetes.io/ingress.class: traefik
# Uncomment if use nginx-ingress controller
# kubernetes.io/ingress.class: nginx
spec:
rules:
- host: backup.cronicle.example.com
http:
paths:
- backend:
serviceName: cronicle-ui-secondary
servicePort: http

30 changes: 30 additions & 0 deletions k8s/04_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
apiVersion: v1
kind: Service
metadata:
name: cronicle-ui-primary
namespace: cronicle
spec:
type: ClusterIP
ports:
- name: http
port: 3012
selector:
app: cronicle-server
server-role: primary

---
apiVersion: v1
kind: Service
metadata:
name: cronicle-ui-secondary
namespace: cronicle
spec:
type: ClusterIP
ports:
- name: http
port: 3012
selector:
app: cronicle-server
server-role: secondary

68 changes: 68 additions & 0 deletions k8s/09_deployment_client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: cronicle-client
name: cronicle-client
namespace: cronicle
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
selector:
matchLabels:
app: cronicle-client
template:
metadata:
labels:
app: cronicle-client
name: cronicle-client
spec:
containers:
- name: cronicle-client
image: intelliops/cronicle:0.8.28
imagePullPolicy: IfNotPresent
env:
- name: CRONICLE_base_app_url
value: http://cronicle.example.com
- name: CRONICLE_secret_key
value: Iogh8noo3eDoo7aiP1hahkeicu3Aneid
- name: CRONICLE_web_socket_use_hostnames
value: 'true'
- name: CRONICLE_server_comm_use_hostnames
value: 'false'
ports:
- name: http
containerPort: 3012
- name: broadcast-tcp
containerPort: 3014
- name: broadcast-udp
containerPort: 3014
protocol: UDP
resources:
requests:
cpu: 100m
memory: 64M
limits:
cpu: 1000m
memory: 512M
volumeMounts:
- name: data
mountPath: /opt/cronicle/data
initContainers:
- name: setup-done
image: busybox
command:
- touch
- /opt/cronicle/data/.setup_done
volumeMounts:
- name: data
mountPath: /opt/cronicle/data
restartPolicy: Always
volumes:
- name: data
emptyDir: {}

61 changes: 61 additions & 0 deletions k8s/09_statefulset_server_primary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: cronicle-server
server-role: primary
name: cronicle-server-primary
namespace: cronicle
spec:
replicas: 1
selector:
matchLabels:
app: cronicle-server
serviceName: cronicle-server
template:
metadata:
labels:
app: cronicle-server
server-role: primary
name: cronicle-server
spec:
containers:
- name: cronicle-server
image: intelliops/cronicle:0.8.28
imagePullPolicy: IfNotPresent
env:
- name: CRONICLE_base_app_url
value: http://cronicle.example.com
- name: CRONICLE_secret_key
value: Iogh8noo3eDoo7aiP1hahkeicu3Aneid
- name: CRONICLE_web_socket_use_hostnames
value: 'true'
- name: CRONICLE_server_comm_use_hostnames
value: 'false'
ports:
- name: http
containerPort: 3012
- name: broadcast-tcp
containerPort: 3014
- name: broadcast-udp
containerPort: 3014
protocol: UDP
resources:
requests:
cpu: 100m
memory: 64M
limits:
cpu: 1000m
memory: 512M
volumeMounts:
- name: data
mountPath: /opt/cronicle/data
restartPolicy: Always
volumes:
- name: data
persistentVolumeClaim:
claimName: cronicle-server-data
updateStrategy:
type: RollingUpdate

70 changes: 70 additions & 0 deletions k8s/09_statefulset_server_secondary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app: cronicle-server
server-role: secondary
name: cronicle-server-secondary
namespace: cronicle
spec:
replicas: 1
selector:
matchLabels:
app: cronicle-server
serviceName: cronicle-server
template:
metadata:
labels:
app: cronicle-server
server-role: secondary
name: cronicle-server
spec:
containers:
- name: cronicle-server
image: intelliops/cronicle:0.8.28
imagePullPolicy: IfNotPresent
env:
- name: CRONICLE_base_app_url
value: http://cronicle.example.com
- name: CRONICLE_secret_key
value: Iogh8noo3eDoo7aiP1hahkeicu3Aneid
- name: CRONICLE_web_socket_use_hostnames
value: 'true'
- name: CRONICLE_server_comm_use_hostnames
value: 'false'
ports:
- name: http
containerPort: 3012
- name: broadcast-tcp
containerPort: 3014
- name: broadcast-udp
containerPort: 3014
protocol: UDP
resources:
requests:
cpu: 100m
memory: 64M
limits:
cpu: 1000m
memory: 512M
volumeMounts:
- name: data
mountPath: /opt/cronicle/data
initContainers:
- name: setup-done
image: busybox
command:
- touch
- /opt/cronicle/data/.setup_done
volumeMounts:
- name: data
mountPath: /opt/cronicle/data
restartPolicy: Always
volumes:
- name: data
persistentVolumeClaim:
claimName: cronicle-server-data
updateStrategy:
type: RollingUpdate

16 changes: 16 additions & 0 deletions k8s/READEME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Notes
You'll need an ingress controller such as Traefik or nginx to leverage the ingress YAML. If not, you'll have to modify the service to be NodePort instead.

### Quickstart
```$ kubectl apply -f ./k8s```

You should see one client, one primary master, and one secondary master when executing ```$ kubectl --namespace cronicle get pod``` similar to below.
```
NAME READY STATUS RESTARTS AGE
cronicle-client-586ff8fb6d-zxp4q 1/1 Running 0 32m
cronicle-server-primary-0 1/1 Running 0 32m
cronicle-server-secondary-0 1/1 Running 0 32m
```

Once all the pods are *running* you can hit http://cronicle.example.com and see cronicle. Remember to map *cronicle.example.com* to the right IP in your hosts file.