1+ {{- $authtype := .Values.authtype | lower }}
2+ {{- $resourceNamePrefix := .Values.global.resourceNamePrefix }}
3+ {{- $kubernetesClusterName := (include "logan.kubernetesClusterName" .) }}
4+ {{- $kubernetesClusterId := (include "logan.kubernetesClusterId" .) }}
5+ {{- $kubernetesNamespace := (include "logan.namespace" .) }}
6+ {{- $serviceAccount := (include "logan.serviceAccount" .) }}
7+ apiVersion : batch/v1
8+ kind : CronJob
9+ metadata :
10+ name : {{ .Values.global.resourceNamePrefix }}-discovery
11+ namespace : {{ $kubernetesNamespace }}
12+ spec :
13+ schedule : {{ .Values.k8sDiscovery.objects.cronSchedule | quote }}
14+ startingDeadlineSeconds : 120
15+ concurrencyPolicy : Replace
16+ successfulJobsHistoryLimit : {{ .Values.k8sDiscovery.objects.successfulJobsHistoryLimit }}
17+ failedJobsHistoryLimit : {{ .Values.k8sDiscovery.objects.failedJobsHistoryLimit }}
18+ jobTemplate :
19+ spec :
20+ backoffLimit : 2
21+ template :
22+ spec :
23+ restartPolicy : {{ .Values.k8sDiscovery.objects.restartPolicy }}
24+ serviceAccountName : {{ $serviceAccount }}
25+ containers :
26+ - name : k8-discovery-job
27+ image : {{ .Values.image.url }}
28+ {{- if eq $authtype "config" }}
29+ volumeMounts :
30+ - name : ociconfigdir
31+ mountPath : {{ .Values.oci.path }}
32+ readOnly : true
33+ {{- end }}
34+ command :
35+ {{- /* object discovery script */}}
36+ - oci-logan-kubernetes-discovery
37+ {{- /* mandatory inputs */}}
38+ - --kubernetes_cluster_id
39+ - {{ $kubernetesClusterId }}
40+ - --kubernetes_cluster_name
41+ - {{ $kubernetesClusterName }}
42+ - --kubernetes_cluster_namespace
43+ - {{ $kubernetesNamespace }}
44+ - --oci_la_namespace
45+ {{- if .Values.ociLANamespace }}
46+ - {{ .Values.ociLANamespace }}
47+ {{- else }}
48+ {{- required "ociLANamespace is required" .Values.ociLANamespace }}
49+ {{- end }}
50+ - --oci_la_log_group_id
51+ {{- if .Values.k8sDiscovery.objects.ociLALogGroupID }}
52+ - {{ .Values.k8sDiscovery.objects.ociLALogGroupID }}
53+ {{- else if .Values.ociLALogGroupID }}
54+ - {{ .Values.ociLALogGroupID }}
55+ {{- else }}
56+ {{- required "ociLALogGroupID is required" .Values.ociLALogGroupID }}
57+ {{- end }}
58+ {{- /* mandatory inputs when authtype is set as config */}}
59+ {{- if eq .Values.authtype "config" }}
60+ {{- if and .Values.oci.path .Values.oci.file }}
61+ - --config_file_location
62+ - {{ .Values.oci.path -}}/{{ .Values.oci.file }}
63+ {{- else }}
64+ {{- required "{{ .Values.oci.path -}}/{{ .Values.oci.file }} is required" .Values.oci.path }}
65+ {{- end }}
66+ {{- end }}
67+ {{- /* optional discovery job configuration */}}
68+ {{- if and .Values.ociLAClusterEntityID $resourceNamePrefix }}
69+ - --oci_la_cluster_entity_id
70+ - {{ .Values.ociLAClusterEntityID }}
71+ - --kubernetes_resourcename_prefix
72+ - {{ $resourceNamePrefix }}
73+ {{- end }}
74+ {{- if .Values.k8sDiscovery.objects.discoveryMode }}
75+ - --discovery
76+ - {{ .Values.k8sDiscovery.objects.discoveryMode }}
77+ {{- end }}
78+ {{- if .Values.k8sDiscovery.objects.log_format }}
79+ - --log_format
80+ - {{ .Values.k8sDiscovery.objects.log_format }}
81+ {{- end }}
82+ {{- if .Values.k8sDiscovery.objects.log_level }}
83+ - --log_level
84+ - {{ .Values.k8sDiscovery.objects.log_level }}
85+ {{- end }}
86+ {{- if and .Values.k8sDiscovery.objects.enable_threading .Values.k8sDiscovery.objects.thread_count }}
87+ - --enable_threading
88+ - --thread_count
89+ - {{ .Values.k8sDiscovery.objects.thread_count | quote }}
90+ {{- end }}
91+ {{- if .Values.k8sDiscovery.objects.chunk_limit }}
92+ - --chunk_limit
93+ - {{ .Values.k8sDiscovery.objects.chunk_limit | quote }}
94+ {{- end }}
95+ {{- if .Values.k8sDiscovery.objects.collect_warning_events_only }}
96+ - --collect_warning_events_only
97+ {{- end }}
98+ {{- /* optional kubernetes cluster configuration */}}
99+ {{- if .Values.k8sDiscovery.kubeClientOptions.kubernetes_url }}
100+ - --kubernetes_url
101+ - {{ .Values.k8sDiscovery.kubeClientOptions.kubernetes_url }}
102+ {{- end }}
103+ {{- if .Values.k8sDiscovery.kubeClientOptions.client_cert }}
104+ - --client_cert
105+ - {{ .Values.k8sDiscovery.kubeClientOptions.client_cert }}
106+ {{- end }}
107+ {{- if .Values.k8sDiscovery.kubeClientOptions.client_key }}
108+ - --client_key
109+ - {{ .Values.k8sDiscovery.kubeClientOptions.client_key }}
110+ {{- end }}
111+ {{- if .Values.k8sDiscovery.kubeClientOptions.ca_file }}
112+ - --ca_file
113+ - {{ .Values.k8sDiscovery.kubeClientOptions.ca_file }}
114+ {{- end }}
115+ {{- if eq .Values.k8sDiscovery.kubeClientOptions.verify_ssl true }}
116+ - --verify_ssl
117+ {{- end }}
118+ {{- if .Values.k8sDiscovery.kubeClientOptions.bearer_token_file }}
119+ - --bearer_token_file
120+ - {{ .Values.k8sDiscovery.kubeClientOptions.bearer_token_file }}
121+ {{- end }}
122+ {{- if .Values.k8sDiscovery.kubeClientOptions.secret_dir }}
123+ - --secret_dir
124+ - {{ .Values.k8sDiscovery.kubeClientOptions.secret_dir }}
125+ {{- end }}
126+ {{- /* developer options - optional */}}
127+ {{- if .Values.k8sDiscovery.oci_la_endpoint }}
128+ - --endpoint
129+ - {{ .Values.k8sDiscovery.oci_la_endpoint }}
130+ {{- else if .Values.ociLAEndpoint }}
131+ - --endpoint
132+ - {{ .Values.ociLAEndpoint }}
133+ {{- end }}
134+ {{- if eq $authtype "config" }}
135+ volumes :
136+ - name : ociconfigdir
137+ projected :
138+ sources :
139+ - secret :
140+ name : {{ $resourceNamePrefix }}-oci-config
141+ {{- end }}
0 commit comments