generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from mneverov/helm
Add helm chart.
- Loading branch information
Showing
7 changed files
with
281 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
apiVersion: v2 | ||
name: kube-network-policies | ||
description: A Helm chart for Kubernetes Network Policies | ||
type: application | ||
version: 0.0.1 | ||
appVersion: "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "kube-network-policies.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 "kube-network-policies.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 "kube-network-policies.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "kube-network-policies.labels" -}} | ||
helm.sh/chart: {{ include "kube-network-policies.chart" . }} | ||
{{ include "kube-network-policies.selectorLabels" . }} | ||
k8s-app: {{ include "kube-network-policies.name" . }} | ||
tier: node | ||
{{- if .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "kube-network-policies.selectorLabels" -}} | ||
app: {{ include "kube-network-policies.name" . }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "kube-network-policies.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "kube-network-policies.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: {{ template "kube-network-policies.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "kube-network-policies.labels" . | nindent 4 }} | ||
{{- with .Values.daemonset.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
{{- with .Values.daemonset.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
{{- include "kube-network-policies.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "kube-network-policies.labels" . | nindent 8 }} | ||
{{- with .Values.daemonset.labels }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
hostNetwork: true | ||
dnsPolicy: ClusterFirst | ||
{{- with .Values.daemonset.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .Values.daemonset.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ include "kube-network-policies.serviceAccountName" . }} | ||
containers: | ||
- name: kube-network-policies | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
args: | ||
- /bin/netpol | ||
- --hostname-override=$(MY_NODE_NAME) | ||
- --v=2 | ||
{{- if .Values.adminNetworkPolicy }} | ||
- --nfqueue-id=99 | ||
- --admin-network-policy=true | ||
- --baseline-admin-network-policy=true | ||
{{- else }} | ||
- --nfqueue-id=98 | ||
{{- end }} | ||
{{- with .Values.daemonset.resources }} | ||
resources: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
{{- with .Values.daemonset.securityContext }} | ||
securityContext: | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
env: | ||
- name: MY_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
{{- with .Values.daemonset.extraEnv }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
volumeMounts: | ||
- name: lib-modules | ||
mountPath: /lib/modules | ||
readOnly: true | ||
volumes: | ||
- name: lib-modules | ||
hostPath: | ||
path: /lib/modules |
62 changes: 62 additions & 0 deletions
62
charts/kube-network-policies/templates/serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "kube-network-policies.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "kube-network-policies.labels" . | nindent 4 }} | ||
{{- with .Values.serviceAccount.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "kube-network-policies.serviceAccountName" . }} | ||
labels: | ||
{{- include "kube-network-policies.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
- namespaces | ||
{{- if .Values.baselineAdminNetworkPolicy }} | ||
- nodes | ||
{{- end }} | ||
verbs: | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "networking.k8s.io" | ||
resources: | ||
- networkpolicies | ||
verbs: | ||
- list | ||
- watch | ||
{{- if .Values.baselineAdminNetworkPolicy }} | ||
- apiGroups: | ||
- "policy.networking.k8s.io" | ||
resources: | ||
- adminnetworkpolicies | ||
- baselineadminnetworkpolicies | ||
verbs: | ||
- list | ||
- watch | ||
{{- end }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ include "kube-network-policies.serviceAccountName" . }} | ||
labels: | ||
{{- include "kube-network-policies.labels" . | nindent 4 }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ include "kube-network-policies.serviceAccountName" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "kube-network-policies.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
image: | ||
repository: registry.k8s.io/networking/kube-network-policies | ||
pullPolicy: IfNotPresent | ||
tag: "v0.6.0" | ||
|
||
nameOverride: "" | ||
fullnameOverride: "" | ||
|
||
adminNetworkPolicy: true | ||
|
||
serviceAccount: | ||
annotations: {} | ||
name: kube-network-policies | ||
|
||
daemonset: | ||
annotations: {} | ||
labels: {} | ||
nodeSelector: | ||
kubernetes.io/os: linux | ||
tolerations: | ||
- operator: Exists | ||
effect: NoSchedule | ||
extraEnv: [] | ||
securityContext: | ||
privileged: true | ||
capabilities: | ||
add: ["NET_ADMIN"] | ||
resources: | ||
requests: | ||
cpu: "100m" | ||
memory: "50Mi" |