Skip to content

Commit 3d658a4

Browse files
authored
fix: make aws region required (#3)
* fix: make aws region required * fix: remove references of region from the secret * fix: add a pod disruption budget
1 parent 75657e5 commit 3d658a4

File tree

7 files changed

+25
-4
lines changed

7 files changed

+25
-4
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ helm-clean:
161161

162162
# does not work without explicitly specifying the api version
163163
# see: https://github.com/helm/helm/issues/6505
164+
# we explicitly set awsCredentials.awsRegion so that we pass the validate stage but the validation still occurs
164165
.PHONY: helm-validate
165166
helm-validate:
166167
helm template node-tagger \
@@ -171,6 +172,7 @@ helm-validate:
171172
-a monitoring.coreos.com/v1 \
172173
-a apiextensions.k8s.io/v1beta1 \
173174
-a credstash.ouzi.tech/v1 \
175+
--set awsCredentials.awsRegion=us-west-2 \
174176
$(CHART_PATH)/${CHART_NAME}
175177

176178
.PHONY: helm-package

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ node-tagger is a Kubernetes operator that applies specified tags to all aws node
1010
The controller requires AWS credentials to be set before deploying it. This is accomplished by creating a secret with name `aws-credentials` in the controller namespace with the following keys:
1111
* AWS_ACCESS_KEY_ID
1212
* AWS_SECRET_ACCESS_KEY
13-
* AWS_REGION
1413

1514
For example running the following will create an appropriate secret in the `node-tagger` namespace:
1615
```
17-
kubectl create secret generic aws-credentials --from-literal=AWS_ACCESS_KEY_ID=access_key --from-literal=AWS_SECRET_ACCESS_KEY=secret_access_key --from-literal=AWS_REGION=us-west-2 --namespace=node-tagger
16+
kubectl create secret generic aws-credentials --from-literal=AWS_ACCESS_KEY_ID=access_key --from-literal=AWS_SECRET_ACCESS_KEY=secret_access_key --namespace=node-tagger
1817
```
1918

2019
### Required IAM permissions

deploy/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ spec:
4444
path: /readyz
4545
port: http
4646
env:
47+
- name: AWS_REGION
48+
value: "us-east-1"
4749
- name: SERVICE_MONITOR_NAMESPACE
4850
valueFrom:
4951
fieldRef:

deploy/helm/node-tagger/templates/aws_credentials_secret.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ type: Opaque
1313
data:
1414
AWS_ACCESS_KEY_ID: {{ .Values.awsCredentials.awsAccessKeyId | b64enc }}
1515
AWS_SECRET_ACCESS_KEY: {{ .Values.awsCredentials.awsSecretAccessKey | b64enc }}
16-
AWS_REGION: {{ .Values.awsCredentials.awsRegion | b64enc }}
1716
{{- end -}}

deploy/helm/node-tagger/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ spec:
5555
name: {{ include "node-tagger.credentialsSecretName" . }}
5656
{{- end }}
5757
env:
58+
- name: AWS_REGION
59+
value: {{ required "A valid AWS region is required. Please set .Values.awsCredentials.awsRegion" .Values.awsCredentials.awsRegion }}
5860
- name: SERVICE_MONITOR_NAMESPACE
5961
valueFrom:
6062
fieldRef:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- if .Values.podDisruptionBudget -}}
2+
apiVersion: policy/v1beta1
3+
kind: PodDisruptionBudget
4+
metadata:
5+
name: {{ template "node-tagger.fullname" . }}
6+
labels:
7+
{{- include "node-tagger.labels" . | nindent 4 }}
8+
spec:
9+
selector:
10+
matchLabels:
11+
{{- include "node-tagger.selectorLabels" . | nindent 6 }}
12+
{{ toYaml .Values.podDisruptionBudget | indent 2 }}
13+
{{- end -}}

deploy/helm/node-tagger/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ imagePullSecrets: []
1212
nameOverride: ""
1313
fullnameOverride: ""
1414

15+
podDisruptionBudget:
16+
minAvailable: 1
17+
1518
awsCredentials:
19+
# Region must always be set
20+
awsRegion:
1621
# Whether to mount the secret in the pod
1722
# Set to false if you want to use a different aws auth method e.g. eks iam service account
1823
useSecret: true
@@ -22,7 +27,6 @@ awsCredentials:
2227
secretName:
2328
awsAccessKeyId:
2429
awsSecretAccessKey:
25-
awsRegion:
2630

2731
# Specifies the tags to apply to the aws node instances
2832
tagsToApply:

0 commit comments

Comments
 (0)