Skip to content

Commit a238382

Browse files
authored
feat: packaged the entire system into a helm chart (#9)
* With all the components * Fix namespace * Separated files * fixed a typo * Created Complete chart * Added missing components * Updated the version
1 parent f2303f3 commit a238382

27 files changed

+1417
-278
lines changed

charts/lazy-koala/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/lazy-koala/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: lazy-koala
3+
description: A toolkit to apply AIOps to distributed systems
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 1.0.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.0.0"
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.8.0
7+
creationTimestamp: null
8+
name: inspectors.lazykoala.isala.me
9+
spec:
10+
group: lazykoala.isala.me
11+
names:
12+
kind: Inspector
13+
listKind: InspectorList
14+
plural: inspectors
15+
singular: inspector
16+
scope: Namespaced
17+
versions:
18+
- additionalPrinterColumns:
19+
- jsonPath: .spec.namespace
20+
name: Namespace
21+
type: string
22+
- jsonPath: .spec.deploymentRef
23+
name: Target Deployment
24+
type: string
25+
- jsonPath: .spec.serviceRef
26+
name: Target ClusterIP
27+
type: string
28+
- jsonPath: .spec.modelName
29+
name: Model Name
30+
type: string
31+
- jsonPath: .status.status
32+
name: Status
33+
type: string
34+
name: v1alpha1
35+
schema:
36+
openAPIV3Schema:
37+
description: Inspector is the Schema for the inspectors API
38+
properties:
39+
apiVersion:
40+
description: 'APIVersion defines the versioned schema of this representation
41+
of an object. Servers should convert recognized schemas to the latest
42+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
43+
type: string
44+
kind:
45+
description: 'Kind is a string value representing the REST resource this
46+
object represents. Servers may infer this from the endpoint the client
47+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
48+
type: string
49+
metadata:
50+
type: object
51+
spec:
52+
description: InspectorSpec defines the desired state of Inspector
53+
properties:
54+
deploymentRef:
55+
description: Foo is an example field of Inspector. Edit inspector_types.go
56+
to remove/update
57+
type: string
58+
modelName:
59+
type: string
60+
namespace:
61+
type: string
62+
serviceRef:
63+
type: string
64+
required:
65+
- deploymentRef
66+
- modelName
67+
- namespace
68+
- serviceRef
69+
type: object
70+
status:
71+
description: InspectorStatus defines the observed state of Inspector
72+
properties:
73+
monitoredIPs:
74+
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
75+
of cluster Important: Run "make" to regenerate code after modifying
76+
this file'
77+
items:
78+
type: string
79+
type: array
80+
podsSelector:
81+
additionalProperties:
82+
type: string
83+
description: MatchingLabels filters the list/delete operation on the
84+
given set of labels.
85+
type: object
86+
status:
87+
enum:
88+
- Creating
89+
- Running
90+
- Error
91+
type: string
92+
required:
93+
- monitoredIPs
94+
- podsSelector
95+
- status
96+
type: object
97+
type: object
98+
served: true
99+
storage: true
100+
subresources:
101+
status: {}
102+
status:
103+
acceptedNames:
104+
kind: ""
105+
plural: ""
106+
conditions: []
107+
storedVersions: []

charts/lazy-koala/templates/NOTES.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Lazy Koala was successfully installed the {{ .Release.Namespace }} namespace
2+
3+
To access the main dashboard,
4+
1. Run
5+
$ kubectl port-forward svc/inspector 8090:80 -n {{ .Release.Namespace }}
6+
2. Open http://localhost:8090 in your browser
7+
8+
Under the settings tab you will be able to find out list of service that's running inside the cluster.
9+
From there you can mark them to be monitored by the gazer agent.
10+
11+
Finally, Once you navigated to the main dashboard, you can see the list of services that are being monitored and how they interact with each other.
12+
13+
To Uninstall the Lazy Koala, Simply run
14+
$ helm uninstall {{ .Release.Name }} -n {{ .Release.Namespace }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "lazy-koala.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "lazy-koala.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "lazy-koala.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "lazy-koala.labels" -}}
37+
helm.sh/chart: {{ include "lazy-koala.chart" . }}
38+
{{ include "lazy-koala.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "lazy-koala.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "lazy-koala.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "lazy-koala.serviceAccount.name" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "lazy-koala.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- if .Values.gazer.create -}}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: gazer-config
6+
namespace: {{ .Release.Namespace }}
7+
data:
8+
config.yaml: |
9+
{{- end }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{{- if .Values.gazer.create -}}
2+
apiVersion: apps/v1
3+
kind: DaemonSet
4+
metadata:
5+
name: "gazer"
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "lazy-koala.labels" . | nindent 4 }}
9+
lazykoala: gazer
10+
spec:
11+
selector:
12+
matchLabels:
13+
{{- include "lazy-koala.selectorLabels" . | nindent 6 }}
14+
lazykoala: gazer
15+
template:
16+
metadata:
17+
{{- with .Values.gazer.podAnnotations }}
18+
annotations:
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
labels:
22+
{{- include "lazy-koala.selectorLabels" . | nindent 8 }}
23+
lazykoala: gazer
24+
spec:
25+
{{- with .Values.gazer.imagePullSecrets }}
26+
imagePullSecrets:
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
hostNetwork: true
30+
hostPID: true
31+
serviceAccountName: {{ .Values.gazer.serviceAccount.name }}
32+
securityContext:
33+
{{- toYaml .Values.gazer.podSecurityContext | nindent 8 }}
34+
containers:
35+
- name: {{ .Chart.Name }}
36+
securityContext:
37+
{{- toYaml .Values.gazer.securityContext | nindent 12 }}
38+
image: "{{ .Values.gazer.image.repository }}:{{ .Values.gazer.image.tag }}"
39+
imagePullPolicy: {{ .Values.gazer.image.pullPolicy }}
40+
ports:
41+
- containerPort: 8000
42+
name: metrics
43+
resources:
44+
{{- toYaml .Values.gazer.resources | nindent 12 }}
45+
env:
46+
- name: NODE_NAME
47+
valueFrom:
48+
fieldRef:
49+
fieldPath: spec.nodeName
50+
- name: PYTHONUNBUFFERED
51+
value: "1"
52+
- name: PYTHONWARNINGS
53+
value: "ignore:Unverified HTTPS request"
54+
volumeMounts:
55+
{{- toYaml .Values.gazer.volumeMounts | nindent 12 }}
56+
initContainers:
57+
- name: init-headers
58+
image: "{{ .Values.gazer.initImage.repository }}:{{ .Values.gazer.initImage.tag }}"
59+
imagePullPolicy: {{ .Values.gazer.initImage.pullPolicy }}
60+
securityContext:
61+
{{- toYaml .Values.gazer.securityContext | nindent 12 }}
62+
volumeMounts:
63+
{{- toYaml .Values.gazer.volumeMounts | nindent 12 }}
64+
{{- with .Values.gazer.volumes }}
65+
volumes:
66+
{{- toYaml . | nindent 8 }}
67+
{{- end }}
68+
{{- with .Values.gazer.nodeSelector }}
69+
nodeSelector:
70+
{{- toYaml . | nindent 8 }}
71+
{{- end }}
72+
{{- with .Values.gazer.affinity }}
73+
affinity:
74+
{{- toYaml . | nindent 8 }}
75+
{{- end }}
76+
{{- with .Values.gazer.tolerations }}
77+
tolerations:
78+
{{- toYaml . | nindent 8 }}
79+
{{- end }}
80+
{{- end }}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{{- if .Values.gazer.create -}}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: prometheus-config
6+
namespace: {{ .Release.Namespace }}
7+
data:
8+
prometheus.yml: |
9+
global:
10+
scrape_interval: 10s
11+
scrape_configs:
12+
- job_name: 'lazy-koala'
13+
scrape_interval: 1s
14+
metrics_path: /
15+
kubernetes_sd_configs:
16+
- role: pod
17+
relabel_configs:
18+
- source_labels: [__meta_kubernetes_pod_annotationpresent_lazy_koala_scrape]
19+
action: keep
20+
regex: true
21+
- source_labels: [__meta_kubernetes_pod_container_port_name]
22+
regex: metrics
23+
action: keep
24+
- source_labels: [__meta_kubernetes_pod_container_name]
25+
target_label: gazer
26+
{{- end }}

0 commit comments

Comments
 (0)