Skip to content

Commit

Permalink
Merge pull request #112 from anchore/add-kai-chart
Browse files Browse the repository at this point in the history
Initial Implementation of KAI Helm Chart
  • Loading branch information
dakaneye authored Jan 27, 2021
2 parents de16d40 + 13619c6 commit 418a435
Show file tree
Hide file tree
Showing 13 changed files with 420 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
examples/
*.tgz
charts/
.idea/
23 changes: 23 additions & 0 deletions stable/kai/.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/
38 changes: 38 additions & 0 deletions stable/kai/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: v2
name: kai
description: A Helm chart for Kubernetes Automated Inventory, which describes which images are in use in a given Kubernetes Cluster
keywords:
- analysis
- docker
- anchore
- "anchore-engine"
- image
- inventory
- security
- scanner

maintainers:
- name: dakaneye
email: [email protected]

# 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: 0.1.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.
appVersion: 0.1.0

icon: https://anchore.com/wp-content/uploads/2016/08/anchore.png
Empty file added stable/kai/templates/NOTES.txt
Empty file.
62 changes: 62 additions & 0 deletions stable/kai/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "kai.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 "kai.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 "kai.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "kai.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "kai.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
12 changes: 12 additions & 0 deletions stable/kai/templates/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kai-read-only-binding
subjects:
- kind: ServiceAccount
name: {{ include "kai.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: kai-read-only
apiGroup: rbac.authorization.k8s.io
8 changes: 8 additions & 0 deletions stable/kai/templates/cluster-role-readonly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kai-read-only
rules:
- apiGroups: [""]
resources: ["pods","namespaces"]
verbs: ["get", "watch", "list"]
31 changes: 31 additions & 0 deletions stable/kai/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
kind: ConfigMap
apiVersion: v1
metadata:
name: {{ include "kai.fullname" . }}
labels:
app: {{ include "kai.fullname" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
.kai.yaml: |
kubeconfig:
path: {{ .Values.kai.kubeconfig.path }}
cluster: {{ .Values.kai.kubeconfig.cluster }}
output: {{ .Values.kai.output }}
quiet: {{ .Values.kai.quiet }}
log:
structured: {{ .Values.kai.log.structured }}
level: {{ .Values.kai.log.level }}
file: {{ .Values.kai.log.file }}
namespaces:
{{- toYaml .Values.kai.namespaces | nindent 6 }}
mode: {{ .Values.kai.mode }}
polling-interval-seconds: {{ .Values.kai.pollingIntervalSeconds }}
anchore:
url: {{ .Values.kai.anchore.url }}
user: {{ .Values.kai.anchore.user }}
password: $KAI_ANCHORE_PASSWORD
http:
insecure: {{ .Values.kai.anchore.http.insecure }}
timeoutSeconds: {{ .Values.kai.anchore.http.timeoutSeconds }}
83 changes: 83 additions & 0 deletions stable/kai/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "kai.fullname" . }}
labels:
{{- include "kai.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "kai.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "kai.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "kai.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
exec:
command:
- /kai
- version
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
successThreshold: {{ .Values.probes.liveness.successThreshold }}
readinessProbe:
exec:
command:
- /kai
- version
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
successThreshold: {{ .Values.probes.readiness.successThreshold }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config-volume
mountPath: /.kai.yaml
subPath: .kai.yaml
envFrom:
{{- if not .Values.inject_secrets_via_env }}
- secretRef:
name: {{ default (include "kai.fullname" .) .Values.kai.existingSecret }}
{{- end }}
volumes:
- name: config-volume
configMap:
name: {{ include "kai.fullname" . }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
17 changes: 17 additions & 0 deletions stable/kai/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if not .Values.kai.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "kai.fullname" . }}
labels:
app: {{ template "kai.fullname" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.kai.labels }}
{{ toYaml . | nindent 4 }}
{{- end }}
type: Opaque
stringData:
KAI_ANCHORE_PASSWORD: {{ .Values.kai.anchore.password }}
{{- end }}
15 changes: 15 additions & 0 deletions stable/kai/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "kai.fullname" . }}
labels:
{{- include "kai.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "kai.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions stable/kai/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "kai.serviceAccountName" . }}
labels:
{{- include "kai.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit 418a435

Please sign in to comment.