Skip to content

Commit

Permalink
Add flags for operator to make it possible using k8s api without TP CRDs
Browse files Browse the repository at this point in the history
Fixes: #1880

Signed-off-by: Alexey Olshanskiy <gh@aohoy.dev>
  • Loading branch information
aohoyd committed Jan 10, 2024
1 parent 81b130f commit fe9beba
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/content/en/docs/reference/helm-chart.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion install/kubernetes/tetragon/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ metadata:
data:
skip-crd-creation: {{ .Values.tetragonOperator.skipCRDCreation | quote }}
skip-pod-info-crd: {{ not .Values.tetragonOperator.podInfo.enabled | quote }}
skip-tracing-policy-crd: {{ not .Values.tetragonOperator.tracingPolicy.enabled | quote }}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,5 @@ data:
enable-msg-handling-latency: "true"
{{- end }}
enable-pod-info: {{ .Values.tetragonOperator.podInfo.enabled | quote }}
enable-tracing-policy-crd: {{ .Values.tetragonOperator.tracingPolicy.enabled | quote }}
{{- include "configmap.extra" . | nindent 2 }}
3 changes: 3 additions & 0 deletions install/kubernetes/tetragon/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ tetragonOperator:
# -- Enables the PodInfo CRD and the controller that reconciles PodInfo
# custom resources.
enabled: false
tracingPolicy:
# -- Enables the TracingPolicy and TracingPolicyNamespaced CRD creation.
enabled: true
# -- Enables the Tetragon Operator metrics.
prometheus:
enabled: true
Expand Down
1 change: 1 addition & 0 deletions operator/cmd/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func AddCommonFlags(cmd *cobra.Command) {
flags.String(operatorOption.KubeCfgPath, "", "Kubeconfig filepath to connect to k8s")
flags.String(operatorOption.ConfigDir, "", "Directory in which tetragon-operator-config configmap is mounted")
flags.Bool(operatorOption.SkipPodInfoCRD, false, "When true, PodInfo Custom Resource Definition (CRD) will not be created")
flags.Bool(operatorOption.SkipTracingPolicyCRD, false, "When true, TracingPolicy and TracingPolicyNamespaced Custom Resource Definition (CRD) will not be created")
}

func Initialize(cmd *cobra.Command) {
Expand Down
7 changes: 6 additions & 1 deletion operator/crd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ func RegisterCRDs() {

crds := []crdutils.CRD{}
for _, crd := range client.AllCRDs {
if option.Config.SkipPodInfoCRD && crd.CRDName == client.PodInfoCRD.CRDName {
switch {
case option.Config.SkipPodInfoCRD && crd.CRDName == client.PodInfoCRD.CRDName:
continue
case option.Config.SkipTracingPolicyCRD && crd.CRDName == client.TracingPolicyCRD.CRDName:
continue
case option.Config.SkipTracingPolicyCRD && crd.CRDName == client.TracingPolicyNamespacedCRD.CRDName:
continue
}
crds = append(crds, crd)
Expand Down
9 changes: 9 additions & 0 deletions operator/option/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const (
// SkipPodInfoCRD specifies whether the tetragonPod CustomResourceDefinition will be
// disabled
SkipPodInfoCRD = "skip-pod-info-crd"

// SkipTracingPolicyCRD specifies whether the tracing-policies CustomResourceDefinition will be
// disabled
SkipTracingPolicyCRD = "skip-tracing-policy-crd"
)

// OperatorConfig is the configuration used by the operator.
Expand All @@ -42,6 +46,10 @@ type OperatorConfig struct {

// SkipPodInfoCRD disables creation of the TetragonPod CustomResourceDefinition only.
SkipPodInfoCRD bool

// SkipTracingPolicyCRD disables creation of the TracingPolicy and
// TracingPolicyNamespaced CustomResourceDefinition only.
SkipTracingPolicyCRD bool
}

// Config represents the operator configuration.
Expand All @@ -53,4 +61,5 @@ func ConfigPopulate() {
Config.KubeCfgPath = viper.GetString(KubeCfgPath)
Config.ConfigDir = viper.GetString(ConfigDir)
Config.SkipPodInfoCRD = viper.GetBool(SkipPodInfoCRD)
Config.SkipTracingPolicyCRD = viper.GetBool(SkipTracingPolicyCRD)
}

0 comments on commit fe9beba

Please sign in to comment.