Add Kubernetes Deploy

This commit is contained in:
CAJNA Jarod 2023-10-26 10:31:38 +02:00
parent e1cd3640e4
commit ea6e299ef3
10 changed files with 1205 additions and 1 deletions

View File

@ -0,0 +1,22 @@
# Install Kepler and Electricitymap on HKB cluster.
## Install Kepler
1 - Add Kepler helm repo
```
helm repo add kepler https://sustainable-computing-io.github.io/kepler-helm-chart
```
2 - Install Kepler with values.yaml
```
cd kepler
helm install kepler kepler/kepler --namespace kepler --create-namespace --values kepler-values.yaml
```
3 - Add Grafana Dashboard "kepler-dashboard.json"
## Install electricitymap exporter
1 - Apply all yaml files
```
cd electricitymap
kubectl apply -f electricitymap-deploy.yaml -n kepler
kubectl apply -f electricitymap-svc.yaml -n kepler
kubectl apply -f service-monitor.yaml -n cattle-monitoring-system
```

View File

@ -0,0 +1,3 @@
electricitymap-deploy.yaml
electricitymap-svc.yaml
service-monitor.yaml

View File

@ -7,4 +7,4 @@ RUN pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
CMD ["python", "electricity.py"] CMD ["python", "electricity.py"]

View File

@ -42,6 +42,7 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
self.send_response(200) self.send_response(200)
self.end_headers() self.end_headers()
self.send_header('Content-type', 'text/plain; version=0.0.4')
response_string = f'electricitymap_carbon_intensity{{zone="{ZONE}"}} ' + str(data) response_string = f'electricitymap_carbon_intensity{{zone="{ZONE}"}} ' + str(data)
self.wfile.write(response_string.encode('utf-8')) self.wfile.write(response_string.encode('utf-8'))

View File

@ -0,0 +1,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: electricitymap-deployment
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: electricitymap
template:
metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: electricitymap
spec:
containers:
- name: electricitymap
image: hysio-kub-repos.artifact.hysio.mutu.dc1.smhg.adm.ths/electricitymap:1.0.0
ports:
- containerPort: 8808
name: metrics

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: electricitymap-service
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: electricitymap
spec:
selector:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: electricitymap
ports:
- protocol: TCP
port: 8808
targetPort: metrics
name: metrics

View File

@ -0,0 +1,19 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: electricitymap-servicemonitor
spec:
namespaceSelector:
matchNames:
- kepler
selector:
matchLabels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: electricitymap
jobLabel: app.kubernetes.io/name
endpoints:
- port: metrics
interval: 30s
path: "/"
scheme: http
scrapeTimeout: 15s

1024
kepler/kepler-dashboard.json Normal file

File diff suppressed because it is too large Load Diff

96
kepler/kepler-values.yaml Normal file
View File

@ -0,0 +1,96 @@
---
# -- Replaces the name of the chart in the Chart.yaml file
nameOverride: ""
# -- Replaces the generated name
fullnameOverride: ""
image:
# -- Repository to pull the image from
repository: "quay.io/sustainable_computing_io/kepler"
# -- Image tag, if empty it will get it from the chart's appVersion
tag: ""
# -- Pull policy
pullPolicy: Always
# -- Secret name for pulling images from private repository
imagePullSecrets: []
# -- Additional DaemonSet annotations
annotations: {}
# -- Additional pod annotations
podAnnotations: {}
# -- Additional pod labels
podLabels: {}
# -- Privileges and access control settings for a Pod (all containers in a pod)
podSecurityContext: {}
# fsGroup: 2000
# -- Privileges and access control settings for a container
securityContext:
privileged: true
# -- Node selection constraint
nodeSelector:
kubernetes.io/os: linux
node-role.kubernetes.io/worker: "true"
# -- Toleration for taints
tolerations:
- operator: "Exists"
# -- Affinity rules
affinity: {}
# -- CPU/MEM resources
resources: {}
# -- Extra environment variables
extraEnvVars:
KEPLER_LOG_LEVEL: "1"
ENABLE_GPU: "true"
ENABLE_EBPF_CGROUPID: "true"
EXPOSE_IRQ_COUNTER_METRICS: "true"
EXPOSE_KUBELET_METRICS: "true"
ENABLE_PROCESS_METRICS: "true"
CPU_ARCH_OVERRIDE: ""
CGROUP_METRICS: "*"
# REDFISH_PROBE_INTERVAL_IN_SECONDS: "60"
# REDFISH_SKIP_SSL_VERIFY: "true"
canMount:
usrSrc: true # /usr/src may not available, ie GKE
service:
annotations: {}
type: ClusterIP
port: 9102
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
serviceMonitor:
enabled: true
namespace: "cattle-monitoring-system"
interval: 30s
scrapeTimeout: 5s
labels: {}
redfish:
enabled: false
name: redfish
labels: {}
annotations: {}
fileContent: |-
your_kubelet_node1_name,redfish_username,redfish_password,https://node1_redfish_ip_or_hostname
your_kubelet_node2_name,redfish_username,redfish_password,https://node2_redfish_ip_or_hostname