Skip to content

Commit

Permalink
feat: packaged the entire system into a helm chart (#9)
Browse files Browse the repository at this point in the history
* With all the components

* Fix namespace

* Separated files

* fixed a typo

* Created Complete chart

* Added missing components

* Updated the version
  • Loading branch information
isala404 authored May 13, 2022
1 parent f2303f3 commit a238382
Show file tree
Hide file tree
Showing 27 changed files with 1,417 additions and 278 deletions.
23 changes: 23 additions & 0 deletions charts/lazy-koala/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions charts/lazy-koala/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: lazy-koala
description: A toolkit to apply AIOps to distributed systems

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.0.0"
107 changes: 107 additions & 0 deletions charts/lazy-koala/crds/lazykoala.isala.me_inspectors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: inspectors.lazykoala.isala.me
spec:
group: lazykoala.isala.me
names:
kind: Inspector
listKind: InspectorList
plural: inspectors
singular: inspector
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.namespace
name: Namespace
type: string
- jsonPath: .spec.deploymentRef
name: Target Deployment
type: string
- jsonPath: .spec.serviceRef
name: Target ClusterIP
type: string
- jsonPath: .spec.modelName
name: Model Name
type: string
- jsonPath: .status.status
name: Status
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: Inspector is the Schema for the inspectors API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: InspectorSpec defines the desired state of Inspector
properties:
deploymentRef:
description: Foo is an example field of Inspector. Edit inspector_types.go
to remove/update
type: string
modelName:
type: string
namespace:
type: string
serviceRef:
type: string
required:
- deploymentRef
- modelName
- namespace
- serviceRef
type: object
status:
description: InspectorStatus defines the observed state of Inspector
properties:
monitoredIPs:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
items:
type: string
type: array
podsSelector:
additionalProperties:
type: string
description: MatchingLabels filters the list/delete operation on the
given set of labels.
type: object
status:
enum:
- Creating
- Running
- Error
type: string
required:
- monitoredIPs
- podsSelector
- status
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
14 changes: 14 additions & 0 deletions charts/lazy-koala/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Lazy Koala was successfully installed the {{ .Release.Namespace }} namespace

To access the main dashboard,
1. Run
$ kubectl port-forward svc/inspector 8090:80 -n {{ .Release.Namespace }}
2. Open http://localhost:8090 in your browser

Under the settings tab you will be able to find out list of service that's running inside the cluster.
From there you can mark them to be monitored by the gazer agent.

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.

To Uninstall the Lazy Koala, Simply run
$ helm uninstall {{ .Release.Name }} -n {{ .Release.Namespace }}
62 changes: 62 additions & 0 deletions charts/lazy-koala/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "lazy-koala.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "lazy-koala.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "lazy-koala.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "lazy-koala.labels" -}}
helm.sh/chart: {{ include "lazy-koala.chart" . }}
{{ include "lazy-koala.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "lazy-koala.selectorLabels" -}}
app.kubernetes.io/name: {{ include "lazy-koala.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "lazy-koala.serviceAccount.name" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "lazy-koala.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions charts/lazy-koala/templates/gazer/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.gazer.create -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: gazer-config
namespace: {{ .Release.Namespace }}
data:
config.yaml: |
{{- end }}
80 changes: 80 additions & 0 deletions charts/lazy-koala/templates/gazer/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{{- if .Values.gazer.create -}}
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: "gazer"
namespace: {{ .Release.Namespace }}
labels:
{{- include "lazy-koala.labels" . | nindent 4 }}
lazykoala: gazer
spec:
selector:
matchLabels:
{{- include "lazy-koala.selectorLabels" . | nindent 6 }}
lazykoala: gazer
template:
metadata:
{{- with .Values.gazer.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "lazy-koala.selectorLabels" . | nindent 8 }}
lazykoala: gazer
spec:
{{- with .Values.gazer.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
hostNetwork: true
hostPID: true
serviceAccountName: {{ .Values.gazer.serviceAccount.name }}
securityContext:
{{- toYaml .Values.gazer.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.gazer.securityContext | nindent 12 }}
image: "{{ .Values.gazer.image.repository }}:{{ .Values.gazer.image.tag }}"
imagePullPolicy: {{ .Values.gazer.image.pullPolicy }}
ports:
- containerPort: 8000
name: metrics
resources:
{{- toYaml .Values.gazer.resources | nindent 12 }}
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: PYTHONUNBUFFERED
value: "1"
- name: PYTHONWARNINGS
value: "ignore:Unverified HTTPS request"
volumeMounts:
{{- toYaml .Values.gazer.volumeMounts | nindent 12 }}
initContainers:
- name: init-headers
image: "{{ .Values.gazer.initImage.repository }}:{{ .Values.gazer.initImage.tag }}"
imagePullPolicy: {{ .Values.gazer.initImage.pullPolicy }}
securityContext:
{{- toYaml .Values.gazer.securityContext | nindent 12 }}
volumeMounts:
{{- toYaml .Values.gazer.volumeMounts | nindent 12 }}
{{- with .Values.gazer.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gazer.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gazer.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gazer.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/lazy-koala/templates/gazer/prometheus/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if .Values.gazer.create -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: {{ .Release.Namespace }}
data:
prometheus.yml: |
global:
scrape_interval: 10s
scrape_configs:
- job_name: 'lazy-koala'
scrape_interval: 1s
metrics_path: /
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotationpresent_lazy_koala_scrape]
action: keep
regex: true
- source_labels: [__meta_kubernetes_pod_container_port_name]
regex: metrics
action: keep
- source_labels: [__meta_kubernetes_pod_container_name]
target_label: gazer
{{- end }}
Loading

0 comments on commit a238382

Please sign in to comment.