Skip to content

Commit

Permalink
WIP: add kustomize
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-karan authored and Karan Sharma committed Aug 20, 2019
1 parent 5f81989 commit 4cb9f9c
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 100 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ tsconfig.json
jsconfig.json

### Misc ###
config.toml
# config.toml
.goreleaser.yml
.DS_Store
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ There are multiple ways of installing/running calert.
- ### Running as docker container
`docker pull mrkaran/calert:1.0.0-stable`

- ### Deploying on Kubernetes cluster
`kustomize build ./kustomize/overlays/prod | kubectl apply -f -`

### Quickstart

```sh
Expand Down
36 changes: 0 additions & 36 deletions k8s/configmap.yml

This file was deleted.

17 changes: 0 additions & 17 deletions k8s/load_balancer_service.yml

This file was deleted.

15 changes: 0 additions & 15 deletions k8s/network-policy.yml

This file was deleted.

15 changes: 0 additions & 15 deletions k8s/node_port_service.yml

This file was deleted.

18 changes: 6 additions & 12 deletions k8s/deployment.yml → kustomize/base/deployments/calert.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: calert-deployment
labels:
app: calert
name: app
spec:
replicas: 3
replicas: 1
selector:
matchLabels:
app: calert
service: app
template:
metadata:
labels:
app: calert
tier: api
service: app
spec:
containers:
- name: calert
image: mrkaran/calert:1.0.0-stable
image: mrkaran/calert:1.0.0
ports:
- containerPort: 6000
volumeMounts:
Expand All @@ -26,7 +23,4 @@ spec:
volumes:
- name: config-dir
configMap:
name: calert-config
items:
- key: config.toml
path: config.toml
name: app-config
5 changes: 1 addition & 4 deletions k8s/redis.yml → kustomize/base/deployments/redis.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-deployment
labels:
service: redis
name: redis
spec:
replicas: 1
selector:
Expand All @@ -13,7 +11,6 @@ spec:
metadata:
labels:
service: redis
tier: cache
spec:
containers:
- name: redis
Expand Down
6 changes: 6 additions & 0 deletions kustomize/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- deployments/calert.yaml
- deployments/redis.yaml
- services/calert.yaml
- services/redis.yaml
namePrefix: calert-
11 changes: 11 additions & 0 deletions kustomize/base/services/calert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: service
spec:
ports:
- protocol: TCP
port: 6000
selector:
tier: api
type: NodePort
File renamed without changes.
159 changes: 159 additions & 0 deletions kustomize/build/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
env: prod
group: calert
name: calert
---
apiVersion: v1
data:
config.toml: |
# All timeouts and durations are in milliseconds.
[server]
address = ":6000"
socket = "/tmp/calert.sock"
name = "calert"
# WARNING If these timeouts are less than 1s,
# the server connection breaks.
read_timeout=5000
write_timeout=5000
keepalive_timeout=300000
[app]
template_file = "message.tmpl"
[app.http_client]
max_idle_conns = 100
request_timeout = 8000
[app.chat.alertManagerTestRoom]
notification_url = "https://chat.googleapis.com/v1/spaces/xxx/messages?key=abc-xyz&token=token-unique-key%3D"
[app.chat.awesomeRoomTwo]
notification_url = "https://chat.googleapis.com/v1/spaces/xxx/messages?key=abc-xyz&token=token-unique-key%3D"
kind: ConfigMap
metadata:
labels:
env: prod
group: calert
name: app-config-kf68kdh2b8
namespace: calert
---
apiVersion: v1
kind: Service
metadata:
labels:
env: prod
group: calert
name: calert-redis-calert
namespace: calert
spec:
ports:
- port: 6379
protocol: TCP
selector:
env: prod
group: calert
service: redis
tier: cache
---
apiVersion: v1
kind: Service
metadata:
labels:
env: prod
group: calert
name: calert-service
namespace: calert
spec:
ports:
- port: 6000
protocol: TCP
selector:
app: calert
env: prod
group: calert
tier: api
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
env: prod
group: calert
name: calert-app
namespace: calert
spec:
replicas: 1
selector:
matchLabels:
env: prod
group: calert
service: app
template:
metadata:
labels:
env: prod
group: calert
service: app
tier: api
spec:
containers:
- image: mrkaran/calert:1.8.0-stable
name: calert
ports:
- containerPort: 6000
resources:
limits:
cpu: 500m
memory: 400Mi
requests:
cpu: 250m
memory: 200Mi
volumeMounts:
- mountPath: /etc/calert/
name: config-dir
volumes:
- configMap:
name: app-config-kf68kdh2b8
name: config-dir
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
env: prod
group: calert
name: calert-redis
namespace: calert
spec:
replicas: 1
selector:
matchLabels:
env: prod
group: calert
service: redis
template:
metadata:
labels:
env: prod
group: calert
service: redis
tier: cache
spec:
containers:
- image: redis:5.0-alpine
name: redis
ports:
- containerPort: 6379
resources:
limits:
cpu: 300m
memory: 200Mi
requests:
cpu: 150m
memory: 100Mi
34 changes: 34 additions & 0 deletions kustomize/overlays/prod/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: calert
commonLabels:
env: prod
group: calert
resources:
- namespace.yaml
- ../../base
patchesStrategicMerge:
- patches/resource-limits.yaml
# - patches/service-calert.yaml
- patches/add-labels.yaml

images:
- name: mrkaran/calert
newTag: 1.0.0-stable
# patchesJson6902:
# - target:
# group: apps
# version: v1
# kind: Deployment
# name: app
# path: patches/add-redis-labels.yaml
# - target:
# group: apps
# version: v1
# kind: Deployment
# name: app
# path: patches/add-labels.yaml
configMapGenerator:
- name: app-config
files:
- raw/config.toml
4 changes: 4 additions & 0 deletions kustomize/overlays/prod/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: calert

0 comments on commit 4cb9f9c

Please sign in to comment.