Skip to content

Commit 55bd887

Browse files
authored
Merge pull request #464 from jetstack/pf/agent-args
feat: Config and Argument configuration plus tests for these features
2 parents f8d8b5a + 85e98ce commit 55bd887

File tree

12 files changed

+449
-16
lines changed

12 files changed

+449
-16
lines changed

.github/workflows/chart-test.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Chart Testing
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- master
7+
pull_request:
8+
branches:
9+
- "*"
10+
11+
jobs:
12+
unittest:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: d3adb5/helm-unittest-action@v2
17+
with:
18+
flags: "--color --strict"
19+
charts: deploy/charts/jetstack-agent
20+
helm-version: v3.12.3
21+
# This has to be second as helm may not be installed until after above action
22+
# source: https://github.com/marketplace/actions/helm-unit-tests#examples
23+
- run: helm lint deploy/charts/jetstack-agent

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ terraform.tfstate
99
terraform.tfstate.backup
1010
bom.xml
1111
predicate.json
12+
privatekey.pem
13+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests

deploy/charts/jetstack-agent/Chart.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: v2
22
name: jetstack-agent
3-
description: Jetstack Secure Agent
3+
description: TLS Protect for Kubernetes Agent
44
type: application
5-
version: 0.2.1
6-
appVersion: "v0.1.39"
5+
version: 0.3.0
6+
appVersion: "v0.1.40"
77
home: https://github.com/jetstack/jetstack-secure
88
maintainers:
99
- name: JSCP and CRE Team

deploy/charts/jetstack-agent/README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# jetstack-agent
22

3-
Jetstack Secure Agent
3+
TLS Protect for Kubernetes Agent
44

5-
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.1.39](https://img.shields.io/badge/AppVersion-v0.1.39-informational?style=flat-square)
5+
![Version: 0.3.0](https://img.shields.io/badge/Version-0.3.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.1.40](https://img.shields.io/badge/AppVersion-v0.1.40-informational?style=flat-square)
66

77
## Additional Information
88

@@ -137,19 +137,24 @@ kubectl logs -n jetstack-secure $(kubectl get pod -n jetstack-secure -l app.kube
137137
| authentication.secretKey | string | `"credentials.json"` | Key name in secret |
138138
| authentication.secretName | string | `"agent-credentials"` | Name of the secret containing agent credentials.json |
139139
| authentication.secretValue | string | `""` | Base64 encoded value from Jetstack Secure Dashboard - only required when createSecret is true |
140-
| authentication.type | string | `"file"` | Type can be "file"/"token" which dictates whether a credential file or token is used |
141-
| config | object | `{"cluster":"","dataGatherers":{"custom":[],"default":true},"organisation":"","period":"0h1m0s","server":"https://platform.jetstack.io"}` | Configuration section for the Jetstack Agent itself |
140+
| authentication.type | string | `"file"` | Type can be "file"/"token" determining how the agent should authenticate the to the backend |
141+
| command | list | `[]` | |
142+
| config | object | `{"cluster":"","dataGatherers":{"custom":[],"default":true},"organisation":"","override":{"config":"","configmap":{"key":"","name":""},"enabled":false},"period":"0h1m0s","server":"https://platform.jetstack.io"}` | Configuration section for the Jetstack Agent itself |
142143
| config.cluster | string | `""` | REQUIRED - Your Jetstack Secure Cluster Name |
143144
| config.dataGatherers | object | `{"custom":[],"default":true}` | Configure data that is gathered from your cluster, for full details see https://platform.jetstack.io/documentation/configuration/jetstack-agent/configuration |
144145
| config.dataGatherers.custom | list | `[]` | A list of data gatherers to limit agent scope |
145146
| config.dataGatherers.default | bool | `true` | Use the standard full set of data gatherers |
146147
| config.organisation | string | `""` | REQUIRED - Your Jetstack Secure Organisation Name |
148+
| config.override | object | `{"config":"","configmap":{"key":"","name":""},"enabled":false}` | Provide an Override to allow completely custom agent configuration |
149+
| config.override.config | string | `""` | Embed the agent configuration here in the chart values |
150+
| config.override.configmap | object | `{"key":"","name":""}` | Sepcify ConfigMap details to load config from existing ConfigMap |
151+
| config.override.enabled | bool | `false` | Override disabled by default |
147152
| config.period | string | `"0h1m0s"` | Send data back to the platform every minute unless changed |
148153
| config.server | string | `"https://platform.jetstack.io"` | Overrides the server if using a proxy between agent and Jetstack Secure |
149154
| fullnameOverride | string | `""` | Helm default setting, use this to shorten install name |
150155
| image.pullPolicy | string | `"IfNotPresent"` | Defaults to only pull if not already present |
151156
| image.repository | string | `"quay.io/jetstack/preflight"` | Default to Open Source image repository |
152-
| image.tag | string | `"v0.1.39"` | Overrides the image tag whose default is the chart appVersion |
157+
| image.tag | string | `"v0.1.40"` | Overrides the image tag whose default is the chart appVersion |
153158
| imagePullSecrets | list | `[]` | Specify image pull credentials if using a prviate registry |
154159
| nameOverride | string | `""` | Helm default setting to override release name, leave blank |
155160
| nodeSelector | object | `{}` | |

deploy/charts/jetstack-agent/templates/configmap.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{ if not (and .Values.config.override.enabled .Values.config.override.configmap.name) }}
12
---
23
apiVersion: v1
34
kind: ConfigMap
@@ -6,8 +7,12 @@ metadata:
67
labels:
78
{{- include "jetstack-agent.labels" . | nindent 4 }}
89
data:
10+
{{- if .Values.config.override.config }}
911
config.yaml: |-
10-
server: {{ .Values.config.server }}
12+
{{- toYaml .Values.config.override.config | nindent 4 }}
13+
{{- else }}
14+
config.yaml: |-
15+
server: {{ .Values.config.server | quote }}
1116
organization_id: {{ required "Organisation is a required input value" .Values.config.organisation }}
1217
cluster_id: {{ required "Cluster is a required input value" .Values.config.cluster }}
1318
data-gatherers:
@@ -68,7 +73,7 @@ data:
6873
name: "k8s/cronjobs"
6974
config:
7075
resource-type:
71-
version: v1beta1
76+
version: v1
7277
resource: cronjobs
7378
group: batch
7479
- kind: "k8s-dynamic"
@@ -205,3 +210,5 @@ data:
205210
version: v1alpha1
206211
resource: venafiissuers
207212
{{- end }}
213+
{{- end }}
214+
{{- end }}

deploy/charts/jetstack-agent/templates/deployment.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,40 @@ spec:
4040
name: {{ default "agent-credentials" .Values.authentication.secretName }}
4141
key: {{ default "apitoken" .Values.authentication.secretKey }}
4242
{{- end }}
43+
{{- if not (empty .Values.command) }}
44+
command:
45+
{{- range .Values.command }}
46+
- {{ . | quote }}
47+
{{- end }}
48+
{{- end }}
4349
args:
4450
- "agent"
4551
- "-c"
52+
{{- if .Values.config.override.enabled }}
53+
- "/etc/jetstack-secure/agent/config/{{ default "config.yaml" .Values.config.override.configmap.key }}"
54+
{{- else }}
4655
- "/etc/jetstack-secure/agent/config/config.yaml"
56+
{{- end }}
4757
{{- if eq .Values.authentication.type "file" }}
4858
- "-k"
4959
- "/etc/jetstack-secure/agent/credentials/{{ default "credentials.json" .Values.authentication.secretKey}}"
5060
{{- end }}
5161
- "-p"
5262
- "0h1m0s"
63+
{{- range .Values.extraArgs }}
64+
- {{ . | quote }}
65+
{{- end }}
66+
resources:
67+
{{- toYaml .Values.resources | nindent 12 }}
5368
volumeMounts:
5469
- name: config
5570
mountPath: "/etc/jetstack-secure/agent/config"
5671
readOnly: true
5772
{{- if eq .Values.authentication.type "file" }}
5873
- name: credentials
59-
mountPath: /etc/jetstack-secure/agent/credentials
74+
mountPath: "/etc/jetstack-secure/agent/credentials"
6075
readOnly: true
6176
{{- end }}
62-
resources:
63-
{{- toYaml .Values.resources | nindent 12 }}
6477
{{- with .Values.nodeSelector }}
6578
nodeSelector:
6679
{{- toYaml . | nindent 8 }}
@@ -74,10 +87,17 @@ spec:
7487
{{- toYaml . | nindent 8 }}
7588
{{- end }}
7689
volumes:
90+
{{- if .Values.config.override.enabled }}
91+
- name: config
92+
configMap:
93+
name: {{ default "agent-config" .Values.config.override.configmap.name }}
94+
optional: false
95+
{{- else }}
7796
- name: config
7897
configMap:
7998
name: agent-config
8099
optional: false
100+
{{- end }}
81101
- name: credentials
82102
secret:
83103
secretName: {{ default "agent-credentials" .Values.authentication.secretName }}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
render correctly when only required config is given:
2+
1: |
3+
apiVersion: v1
4+
data:
5+
config.yaml: |-
6+
server: "https://platform.jetstack.io"
7+
organization_id: test_org
8+
cluster_id: test_cluster
9+
data-gatherers:
10+
# gather k8s apiserver version information
11+
- kind: "k8s-discovery"
12+
name: "k8s-discovery"
13+
# pods data is used in the pods and application_versions packages
14+
- kind: "k8s-dynamic"
15+
name: "k8s/pods"
16+
config:
17+
resource-type:
18+
resource: pods
19+
version: v1
20+
# gather services for pod readiness probe rules
21+
- kind: "k8s-dynamic"
22+
name: "k8s/services"
23+
config:
24+
resource-type:
25+
resource: services
26+
version: v1
27+
# gather higher level resources to ensure data to determine ownership is present
28+
- kind: "k8s-dynamic"
29+
name: "k8s/deployments"
30+
config:
31+
resource-type:
32+
version: v1
33+
resource: deployments
34+
group: apps
35+
- kind: "k8s-dynamic"
36+
name: "k8s/replicasets"
37+
config:
38+
resource-type:
39+
version: v1
40+
resource: replicasets
41+
group: apps
42+
- kind: "k8s-dynamic"
43+
name: "k8s/statefulsets"
44+
config:
45+
resource-type:
46+
version: v1
47+
resource: statefulsets
48+
group: apps
49+
- kind: "k8s-dynamic"
50+
name: "k8s/daemonsets"
51+
config:
52+
resource-type:
53+
version: v1
54+
resource: daemonsets
55+
group: apps
56+
- kind: "k8s-dynamic"
57+
name: "k8s/jobs"
58+
config:
59+
resource-type:
60+
version: v1
61+
resource: jobs
62+
group: batch
63+
- kind: "k8s-dynamic"
64+
name: "k8s/cronjobs"
65+
config:
66+
resource-type:
67+
version: v1
68+
resource: cronjobs
69+
group: batch
70+
- kind: "k8s-dynamic"
71+
name: "k8s/ingresses"
72+
config:
73+
resource-type:
74+
group: networking.k8s.io
75+
version: v1
76+
resource: ingresses
77+
- kind: "k8s-dynamic"
78+
name: "k8s/secrets"
79+
config:
80+
resource-type:
81+
version: v1
82+
resource: secrets
83+
- kind: "k8s-dynamic"
84+
name: "k8s/certificates"
85+
config:
86+
resource-type:
87+
group: cert-manager.io
88+
version: v1
89+
resource: certificates
90+
- kind: "k8s-dynamic"
91+
name: "k8s/certificaterequests"
92+
config:
93+
resource-type:
94+
group: cert-manager.io
95+
version: v1
96+
resource: certificaterequests
97+
- kind: "k8s-dynamic"
98+
name: "k8s/issuers"
99+
config:
100+
resource-type:
101+
group: cert-manager.io
102+
version: v1
103+
resource: issuers
104+
- kind: "k8s-dynamic"
105+
name: "k8s/clusterissuers"
106+
config:
107+
resource-type:
108+
group: cert-manager.io
109+
version: v1
110+
resource: clusterissuers
111+
- kind: "k8s-dynamic"
112+
name: "k8s/googlecasissuers"
113+
config:
114+
resource-type:
115+
group: cas-issuer.jetstack.io
116+
version: v1beta1
117+
resource: googlecasissuers
118+
- kind: "k8s-dynamic"
119+
name: "k8s/googlecasclusterissuers"
120+
config:
121+
resource-type:
122+
group: cas-issuer.jetstack.io
123+
version: v1beta1
124+
resource: googlecasclusterissuers
125+
- kind: "k8s-dynamic"
126+
name: "k8s/awspcaissuer"
127+
config:
128+
resource-type:
129+
group: awspca.cert-manager.io
130+
version: v1beta1
131+
resource: awspcaissuers
132+
- kind: "k8s-dynamic"
133+
name: "k8s/awspcaclusterissuers"
134+
config:
135+
resource-type:
136+
group: awspca.cert-manager.io
137+
version: v1beta1
138+
resource: awspcaclusterissuers
139+
- kind: "k8s-dynamic"
140+
name: "k8s/mutatingwebhookconfigurations"
141+
config:
142+
resource-type:
143+
group: admissionregistration.k8s.io
144+
version: v1
145+
resource: mutatingwebhookconfigurations
146+
- kind: "k8s-dynamic"
147+
name: "k8s/validatingwebhookconfigurations"
148+
config:
149+
resource-type:
150+
group: admissionregistration.k8s.io
151+
version: v1
152+
resource: validatingwebhookconfigurations
153+
- kind: "k8s-dynamic"
154+
name: "k8s/gateways"
155+
config:
156+
resource-type:
157+
group: networking.istio.io
158+
version: v1alpha3
159+
resource: gateways
160+
- kind: "k8s-dynamic"
161+
name: "k8s/virtualservices"
162+
config:
163+
resource-type:
164+
group: networking.istio.io
165+
version: v1alpha3
166+
resource: virtualservices
167+
- kind: "k8s-dynamic"
168+
name: "k8s/routes"
169+
config:
170+
resource-type:
171+
version: v1
172+
group: route.openshift.io
173+
resource: routes
174+
- kind: "k8s-dynamic"
175+
name: "k8s/venaficlusterissuers"
176+
config:
177+
resource-type:
178+
group: jetstack.io
179+
version: v1alpha1
180+
resource: venaficlusterissuers
181+
- kind: "k8s-dynamic"
182+
name: "k8s/venafiissuers"
183+
config:
184+
resource-type:
185+
group: jetstack.io
186+
version: v1alpha1
187+
resource: venafiissuers
188+
kind: ConfigMap
189+
metadata:
190+
labels:
191+
app.kubernetes.io/instance: RELEASE-NAME
192+
app.kubernetes.io/managed-by: Helm
193+
app.kubernetes.io/name: jetstack-agent
194+
app.kubernetes.io/version: v0.1.40
195+
helm.sh/chart: jetstack-agent-0.3.0
196+
name: agent-config

0 commit comments

Comments
 (0)