Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add k8s-daemonset helm-chart - inital cut #134

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions charts/k8s-daemonset/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
11 changes: 11 additions & 0 deletions charts/k8s-daemonset/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
name: k8s-daemonset
description: A Helm chart to package your application container for Kubernetes
# This will be updated with the release tag in the CI/CD pipeline before publishing. This has to be a valid semver for
# the linter to accept.
version: 0.0.1-replace
home: https://github.com/gruntwork-io/helm-kubernetes-services
maintainers:
- name: Gruntwork
email: [email protected]
url: https://gruntwork.io
1,202 changes: 1,202 additions & 0 deletions charts/k8s-daemonset/README.md

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions charts/k8s-daemonset/linter_values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#----------------------------------------------------------------------------------------------------------------------
# CHART PARAMETERS TO USE WITH HELM LINT
# This file declares a complete configuration value for this chart, with required values defined so that it can be used
# with helm lint to lint the chart. This should only specify the required values of the chart, and be combined with the
# default values of the chart.
# This is a YAML-formatted file.
#----------------------------------------------------------------------------------------------------------------------

#----------------------------------------------------------------------------------------------------------------------
# REQUIRED VALUES
# These values are expected to be defined and passed in by the operator when deploying this helm chart.
#----------------------------------------------------------------------------------------------------------------------

# containerImage is a map that describes the container image that should be used to serve the application managed by
# this chart.
# The expected keys are:
# - repository (string) (required) : The container image repository that should be used.
# E.g `nginx` ; `gcr.io/kubernetes-helm/tiller`
# - tag (string) (required) : The tag of the image (e.g `latest`) that should be used. We recommend using a
# fixed tag or the SHA of the image. Avoid using the tags `latest`, `head`,
# `canary`, or other tags that are designed to be “floating”.
# - pullPolicy (string) : The image pull policy to employ. Determines when the image will be pulled in. See
# the official Kubernetes docs for more info. If undefined, this will default to
# `IfNotPresent`.
#
# The following example deploys the `nginx:stable` image with a `IfNotPresent` image pull policy, which indicates that
# the image should only be pulled if it has not been pulled previously.
#
# EXAMPLE:
#
# containerImage:
# repository: nginx
# tag: stable
# pullPolicy: IfNotPresent
containerImage:
repository: nginx
tag: stable
pullPolicy: IfNotPresent

# applicationName is a string that names the application. This is used to label the pod and to name the main application
# container in the pod spec. The label is keyed under "gruntwork.io/app-name"
applicationName: "linter"
43 changes: 43 additions & 0 deletions charts/k8s-daemonset/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Check the status of your Deployment by running this comamnd:

kubectl get daemonsets --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "k8s-daemonset.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"


List the related Pods with the following command:

kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "k8s-daemonset.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"


Use the following command to view information about the Service:

kubectl get services --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "k8s-daemonset.name" . }},app.kubernetes.io/instance={{ .Release.Name }}"


{{ if .Values.containerPorts -}}
{{- $serviceType := .Values.service.type | default "ClusterIP" -}}
Get the application URL by running these commands:

{{- if .Values.ingress.enabled }}
{{- range .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ . }}{{ $.Values.ingress.path }}
{{- end }}
{{- else if contains "NodePort" $serviceType }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "k8s-daemonset.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" $serviceType }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get svc -w {{ include "k8s-daemonset.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "k8s-daemonset.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" $serviceType }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "k8s-daemonset.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
{{- range $portName, $portSpec := .Values.containerPorts }}
{{- if not $portSpec.disabled }}
echo "Visit http://127.0.0.1:80{{ $portSpec.port }} to use your application container serving port {{ $portName }}"
kubectl port-forward $POD_NAME 80{{ $portSpec.port }}:{{ $portSpec.port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
42 changes: 42 additions & 0 deletions charts/k8s-daemonset/templates/_capabilities_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{/* Allow KubeVersion to be overridden. This is mostly used for testing purposes. */}}
{{- define "gruntwork.kubeVersion" -}}
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride -}}
{{- end -}}

{{/* Get Ingress API Version */}}
{{- define "gruntwork.ingress.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" (include "gruntwork.kubeVersion" .)) -}}
{{- print "networking.k8s.io/v1" -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/* Ingress API version aware ingress backend */}}
{{- define "gruntwork.ingress.backend" -}}
{{/* NOTE: The leading whitespace is significant, as it is the specific yaml indentation for injection into the ingress resource. */}}
{{- if eq .ingressAPIVersion "networking.k8s.io/v1" }}
service:
name: {{ if .serviceName }}{{ .serviceName }}{{ else }}{{ .fullName }}{{ end }}
port:
{{- if int .servicePort }}
number: {{ .servicePort }}
{{- else }}
name: {{ .servicePort }}
{{- end }}
{{- else }}
serviceName: {{ if .serviceName }}{{ .serviceName }}{{ else }}{{ .fullName }}{{ end }}
servicePort: {{ .servicePort }}
{{- end }}
{{- end -}}

{{/* Get PodDisruptionBudget API Version */}}
{{- define "gruntwork.pdb.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">= 1.21-0" (include "gruntwork.kubeVersion" .)) -}}
{{- print "policy/v1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}
Loading