From 8f53fc1f163d08feb7c8361d4a0612cd426ecbde Mon Sep 17 00:00:00 2001 From: Chung Tran Date: Thu, 28 Feb 2019 20:40:54 -0500 Subject: [PATCH 1/3] Added k8s manifests. --- k8s/00_namespace.yaml | 11 ++++ k8s/01_pvc.yaml | 13 +++++ k8s/02_netpol.yaml | 16 ++++++ k8s/03_ingress.yaml | 38 +++++++++++++ k8s/04_service.yaml | 30 ++++++++++ k8s/09_deployment_client.yaml | 68 +++++++++++++++++++++++ k8s/09_statefulset_server_primary.yaml | 61 +++++++++++++++++++++ k8s/09_statefulset_server_secondary.yaml | 70 ++++++++++++++++++++++++ k8s/READEME.md | 15 +++++ 9 files changed, 322 insertions(+) create mode 100644 k8s/00_namespace.yaml create mode 100644 k8s/01_pvc.yaml create mode 100644 k8s/02_netpol.yaml create mode 100644 k8s/03_ingress.yaml create mode 100644 k8s/04_service.yaml create mode 100644 k8s/09_deployment_client.yaml create mode 100644 k8s/09_statefulset_server_primary.yaml create mode 100644 k8s/09_statefulset_server_secondary.yaml create mode 100644 k8s/READEME.md diff --git a/k8s/00_namespace.yaml b/k8s/00_namespace.yaml new file mode 100644 index 00000000..b4ed8ac4 --- /dev/null +++ b/k8s/00_namespace.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: cronicle +spec: + finalizers: + - kubernetes +status: + phase: Active + diff --git a/k8s/01_pvc.yaml b/k8s/01_pvc.yaml new file mode 100644 index 00000000..7843de6c --- /dev/null +++ b/k8s/01_pvc.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: cronicle-server-data + namespace: cronicle +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 512m + diff --git a/k8s/02_netpol.yaml b/k8s/02_netpol.yaml new file mode 100644 index 00000000..4a942616 --- /dev/null +++ b/k8s/02_netpol.yaml @@ -0,0 +1,16 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: allow-all + namespace: cronicle +spec: + podSelector: {} + policyTypes: + - Ingress + - Egress + ingress: + - {} + egress: + - {} + diff --git a/k8s/03_ingress.yaml b/k8s/03_ingress.yaml new file mode 100644 index 00000000..a649c483 --- /dev/null +++ b/k8s/03_ingress.yaml @@ -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 + diff --git a/k8s/04_service.yaml b/k8s/04_service.yaml new file mode 100644 index 00000000..0f8f366f --- /dev/null +++ b/k8s/04_service.yaml @@ -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 + diff --git a/k8s/09_deployment_client.yaml b/k8s/09_deployment_client.yaml new file mode 100644 index 00000000..52754680 --- /dev/null +++ b/k8s/09_deployment_client.yaml @@ -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: {} + diff --git a/k8s/09_statefulset_server_primary.yaml b/k8s/09_statefulset_server_primary.yaml new file mode 100644 index 00000000..10ea07c3 --- /dev/null +++ b/k8s/09_statefulset_server_primary.yaml @@ -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 + diff --git a/k8s/09_statefulset_server_secondary.yaml b/k8s/09_statefulset_server_secondary.yaml new file mode 100644 index 00000000..29c2f524 --- /dev/null +++ b/k8s/09_statefulset_server_secondary.yaml @@ -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 + diff --git a/k8s/READEME.md b/k8s/READEME.md new file mode 100644 index 00000000..201f26b9 --- /dev/null +++ b/k8s/READEME.md @@ -0,0 +1,15 @@ +### 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 in *running* you can hit http://cronicle.example.com and see cronicle. Remember *cronicle.example.com* to the right IP in your hosts file. From ec480a9282207e2d952a5da378050bb37b5e5b1a Mon Sep 17 00:00:00 2001 From: Chung Tran Date: Thu, 28 Feb 2019 20:47:24 -0500 Subject: [PATCH 2/3] Added k8s manifests. --- k8s/READEME.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/READEME.md b/k8s/READEME.md index 201f26b9..a12986cb 100644 --- a/k8s/READEME.md +++ b/k8s/READEME.md @@ -12,4 +12,4 @@ cronicle-server-primary-0 1/1 Running 0 32m cronicle-server-secondary-0 1/1 Running 0 32m ``` -Once all the pods are in *running* you can hit http://cronicle.example.com and see cronicle. Remember *cronicle.example.com* to the right IP in your hosts file. +Once all the pods are *running* you can hit http://cronicle.example.com and see cronicle. Remember *cronicle.example.com* to the right IP in your hosts file. From ff2bac1e87cb642f248b2cbb0e8c38496e135b0c Mon Sep 17 00:00:00 2001 From: Chung Tran Date: Fri, 1 Mar 2019 08:52:30 -0500 Subject: [PATCH 3/3] Fixed README.md. --- k8s/READEME.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/k8s/READEME.md b/k8s/READEME.md index a12986cb..f8ac1e0d 100644 --- a/k8s/READEME.md +++ b/k8s/READEME.md @@ -12,4 +12,5 @@ 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 *cronicle.example.com* to the right IP in your hosts file. +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. +