Skip to content

Commit 7d7589b

Browse files
Refactor TLS, CASecret logic
1 parent dd340c8 commit 7d7589b

6 files changed

Lines changed: 5 additions & 64 deletions

File tree

api/v1/coroot_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ type AgentsOnlySpec struct {
3434
CorootURL string `json:"corootURL,omitempty"`
3535
// Whether to skip verification of the Coroot server's TLS certificate.
3636
TLSSkipVerify bool `json:"tlsSkipVerify,omitempty"`
37-
// Secret containing the CA certificate to verify the Coroot server's certificate.
38-
CASecret *corev1.SecretKeySelector `json:"caSecret,omitempty"`
3937
}
4038

4139
type AgentTLSSpec struct {

api/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/coroot.com_coroots.yaml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -962,31 +962,6 @@ spec:
962962
description: Configures the operator to install only the node-agent
963963
and cluster-agent.
964964
properties:
965-
caSecret:
966-
description: Secret containing the CA certificate to verify the
967-
Coroot server's certificate.
968-
properties:
969-
key:
970-
description: The key of the secret to select from. Must be
971-
a valid secret key.
972-
type: string
973-
name:
974-
default: ""
975-
description: |-
976-
Name of the referent.
977-
This field is effectively required, but due to backwards compatibility is
978-
allowed to be empty. Instances of this type with an empty value here are
979-
almost certainly wrong.
980-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
981-
type: string
982-
optional:
983-
description: Specify whether the Secret or its key must be
984-
defined
985-
type: boolean
986-
required:
987-
- key
988-
type: object
989-
x-kubernetes-map-type: atomic
990965
corootURL:
991966
description: URL of the Coroot instance to which agents send metrics,
992967
logs, traces, and profiles.

config/crd/coroot.com_coroots_legacy.yaml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -869,27 +869,6 @@ spec:
869869
agentsOnly:
870870
description: Configures the operator to install only the node-agent and cluster-agent.
871871
properties:
872-
caSecret:
873-
description: Secret containing the CA certificate to verify the Coroot server's certificate.
874-
properties:
875-
key:
876-
description: The key of the secret to select from. Must be a valid secret key.
877-
type: string
878-
name:
879-
default: ""
880-
description: |-
881-
Name of the referent.
882-
This field is effectively required, but due to backwards compatibility is
883-
allowed to be empty. Instances of this type with an empty value here are
884-
almost certainly wrong.
885-
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
886-
type: string
887-
optional:
888-
description: Specify whether the Secret or its key must be defined
889-
type: boolean
890-
required:
891-
- key
892-
type: object
893872
corootURL:
894873
description: URL of the Coroot instance to which agents send metrics, logs, traces, and profiles.
895874
pattern: ^https?://.+$

controller/cluster_agent.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,12 @@ func (r *CorootReconciler) clusterAgentDeployment(cr *corootv1.Coroot) *appsv1.D
9999
port = cr.Spec.Service.HTTPSPort
100100
}
101101
corootURL := fmt.Sprintf("%s://%s-coroot.%s:%d", scheme, cr.Name, cr.Namespace, port)
102-
var tlsSkipVerify bool
103-
var caSecret *corev1.SecretKeySelector
104102
if cr.Spec.AgentsOnly != nil && cr.Spec.AgentsOnly.CorootURL != "" {
105103
corootURL = cr.Spec.AgentsOnly.CorootURL
106-
tlsSkipVerify = cr.Spec.AgentsOnly.TLSSkipVerify
107-
caSecret = cr.Spec.AgentsOnly.CASecret
108104
}
105+
tlsSkipVerify := (cr.Spec.AgentsOnly != nil && cr.Spec.AgentsOnly.TLSSkipVerify) || (cr.Spec.ClusterAgent.TLS != nil && cr.Spec.ClusterAgent.TLS.TLSSkipVerify)
106+
var caSecret *corev1.SecretKeySelector
109107
if cr.Spec.ClusterAgent.TLS != nil {
110-
tlsSkipVerify = cr.Spec.ClusterAgent.TLS.TLSSkipVerify
111108
caSecret = cr.Spec.ClusterAgent.TLS.CASecret
112109
}
113110
scrapeInterval := cmp.Or(cr.Spec.MetricsRefreshInterval, corootv1.DefaultMetricRefreshInterval)

controller/node_agent.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,12 @@ func (r *CorootReconciler) nodeAgentDaemonSet(cr *corootv1.Coroot) *appsv1.Daemo
3030
port = cr.Spec.Service.HTTPSPort
3131
}
3232
corootURL := fmt.Sprintf("%s://%s-coroot.%s:%d", scheme, cr.Name, cr.Namespace, port)
33-
var tlsSkipVerify bool
34-
var caSecret *corev1.SecretKeySelector
3533
if cr.Spec.AgentsOnly != nil && cr.Spec.AgentsOnly.CorootURL != "" {
3634
corootURL = strings.TrimRight(cr.Spec.AgentsOnly.CorootURL, "/")
37-
tlsSkipVerify = cr.Spec.AgentsOnly.TLSSkipVerify
38-
caSecret = cr.Spec.AgentsOnly.CASecret
3935
}
36+
tlsSkipVerify := (cr.Spec.AgentsOnly != nil && cr.Spec.AgentsOnly.TLSSkipVerify) || (cr.Spec.NodeAgent.TLS != nil && cr.Spec.NodeAgent.TLS.TLSSkipVerify)
37+
var caSecret *corev1.SecretKeySelector
4038
if cr.Spec.NodeAgent.TLS != nil {
41-
tlsSkipVerify = cr.Spec.NodeAgent.TLS.TLSSkipVerify
4239
caSecret = cr.Spec.NodeAgent.TLS.CASecret
4340
}
4441
scrapeInterval := cmp.Or(cr.Spec.MetricsRefreshInterval, corootv1.DefaultMetricRefreshInterval)

0 commit comments

Comments
 (0)