Open
Conversation
Signed-off-by: Konstantin Kozoriz <konstantin.kozoriz@flant.com>
When --publish is not explicitly set, detect whether the client is inside the target cluster by probing the ClusterIP of the default/kubernetes service and comparing UIDs. Signed-off-by: Konstantin Kozoriz <konstantin.kozoriz@flant.com>
Signed-off-by: Konstantin Kozoriz <konstantin.kozoriz@flant.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
--publishis not explicitly provided, the CLI now auto-detects whether the user is inside the target cluster by probing the default/kubernetes service via its ClusterIP.How it works
Service default/kubernetesvia the normal kubeconfig endpoint to get its ClusterIP and UID.https://<ClusterIP>:443with a short timeout (3s).Changes
internal/data/publish.go- PublishFlag struct and ParsePublishFlag for three-state flag parsing (explicit true / explicit false / not set).internal/data/publish_detect.go- ResolvePublish, DetectPublish, and isNetworkUnreachable implementing the auto-detection logic.pkg/libsaferequest/client/http.go- SetProbeEndpoint and Copy methods on SafeClient to configure and clone the probe client without mutating the original.internal/data/dataexport/cmd/{create,download,list}- integrated ParsePublishFlag + ResolvePublish replacing direct GetBool("publish").internal/data/dataimport/cmd/{create,upload}- same integration for import commands.internal/data/data{export,import}/util/util.go- GetData{Export,Import}WithRestart now accepts publish bool for publish reconciliation.internal/data/publish_detect_test.go- unit tests covering isNetworkUnreachable, ResolvePublish, getKubeService, and DetectPublish.Usage
In cluster
Commands run from a node inside the target cluster. Auto-detection probes the ClusterIP successfully, UIDs match ->
publish=false.d8 data export create
Note: auto-detect selects
publish=false, DataExport has no Public URL - accessible only within the cluster.d8 data export download
d8 data export list
Out of cluster
Commands run from a developer laptop. ClusterIP is not routable -> auto-detect selects
publish=true.d8 data export create
Note: auto-detect selects
publish=true, DataExport gets a Public URL for external access.d8 data export download
d8 data export list
d8 data export download (when DataExport.Spec.Publish=false)
Demonstrates one-way reconciliation: DataExport was created with
spec.publish=falsefrom inside the cluster. When download runs from outside, auto-detect resolvespublish=trueand patches the existing DataExport - Public URL appears, download uses it.