Skip to content

Commit

Permalink
302 k8s deployment (#303)
Browse files Browse the repository at this point in the history
* K8s deployment resources.

* Basic k8s deployment.

* Move k8s deployment files to one folder.
  • Loading branch information
bartossh authored Nov 20, 2023
1 parent 6252aad commit 4f98806
Show file tree
Hide file tree
Showing 16 changed files with 480 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ c/client-node/packages/
ed25519
ed25519.pub



# k8s config
kubeconfig.yaml
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ARG APPLICATION
WORKDIR /app
COPY . .
RUN go mod tidy
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -o cmd/${APPLICATION}/main -ldflags="-s -w" cmd/${APPLICATION}/main.go
RUN GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -a -installsuffix cgo -o cmd/${APPLICATION}/main -ldflags="-s -w" cmd/${APPLICATION}/main.go

FROM alpine AS app
ARG APPLICATION
Expand Down
Binary file modified artefacts/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions deployment/grafana-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: grafana-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: grafana
name: grafana
spec:
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
securityContext:
fsGroup: 472
supplementalGroups:
- 0
containers:
- name: grafana
image: grafana/grafana:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 3000
name: http-grafana
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /robots.txt
port: 3000
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 2
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 3000
timeoutSeconds: 1
resources:
requests:
cpu: 250m
memory: 750Mi
volumeMounts:
- mountPath: /var/lib/grafana
name: grafana-pv
volumes:
- name: grafana-pv
persistentVolumeClaim:
claimName: grafana-pvc
---
apiVersion: v1
kind: Service
metadata:
name: grafana
spec:
ports:
- port: 3000
protocol: TCP
targetPort: 3000
nodePort: 30300
selector:
app: grafana
sessionAffinity: None
type: LoadBalancer
33 changes: 33 additions & 0 deletions deployment/nats-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nats
spec:
replicas: 1
selector:
matchLabels:
app: nats
template:
metadata:
labels:
app: nats
spec:
containers:
- name: nats
image: nats:latest
ports:
- containerPort: 4222
env:
- name: GOMAXPROCS
value: "1"

---
apiVersion: v1
kind: Service
metadata:
name: nats
spec:
selector:
app: nats
ports:
- port: 4222
57 changes: 57 additions & 0 deletions deployment/node-exporter-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-exporter
labels:
app: node-exporter
spec:
replicas: 1
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
containers:
- name: node-exporter
image: prom/node-exporter:latest
args:
- "--path.procfs=/host/proc"
- "--path.rootfs=/rootfs"
- "--path.sysfs=/host/sys"
- "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($()|/)"
env:
- name: GOMAXPROCS
value: "1"
ports:
- containerPort: 9100
volumeMounts:
- mountPath: /host/proc
name: node-exporter-0
- mountPath: /host/sys
name: node-exporter-1
- mountPath: /rootfs
name: node-exporter-2
restartPolicy: Always
volumes:
- name: node-exporter-0
emptyDir: {}
- name: node-exporter-1
emptyDir: {}
- name: node-exporter-2
emptyDir: {}

---
apiVersion: v1
kind: Service
metadata:
name: node-exporter
spec:
selector:
app: node-exporter
ports:
- protocol: "TCP"
port: 9100
targetPort: 9100
54 changes: 54 additions & 0 deletions deployment/notary-node-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@

apiVersion: v1
kind: Service
metadata:
name: notary-node
spec:
ports:
- name: "api"
port: 8000
protocol: TCP
targetPort: 8000
nodePort: 30080
- name: "gossip"
port: 8080
protocol: TCP
targetPort: 8080
nodePort: 30880
selector:
app: notary-node
sessionAffinity: ClientIP
type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: notary-node-deployment
labels:
app: nota-node
spec:
replicas: 1
selector:
matchLabels:
app: notary-node
template:
metadata:
labels:
app: notary-node
spec:
imagePullSecrets:
- name: regcred
containers:
- name: notary-node
image: alogorythmos/computantis
env:
- name: GOMAXPROCS
value: "2"
ports:
- name: tcp-api
containerPort: 8000
protocol: TCP
- name: tcp-gossip
containerPort: 8080
protocol: TCP
51 changes: 51 additions & 0 deletions deployment/prometheus-config-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-server-conf
labels:
name: prometheus-server-conf
data:
prometheus.rules: |-
groups:
- name: devopscube demo alert
rules:
- alert: High Pod Memory
expr: sum(container_memory_usage_bytes) > 1
for: 1m
labels:
severity: slack
annotations:
summary: High Memory Usage
prometheus.yml: |-
global:
scrape_interval: 1m
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 1m
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['node-exporter:9100']
- job_name: 'notary-genesis'
static_configs:
- targets: ['notary-node-genesis:2112']
- job_name: 'notary-one'
static_configs:
- targets: ['notary-node-one:2112']
- job_name: 'notary-two'
static_configs:
- targets: ['notary-node-two:2112']
- job_name: 'webhooks'
static_configs:
- targets: ['webhooks-node:2112']
- job_name: 'client'
static_configs:
- targets: ['client-node:2112']
54 changes: 54 additions & 0 deletions deployment/prometheus-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-deployment
labels:
app: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
env:
- name: GOMAXPROCS
value: "1"
ports:
- containerPort: 9090
volumeMounts:
- name: prometheus-config-volume
mountPath: /etc/prometheus/
- name: prometheus-storage-volume
mountPath: /prometheus/
restartPolicy: Always
volumes:
- name: prometheus-config-volume
configMap:
defaultMode: 420
name: prometheus-server-conf

- name: prometheus-storage-volume
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: prometheus-service
spec:
selector:
app: prometheus
ports:
- protocol: "TCP"
port: 9090
targetPort: 9090

7 changes: 7 additions & 0 deletions deployment/zinc-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-zinc-auth
data:
username: YWRtaW4=
password: emluY3NlcmNo
Loading

0 comments on commit 4f98806

Please sign in to comment.