-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new NonClusterHost resource for log ingestion #3485
Conversation
2882f3a
to
6c1eae0
Compare
// NonClusterHostSpec enables non-cluster hosts to connect to a cluster. | ||
type NonClusterHostSpec struct { | ||
// Location of the log ingestion point for non-cluster hosts. example: https://1.2.3.4:443 | ||
Endpoint string `json:"endpoint"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a required field. Should we add:
json:"endpoint" validate:"required"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth writing a custom validator, so that the string input that does not match the a predefined regex pattern prints an error at the time of creation.
This might work: // +kubebuilder:validation:Pattern=
^https?://.+$``
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation pattern is added to the endpoint field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since NonClusterHostSpec is not a required field, please mind that it is still possible to create this resource without the Endpoint field. Does that have any implications for the feature? Should the controller still validate that the field exists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonClusterHostSpec isn't required, but it's also not a pointer, which means it will be present regardless and so this field should always be defaulted by the kubebuilder validation IIUC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied the CRD to my kind cluster:
$ k apply -f nonclust.yaml
The NonClusterHost "default" is invalid: spec.endpoint: Required value
1 12:17:55 ~/dev/kind
$ cat nonclust.yaml
kind: NonClusterHost
apiVersion: operator.tigera.io/v1
metadata:
name: default
spec: {}
But then:
$ k apply -f nonclust.yaml
nonclusterhost.operator.tigera.io/default configured
0 12:18:26 ~/dev/kind
$ cat nonclust.yaml
kind: NonClusterHost
apiVersion: operator.tigera.io/v1
metadata:
name: default
spec: null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, guess I was wrong about that. Surprised that spec: null
is valid at all considering the spec isn't a pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is identical to this:
kind: NonClusterHost
apiVersion: operator.tigera.io/v1
metadata:
name: default
7859335
to
de8b353
Compare
// Check if non-cluster host log ingestion is enabled. | ||
// non-cluster hosts will only forward logs to a standalone or a managed cluster. | ||
var nonclusterhost *operatorv1.NonClusterHost | ||
if managementCluster == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if there is any harm in removing this if-statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a nonclusterhost resource is accidentally applied to a management cluster, this check prevents opening the ingestion endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to say that I don't really see the problem in having a management cluster that also has non cluster hosts working at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a minimum, I would prefer if we inverted this check - i.e., "If both are specified, error" instead of silently ignoring an unsupported configuration.
I'm fine with erroring for now if MCM is out of scope, but also fine to allow it in management clusters if we think it will come relatively for free.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec.endpoint
is validated in the manager controller. When NonClusterHost
resource is applied to the cluster and the endpoint
filed is an invalid URL, manager controller will be degraded.
The managementCluster == nil
check is also removed because management cluster should support this feature.
43dc2cc
to
1f256d0
Compare
This change introduces a new `NonClusterHost` custom resource for Calico Enterprise to support non-cluster hosts log ingestion.
1f256d0
to
e97d026
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Description
This change introduces a new
NonClusterHost
custom resource for Calico Enterprise to support non-cluster hosts log ingestion.For PR author
make gen-files
make gen-versions
For PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bug
if this is a bugfix.kind/enhancement
if this is a a new feature.enterprise
if this PR applies to Calico Enterprise only.