Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
macb committed Oct 19, 2023
0 parents commit b1cba05
Show file tree
Hide file tree
Showing 13 changed files with 358 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .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/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Usage

[Helm](https://helm.sh) must be installed to use the charts. Please refer to
Helm's [documentation](https://helm.sh/docs) to get started.

Once Helm has been set up correctly, add the repo as follows:

helm repo add vantage https://vantage-sh.github.io/helm-charts

If you had already added this repo earlier, run `helm repo update` to retrieve
the latest versions of the packages. You can then run `helm search repo
vantage` to see the charts.

To install the `vantage-kubernetes-agent` chart:

helm install -n vantage vantage-kubernetes-agent vantage/vantage-kubernetes-agent --set agent.token=$VANTAGE_API_TOKEN,agent.clusterID=$CLUSTER_ID

To uninstall the chart:

helm delete vantage-kubernetes-agent
7 changes: 7 additions & 0 deletions charts/vantage-kubernetes-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: vantage-kubernetes-agent
description: A Helm chart for provisioning the Vantage Kubernetes agent.
type: application
version: 1.0.0
appVersion: "1.0.0"
icon: "https://www.vantage.sh/nav-logo.svg"
58 changes: 58 additions & 0 deletions charts/vantage-kubernetes-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "vantage-kubernetes-agent.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 "vantage-kubernetes-agent.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 "vantage-kubernetes-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "vantage-kubernetes-agent.serviceAccountName" -}}
{{- default (include "vantage-kubernetes-agent.fullname" .) .Values.serviceAccount.name }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/vantage-kubernetes-agent/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "vantage-kubernetes-agent.fullname" . }}
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
{{- with .Values.clusterRole.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups: [""]
resources: ["nodes/metrics"]
verbs: ["get"]
- apiGroups: [""]
resources: ["nodes", "pods"]
verbs: ["get", "watch", "list"]
18 changes: 18 additions & 0 deletions charts/vantage-kubernetes-agent/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "vantage-kubernetes-agent.fullname" . }}
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
{{- with .Values.clusterRoleBinding.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
subjects:
- kind: ServiceAccount
name: {{ include "vantage-kubernetes-agent.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: {{ include "vantage-kubernetes-agent.fullname" . }}
apiGroup: rbac.authorization.k8s.io
10 changes: 10 additions & 0 deletions charts/vantage-kubernetes-agent/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- $token := .Values.agent.token | required ".Values.agent.token is required."}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "vantage-kubernetes-agent.fullname" . }}
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
type: Opaque
data:
token: {{ $token | b64enc | quote }}
15 changes: 15 additions & 0 deletions charts/vantage-kubernetes-agent/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "vantage-kubernetes-agent.fullname" . }}
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.name }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
{{- include "vantage-kubernetes-agent.selectorLabels" . | nindent 4 }}
10 changes: 10 additions & 0 deletions charts/vantage-kubernetes-agent/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "vantage-kubernetes-agent.serviceAccountName" . }}
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}q
82 changes: 82 additions & 0 deletions charts/vantage-kubernetes-agent/templates/statefulset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{- $clusterID := .Values.agent.clusterID | required ".Values.clusterID.token is required."}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "vantage-kubernetes-agent.fullname" . }}
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
spec:
replicas: 1
serviceName: vantage-agent
selector:
matchLabels:
{{- include "vantage-kubernetes-agent.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "vantage-kubernetes-agent.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "vantage-kubernetes-agent.serviceAccountName" . }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: VANTAGE_DEBUG
value: "{{ .Values.agent.debug }}"
- name: VANTAGE_LOG_LEVEL
value: "{{ .Values.agent.logLevel }}"
- name: VANTAGE_CLUSTER_ID
value: "{{ $clusterID }}"
- name: VANTAGE_API_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "vantage-kubernetes-agent.fullname" . }}
key: token
{{- with .Values.agent.apiHost }}
- name: VANTAGE_API_HOST
value: "{{ . }}"
{{ end }}
{{- with .Values.persist }}
- name: VANTAGE_PERSIST_DIR
value: "{{ .mountPath }}"
{{ end }}
ports:
- name: {{ .Values.service.name }}
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /healthz
port: {{ .Values.service.name }}
readinessProbe:
httpGet:
path: /healthz
port: {{ .Values.service.name }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.persist }}
volumeMounts:
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{ end }}
{{- with .Values.persist }}
volumeClaimTemplates:
- metadata:
name: {{ .name }}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: {{ .size }}
{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "vantage-kubernetes-agent.fullname" . }}-test-connection"
labels:
{{- include "vantage-kubernetes-agent.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "vantage-kubernetes-agent.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
62 changes: 62 additions & 0 deletions charts/vantage-kubernetes-agent/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Default values for vantage-kubernetes-agent.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

image:
repository: "quay.io/vantage-sh/kubernetes-agent"
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""

agent:
debug: false
# logLevel corresponds to https://pkg.go.dev/log/slog#Level
# Info: 0
# Debug: -4
logLevel: "0"
# Unique identifier for your cluster.
clusterID: ""
# Vantage API Token
token: ""

persist:
mountPath: "/var/lib/vantage-agent"
name: "data"
size: "10Gi"

service:
name: report
type: ClusterIP
port: 9010

resources:
limits:
cpu: 10m
memory: 50Mi
requests:
cpu: 10m
memory: 50Mi


imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""


serviceAccount:
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: ""

clusterRole:
annotations: {}
clusterRoleBinding:
annotations: {}

podAnnotations: {}
podSecurityContext: {}
securityContext: {}
nodeSelector: {}
tolerations: []
affinity: {}

0 comments on commit b1cba05

Please sign in to comment.