Skip to content

Commit

Permalink
Merge pull request #34 from DelusionalOptimist/chore/auth-token-secret
Browse files Browse the repository at this point in the history
chore(all-jobs): move auth token to K8s secret
  • Loading branch information
DelusionalOptimist authored Sep 11, 2024
2 parents aaa8ee9 + 8fb5584 commit c34e93c
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ spec:
resources: {}
env:
- name: AUTH_TOKEN
value: {{ .Values.accuknox.authToken }}
valueFrom:
secretKeyRef:
key: AUTH_TOKEN
{{- if (.Values.accuknox.secretName | empty) }}
name: cis-k8s-job-auth-token
{{- else }}
name: {{ .Values.accuknox.secretName }}
{{- end }}
- name: CLUSTER_NAME
value: {{ .Values.accuknox.clusterName }}
- name: LABEL_NAME
Expand Down
11 changes: 9 additions & 2 deletions cis-k8s-job/templates/cis-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ spec:
resources: {}
env:
- name: AUTH_TOKEN
value: {{ .Values.accuknox.authToken }}
valueFrom:
secretKeyRef:
key: AUTH_TOKEN
{{- if (.Values.accuknox.secretName | empty) }}
name: cis-k8s-job-auth-token
{{- else }}
name: {{ .Values.accuknox.secretName }}
{{- end }}
- name: CLUSTER_NAME
value: {{ .Values.accuknox.clusterName }}
- name: LABEL_NAME
Expand Down Expand Up @@ -110,4 +117,4 @@ spec:
name: etc-cni-netd
- hostPath:
path: /opt/cni/bin/
name: opt-cni-bin
name: opt-cni-bin
10 changes: 10 additions & 0 deletions cis-k8s-job/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if (.Values.accuknox.secretName | empty) }}
# if user didn't specify a secretName, use the default
apiVersion: v1
kind: Secret
metadata:
name: cis-k8s-job-auth-token
namespace: {{ .Release.Namespace }}
data:
AUTH_TOKEN: {{ .Values.accuknox.authToken | b64enc }}
{{- end }}
1 change: 1 addition & 0 deletions cis-k8s-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ accuknox:
clusterId: ""
tenantId: ""
url: "cspm.demo.accuknox.com"
secretName: ""
11 changes: 9 additions & 2 deletions k8tls-job/templates/k8tls-cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ spec:
name: k8tls-job
resources: {}
env:
- name: AUTH_TOKEN
valueFrom:
secretKeyRef:
key: AUTH_TOKEN
{{- if (.Values.accuknox.secretName | empty) }}
name: k8tls-job-auth-token
{{- else }}
name: {{ .Values.accuknox.secretName }}
{{- end }}
- name: URL
value: {{ .Values.accuknox.URL }}
- name: TENANT_ID
value: {{ .Values.accuknox.tenantID | quote }}
- name: AUTH_TOKEN
value: {{ .Values.accuknox.authToken }}
- name: CLUSTER_NAME
value: {{ if ne .Values.accuknox.clusterName "" }}{{ .Values.accuknox.clusterName }}{{ else }}{{ "default" }}{{ end }}
- name: LABEL_NAME
Expand Down
11 changes: 9 additions & 2 deletions k8tls-job/templates/k8tls-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ spec:
name: k8tls-job
resources: {}
env:
- name: AUTH_TOKEN
valueFrom:
secretKeyRef:
key: AUTH_TOKEN
{{- if (.Values.accuknox.secretName | empty) }}
name: k8tls-job-auth-token
{{- else }}
name: {{ .Values.accuknox.secretName }}
{{- end }}
- name: URL
value: {{ .Values.accuknox.URL }}
- name: TENANT_ID
value: {{ .Values.accuknox.tenantID | quote }}
- name: AUTH_TOKEN
value: {{ .Values.accuknox.authToken }}
- name: CLUSTER_NAME
value: {{ if ne .Values.accuknox.clusterName "" }}{{ .Values.accuknox.clusterName }}{{ else }}{{ "default" }}{{ end }}
- name: LABEL_NAME
Expand Down
10 changes: 10 additions & 0 deletions k8tls-job/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if (.Values.accuknox.secretName | empty) }}
# if user didn't specify a secretName, use the default
apiVersion: v1
kind: Secret
metadata:
name: k8tls-job-auth-token
namespace: {{ .Release.Namespace }}
data:
AUTH_TOKEN: {{ .Values.accuknox.authToken | b64enc }}
{{- end }}
1 change: 1 addition & 0 deletions k8tls-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ accuknox:
clusterName: ""
label: ""
URL: "cspm.demo.accuknox.com"
secretName: ""
11 changes: 9 additions & 2 deletions kiem-job/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ spec:
name: accuknox-kiem-cronjob
resources: {}
env:
- name: AUTH_TOKEN
valueFrom:
secretKeyRef:
key: AUTH_TOKEN
{{- if (.Values.accuknox.secretName | empty) }}
name: kiem-job-auth-token
{{- else }}
name: {{ .Values.accuknox.secretName }}
{{- end }}
- name: URL
value: {{ .Values.accuknox.URL }}
- name: TENANT_ID
value: {{ .Values.accuknox.tenantID | quote }}
- name: AUTH_TOKEN
value: {{ .Values.accuknox.authToken }}
- name: CLUSTER_NAME
value: {{ .Values.accuknox.clusterName }}
- name: LABEL_NAME
Expand Down
13 changes: 10 additions & 3 deletions kiem-job/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ spec:
name: accuknox-kiem-job
resources: {}
env:
- name: AUTH_TOKEN
valueFrom:
secretKeyRef:
key: AUTH_TOKEN
{{- if (.Values.accuknox.secretName | empty) }}
name: kiem-job-auth-token
{{- else }}
name: {{ .Values.accuknox.secretName }}
{{- end }}
- name: URL
value: {{ .Values.accuknox.URL }}
- name: TENANT_ID
value: {{ .Values.accuknox.tenantID | quote }}
- name: AUTH_TOKEN
value: {{ .Values.accuknox.authToken }}
- name: CLUSTER_NAME
value: {{ .Values.accuknox.clusterName }}
- name: LABEL_NAME
Expand All @@ -42,4 +49,4 @@ spec:
- name: datapath
emptyDir: {}
restartPolicy: OnFailure
serviceAccount: kiem-service-account
serviceAccount: kiem-service-account
10 changes: 10 additions & 0 deletions kiem-job/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if (.Values.accuknox.secretName | empty) }}
# if user didn't specify a secretName, use the default
apiVersion: v1
kind: Secret
metadata:
name: kiem-job-auth-token
namespace: {{ .Release.Namespace }}
data:
AUTH_TOKEN: {{ .Values.accuknox.authToken | b64enc }}
{{- end }}
1 change: 1 addition & 0 deletions kiem-job/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ accuknox:
cronTab: "30 9 * * *"
clusterName: ""
label: ""
secretName: ""

0 comments on commit c34e93c

Please sign in to comment.