Skip to content

Commit

Permalink
Merge pull request CrowdStrike#207 from cs-pvyas/cwpp-kpa-helm-chart
Browse files Browse the repository at this point in the history
  • Loading branch information
redhatrises authored Jul 5, 2023
2 parents a767961 + 68e6cf3 commit a5daa10
Show file tree
Hide file tree
Showing 13 changed files with 326 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/helm-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
paths:
- 'helm-charts/**'
- '!helm-charts/falcon-sensor/**'
- '!helm-charts/cs-k8s-protection-agent/**'

jobs:
lint-test:
Expand Down
23 changes: 23 additions & 0 deletions helm-charts/cs-k8s-protection-agent/.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/
26 changes: 26 additions & 0 deletions helm-charts/cs-k8s-protection-agent/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: cs-k8s-protection-agent
description: A Helm chart for Crowdstrike Kubernetes Protection Agent

# 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.43.8"

# 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: "0.43.8"

icon: "https://www.crowdstrike.com/wp-content/uploads/2020/08/FalconPremium@2x.svg"
3 changes: 3 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The Crowdstrike Kubernetes Agent is now deployed to your cluster under the {{ .Release.Namespace }} namespace as {{ include "cs-k8s-protection-agent.fullname" . }}. You can now check if the agent is running by running the following command:

"kubectl -n {{ .Release.Namespace}} get pods"
74 changes: 74 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "cs-k8s-protection-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 "cs-k8s-protection-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 "cs-k8s-protection-agent.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "cs-k8s-protection-agent.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "cs-k8s-protection-agent.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "imagePullSecret" }}
{{- with .Values.crowdstrikeConfig }}
{{- if eq .env "us-gov-1" }}
{{- printf "{\"auths\":{\"registry.laggar.gcw.crowdstrike.com\":{\"username\":\"kp-%s\",\"password\":\"%s\",\"email\":\"kubernetes-protection@crowdstrike.com\",\"auth\":\"%s\"}}}" .cid .dockerAPIToken (printf "kp-%s:%s" .cid .dockerAPIToken | b64enc) | b64enc }}
{{- else if eq .env "us-gov-2" }}
{{- printf "{\"auths\":{\"registry.us-gov-2.crowdstrike.com\":{\"username\":\"kp-%s\",\"password\":\"%s\",\"email\":\"kubernetes-protection@crowdstrike.com\",\"auth\":\"%s\"}}}" .cid .dockerAPIToken (printf "kp-%s:%s" .cid .dockerAPIToken | b64enc) | b64enc }}
{{- else }}
{{- printf "{\"auths\":{\"registry.crowdstrike.com\":{\"username\":\"kp-%s\",\"password\":\"%s\",\"email\":\"kubernetes-protection@crowdstrike.com\",\"auth\":\"%s\"}}}" .cid .dockerAPIToken (printf "kp-%s:%s" .cid .dockerAPIToken | b64enc) | b64enc }}
{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "cs-k8s-protection-agent.fullname" . }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ .Values.serviceAccount.name | default ( include "cs-k8s-protection-agent.fullname" . ) }}
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ include "cs-k8s-protection-agent.fullname" . }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "cs-k8s-protection-agent.fullname" . }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
rules:
- verbs: [ "watch", "list" ]
apiGroups: [ "batch" ]
resources:
- "cronjobs"
- "jobs"
- verbs: [ "watch", "list" ]
apiGroups: [ "networking.k8s.io" ]
resources:
- "networkpolicies"
- "ingresses"
- verbs: [ "watch", "list" ]
apiGroups: [ "apps", "extensions" ]
resources:
- "daemonsets"
- "deployments"
- "replicasets"
- "statefulsets"
- verbs: [ "watch", "list" ]
apiGroups: [ "" ]
resources:
- "nodes"
- "pods"
- "services"
- verbs: [ "get", "list", "watch" ]
apiGroups: [ "" ]
resources:
- "namespaces"

12 changes: 12 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "cs-k8s-protection-agent.fullname" . }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
data:
AGENT_CLUSTER_NAME: {{ required "A cluster name must be provided for the agent" .Values.crowdstrikeConfig.clusterName | quote }}
AGENT_DEBUG: {{ .Values.crowdstrikeConfig.enableDebug | default "false" | quote }}
AGENT_CLIENT_ID: {{ required "A valid crowdstrike client ID is required" .Values.crowdstrikeConfig.clientID | quote }}
AGENT_ENV: {{ required "An environment for the agent to call into is required" .Values.crowdstrikeConfig.env | quote }}
AGENT_HELM_VERSION: {{ .Chart.Version | quote }}
58 changes: 58 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cs-k8s-protection-agent.fullname" . }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "cs-k8s-protection-agent.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 8 }}
spec:
{{ if .Values.crowdstrikeConfig.dockerAPIToken }}
imagePullSecrets:
- name: {{ include "cs-k8s-protection-agent.fullname" . }}-regsecret
{{- end }}
serviceAccountName: {{ .Values.serviceAccount.name | default ( include "cs-k8s-protection-agent.fullname" . ) }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "cs-k8s-protection-agent.fullname" . }}
- secretRef:
{{- if .Values.crowdstrikeConfig.existingSecret }}
name: {{ .Values.crowdstrikeConfig.existingSecret }}
{{- else }}
name: {{ include "cs-k8s-protection-agent.fullname" . }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
11 changes: 11 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/docker-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ if .Values.crowdstrikeConfig.dockerAPIToken }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "cs-k8s-protection-agent.fullname" . }}-regsecret
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
type: kubernetes.io/dockerconfigjson
data:
.dockerconfigjson: {{ template "imagePullSecret" . }}
{{- end}}
11 changes: 11 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if (not .Values.crowdstrikeConfig.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "cs-k8s-protection-agent.fullname" . }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
data:
AGENT_CLIENT_ID: {{ required "A valid crowdstrike client ID is required" .Values.crowdstrikeConfig.clientID | b64enc | quote }}
AGENT_CLIENT_SECRET: {{ required "A valid crowdstrike client secret is required" .Values.crowdstrikeConfig.clientSecret | b64enc | quote }}
{{- end }}
13 changes: 13 additions & 0 deletions helm-charts/cs-k8s-protection-agent/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.serviceAccount.name | default ( include "cs-k8s-protection-agent.fullname" . ) }}
labels:
{{- include "cs-k8s-protection-agent.labels" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
45 changes: 45 additions & 0 deletions helm-charts/cs-k8s-protection-agent/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Default values for cs-k8s-protection-agent.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: registry.crowdstrike.com/kubernetes_protection/kpagent
tag:
pullPolicy: IfNotPresent
envFrom:
- configMapRef:
name: agent-config

nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Annotations to add to the service account
name: ""
annotations: {}

podAnnotations: {}

podSecurityContext: {}

securityContext: {}

nodeSelector: {}

resources: {}

tolerations: []

affinity: {}

crowdstrikeConfig:
clusterName: ""
enableDebug: ""
clientID: ""
clientSecret: ""
env: ""
cid: ""
dockerAPIToken: ""
existingSecret: ""

0 comments on commit a5daa10

Please sign in to comment.