Skip to content

Commit ee712ef

Browse files
author
Fawad Khaliq
committed
Add lint and dry run checks for the Helm chart
1 parent 398776e commit ee712ef

File tree

4 files changed

+245
-1
lines changed

4 files changed

+245
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*.so
77
*.dylib
88
bin
9+
build
910

1011
# mkdocs generated live docs
1112
site

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
MAKEFILE_PATH = $(dir $(realpath -s $(firstword $(MAKEFILE_LIST))))
3+
24
# Image URL to use all building/pushing image targets
35
IMG ?= amazon/aws-alb-ingress-controller:v2.2.0
46

@@ -14,7 +16,7 @@ endif
1416
all: controller
1517

1618
# Run tests
17-
test: generate fmt vet manifests
19+
test: generate fmt vet manifests helm-lint
1820
go test -race ./pkg/... ./webhooks/... -coverprofile cover.out
1921

2022
# Build controller binary
@@ -51,6 +53,9 @@ fmt:
5153
vet:
5254
go vet ./...
5355

56+
helm-lint:
57+
${MAKEFILE_PATH}/test/helm/helm-lint.sh
58+
5459
# Generate code
5560
generate: controller-gen
5661
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Default values for aws-load-balancer-controller.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 2
6+
7+
image:
8+
repository: 602401143452.dkr.ecr.us-west-2.amazonaws.com/amazon/aws-load-balancer-controller
9+
tag: v2.2.0
10+
pullPolicy: IfNotPresent
11+
12+
imagePullSecrets: []
13+
nameOverride: ""
14+
fullnameOverride: ""
15+
16+
# The name of the Kubernetes cluster. A non-empty value is required
17+
clusterName: test-cluster
18+
19+
serviceAccount:
20+
# Specifies whether a service account should be created
21+
create: true
22+
# Annotations to add to the service account
23+
annotations: {}
24+
# The name of the service account to use.
25+
# If not set and create is true, a name is generated using the fullname template
26+
name:
27+
# Automount API credentials for a Service Account.
28+
automountServiceAccountToken: true
29+
30+
rbac:
31+
# Specifies whether rbac resources should be created
32+
create: true
33+
34+
podSecurityContext:
35+
fsGroup: 65534
36+
37+
securityContext:
38+
# capabilities:
39+
# drop:
40+
# - ALL
41+
readOnlyRootFilesystem: true
42+
runAsNonRoot: true
43+
allowPrivilegeEscalation: false
44+
45+
# Time period for the controller pod to do a graceful shutdown
46+
terminationGracePeriodSeconds: 10
47+
48+
resources:
49+
limits:
50+
cpu: 100m
51+
memory: 128Mi
52+
requests:
53+
cpu: 100m
54+
memory: 128Mi
55+
56+
# priorityClassName specifies the PriorityClass to indicate the importance of controller pods
57+
# ref: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#priorityclass
58+
priorityClassName: system-cluster-critical
59+
60+
nodeSelector: {}
61+
62+
tolerations: []
63+
64+
affinity: {}
65+
66+
podAnnotations: {}
67+
68+
podLabels: {}
69+
70+
# Enable cert-manager
71+
enableCertManager: false
72+
73+
# The ingress class this controller will satisfy. If not specified, controller will match all
74+
# ingresses without ingress class annotation and ingresses of type alb
75+
ingressClass: alb
76+
77+
# The AWS region for the kubernetes cluster. Set to use KIAM or kube2iam for example.
78+
region:
79+
80+
# The VPC ID for the Kubernetes cluster. Set this manually when your pods are unable to use the metadata service to determine this automatically
81+
vpcId:
82+
83+
# Maximum retries for AWS APIs (default 10)
84+
awsMaxRetries:
85+
86+
# If enabled, targetHealth readiness gate will get injected to the pod spec for the matching endpoint pods (default true)
87+
enablePodReadinessGateInject:
88+
89+
# Enable Shield addon for ALB (default true)
90+
enableShield:
91+
92+
# Enable WAF addon for ALB (default true)
93+
enableWaf:
94+
95+
# Enable WAF V2 addon for ALB (default true)
96+
enableWafv2:
97+
98+
# Maximum number of concurrently running reconcile loops for ingress (default 3)
99+
ingressMaxConcurrentReconciles:
100+
101+
# Set the controller log level - info(default), debug (default "info")
102+
logLevel:
103+
104+
# The address the metric endpoint binds to. (default ":8080")
105+
metricsBindAddr: ""
106+
107+
# The TCP port the Webhook server binds to. (default 9443)
108+
webhookBindPort:
109+
110+
# Maximum number of concurrently running reconcile loops for service (default 3)
111+
serviceMaxConcurrentReconciles:
112+
113+
# Maximum number of concurrently running reconcile loops for targetGroupBinding
114+
targetgroupbindingMaxConcurrentReconciles:
115+
116+
# Period at which the controller forces the repopulation of its local object stores. (default 1h0m0s)
117+
syncPeriod:
118+
119+
# Namespace the controller watches for updates to Kubernetes objects, If empty, all namespaces are watched.
120+
watchNamespace:
121+
122+
# disableIngressClassAnnotation disables the usage of kubernetes.io/ingress.class annotation, false by default
123+
disableIngressClassAnnotation:
124+
125+
# disableIngressGroupNameAnnotation disables the usage of alb.ingress.kubernetes.io/group.name annotation, false by default
126+
disableIngressGroupNameAnnotation:
127+
128+
# defaultSSLPolicy specifies the default SSL policy to use for TLS/HTTPS listeners
129+
defaultSSLPolicy:
130+
131+
# Liveness probe configuration for the controller
132+
livenessProbe:
133+
failureThreshold: 2
134+
httpGet:
135+
path: /healthz
136+
port: 61779
137+
scheme: HTTP
138+
initialDelaySeconds: 30
139+
timeoutSeconds: 10
140+
141+
# Environment variables to set for aws-load-balancer-controller pod.
142+
# We strongly discourage programming access credentials in the controller environment. You should setup IRSA or
143+
# comparable solutions like kube2iam, kiam etc instead.
144+
env:
145+
146+
# Specifies if aws-load-balancer-controller should be started in hostNetwork mode.
147+
#
148+
# This is required if using a custom CNI where the managed control plane nodes are unable to initiate
149+
# network connections to the pods, for example using Calico CNI plugin on EKS. This is not required or
150+
# recommended if using the Amazon VPC CNI plugin.
151+
hostNetwork: false
152+
153+
# extraVolumeMounts are the additional volume mounts. This enables setting up IRSA on non-EKS Kubernetes cluster
154+
extraVolumeMounts:
155+
- name: aws-iam-token
156+
mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount
157+
readOnly: true
158+
159+
# extraVolumes for the extraVolumeMounts. Useful to mount a projected service account token for example.
160+
extraVolumes:
161+
- name: aws-iam-token
162+
projected:
163+
defaultMode: 420
164+
sources:
165+
- serviceAccountToken:
166+
audience: sts.amazonaws.com
167+
expirationSeconds: 86400
168+
path: token
169+
170+
# defaultTags are the tags to apply to all AWS resources managed by this controller
171+
defaultTags:
172+
default_tag1: value1
173+
default_tag2: value2
174+
175+
# podDisruptionBudget specifies the disruption budget for the controller pods.
176+
# Disruption budget will be configured only when the replicaCount is greater than 1
177+
podDisruptionBudget:
178+
maxUnavailable: 1
179+
180+
# externalManagedTags is the list of tag keys on AWS resources that will be managed externally
181+
externalManagedTags: []

test/helm/helm-lint.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
set +x
5+
6+
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
7+
TMP_DIR="$SCRIPTPATH/../../build"
8+
PLATFORM=$(uname | tr '[:upper:]' '[:lower:]')
9+
HELM3_VERSION="3.3.1"
10+
HELM2_VERSION="2.16.10"
11+
HELM_DIR="${SCRIPTPATH}/../../helm"
12+
LB_HELM_CHART=${HELM_DIR}/aws-load-balancer-controller
13+
14+
mkdir -p $TMP_DIR
15+
16+
if [ ! -x "$TMP_DIR/helm" ]; then
17+
echo " Downloading the \"helm3\" binary"
18+
curl -L https://get.helm.sh/helm-v$HELM3_VERSION-$PLATFORM-amd64.tar.gz | tar zxf - -C $TMP_DIR
19+
mv $TMP_DIR/$PLATFORM-amd64/helm $TMP_DIR/.
20+
chmod +x $TMP_DIR/helm
21+
echo " Downloaded the \"helm\" binary"
22+
fi
23+
24+
if [ ! -x "$TMP_DIR/helm2" ]; then
25+
echo " Downloading the \"helm2\" binary"
26+
curl -L https://get.helm.sh/helm-v$HELM2_VERSION-$PLATFORM-amd64.tar.gz | tar zxf - -C $TMP_DIR
27+
mv $TMP_DIR/$PLATFORM-amd64/helm $TMP_DIR/helm2
28+
chmod +x $TMP_DIR/helm2
29+
echo " Downloaded the \"helm2\" binary"
30+
fi
31+
export PATH=$TMP_DIR:$PATH
32+
33+
echo "=============================================================================="
34+
echo " Linting Helm Chart w/ Helm v3"
35+
echo "=============================================================================="
36+
helm lint $LB_HELM_CHART
37+
38+
echo "=============================================================================="
39+
echo " Linting Helm Chart w/ Helm v2"
40+
echo "=============================================================================="
41+
helm2 lint $LB_HELM_CHART
42+
43+
echo " Helm Linting for v2 and v3 have successfully completed!"
44+
45+
echo "=============================================================================="
46+
echo " Generate Template w/ Helm v3"
47+
echo "=============================================================================="
48+
49+
helm template aws-load-balancer-controller "${LB_HELM_CHART}" --debug --namespace=kube-system -f "${LB_HELM_CHART}/test.yaml" > /dev/null
50+
51+
echo "=============================================================================="
52+
echo " Generate Template w/ Helm v2"
53+
echo "=============================================================================="
54+
55+
helm2 template --name aws-load-balancer-controller "${LB_HELM_CHART}" --debug --namespace=kube-system -f "${LB_HELM_CHART}/test.yaml" > /dev/null
56+
57+
echo " Helm template generation for v2 and v3 have successfully completed!"

0 commit comments

Comments
 (0)