From 3f2393b309fd90c39de4cf8b0c17ec2568648446 Mon Sep 17 00:00:00 2001 From: Karol Szwaj Date: Fri, 24 Apr 2026 15:02:34 +0200 Subject: [PATCH] Add option to configure host aliases for konnector Signed-off-by: Karol Szwaj On-behalf-of: @SAP karol.szwaj@sap.com --- backend/http/handler.go | 19 ++- backend/kubernetes/manager.go | 59 ++++++-- backend/options/options.go | 12 ++ backend/server.go | 15 ++ ...{index.-8-K3ENk.css => index.7XpcMtlt.css} | 132 +++++++++++------- .../{index.BBkPMOmG.js => index.DE_Nx7OI.js} | 102 ++++++++------ web/dist/index.html | 4 +- web/src/components/BindingResult.vue | 46 ++++++ 8 files changed, 280 insertions(+), 109 deletions(-) rename web/dist/assets/{index.-8-K3ENk.css => index.7XpcMtlt.css} (92%) rename web/dist/assets/{index.BBkPMOmG.js => index.DE_Nx7OI.js} (99%) diff --git a/backend/http/handler.go b/backend/http/handler.go index 5bb8b53cd..09865df98 100644 --- a/backend/http/handler.go +++ b/backend/http/handler.go @@ -27,6 +27,7 @@ import ( "time" "github.com/gorilla/mux" + corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -220,7 +221,7 @@ func (h *handler) handleKonnectorManifests(w http.ResponseWriter, r *http.Reques } konnectorImage := fmt.Sprintf("ghcr.io/kube-bind/konnector:%s", konnectorVersion) - manifests := kuberesources.NewKonnectorManifests(konnectorImage, nil) + manifests := kuberesources.NewKonnectorManifests(konnectorImage, h.kubeManager.GetKonnectorHostAliases()) // Serialize each object to YAML and join with document separators s := runtime.NewScheme() @@ -556,6 +557,9 @@ type applyBindingRequest struct { ConsumerKubeconfig string `json:"consumerKubeconfig"` // BindingName is the name for the binding (used for secret and bundle naming). BindingName string `json:"bindingName"` + // HostAliases is an optional list of host alias entries for konnector pods, + // in the format "IP:hostname1,hostname2". Overrides the server-configured defaults. + HostAliases []string `json:"hostAliases,omitempty"` } // handleApplyBinding receives a consumer kubeconfig and applies the konnector + binding @@ -610,6 +614,18 @@ func (h *handler) handleApplyBinding(w http.ResponseWriter, r *http.Request) { } konnectorImage := fmt.Sprintf("ghcr.io/kube-bind/konnector:%s", konnectorVersion) + // Parse optional host alias overrides from request + var overrideHostAliases []corev1.HostAlias + for _, entry := range req.HostAliases { + parts := strings.SplitN(entry, ":", 2) + if len(parts) == 2 && parts[0] != "" && parts[1] != "" { + overrideHostAliases = append(overrideHostAliases, corev1.HostAlias{ + IP: parts[0], + Hostnames: strings.Split(parts[1], ","), + }) + } + } + // Apply to consumer cluster result, err := h.kubeManager.ApplyToConsumer( r.Context(), @@ -617,6 +633,7 @@ func (h *handler) handleApplyBinding(w http.ResponseWriter, r *http.Request) { handleResult.Kubeconfig, req.BindingName, konnectorImage, + overrideHostAliases, ) if err != nil { logger.Error(err, "failed to apply binding to consumer cluster") diff --git a/backend/kubernetes/manager.go b/backend/kubernetes/manager.go index 424e46e18..ea6f4af7e 100644 --- a/backend/kubernetes/manager.go +++ b/backend/kubernetes/manager.go @@ -57,6 +57,10 @@ type Manager struct { manager mcmanager.Manager embeddedOIDC bool + + // konnectorHostAliases are default host aliases injected into konnector + // pods deployed via the UI flow (configured via --konnector-host-alias flag). + konnectorHostAliases []corev1.HostAlias } func NewKubernetesManager( @@ -68,6 +72,7 @@ func NewKubernetesManager( externalTLSServerName string, manager mcmanager.Manager, embeddedOIDC bool, + konnectorHostAliases []corev1.HostAlias, ) (*Manager, error) { m := &Manager{ namespacePrefix: namespacePrefix, @@ -78,8 +83,9 @@ func NewKubernetesManager( externalCA: externalCA, externalTLSServerName: externalTLSServerName, - manager: manager, - embeddedOIDC: embeddedOIDC, + manager: manager, + embeddedOIDC: embeddedOIDC, + konnectorHostAliases: konnectorHostAliases, } if err := m.manager.GetFieldIndexer().IndexField(ctx, &corev1.Namespace{}, NamespacesByIdentity, @@ -464,6 +470,7 @@ func (m *Manager) ApplyToConsumer( providerKubeconfigData []byte, bindingName string, konnectorImage string, + overrideHostAliases []corev1.HostAlias, ) (*ApplyToConsumerResult, error) { logger := klog.FromContext(ctx).WithValues("bindingName", bindingName) @@ -494,10 +501,17 @@ func (m *Manager) ApplyToConsumer( return nil, fmt.Errorf("failed to create kube-bind namespace: %w", err) } - // 2. Resolve host aliases from the provider kubeconfig so the konnector - // can reach the provider API server (needed in Kind/Docker environments - // where the hostname resolves to localhost on the host but not in pods). - hostAliases := m.resolveProviderHostAliases(ctx, providerKubeconfigData) + // 2. Build host aliases: start with request overrides (if any), fall back to + // configured defaults, then merge any auto-resolved aliases from the provider kubeconfig. + var hostAliases []corev1.HostAlias + if len(overrideHostAliases) > 0 { + hostAliases = append(hostAliases, overrideHostAliases...) + } else { + hostAliases = append(hostAliases, m.konnectorHostAliases...) + } + if resolved := m.resolveProviderHostAliases(ctx, providerKubeconfigData); len(resolved) > 0 { + hostAliases = mergeHostAliases(hostAliases, resolved) + } // 3. Deploy konnector (idempotent) konnectorDeployed, err := m.ensureKonnector(ctx, consumerClient, konnectorImage, hostAliases) @@ -632,18 +646,24 @@ func (m *Manager) resolveProviderHostAliases(ctx context.Context, providerKubeco // ensureKonnector deploys the konnector agent to the consumer cluster. // Returns true if the konnector was newly deployed, false if it already existed. func (m *Manager) ensureKonnector(ctx context.Context, c client.Client, konnectorImage string, hostAliases []corev1.HostAlias) (bool, error) { + manifests := kuberesources.NewKonnectorManifests(konnectorImage, hostAliases) + // Check if konnector deployment already exists existing := &appsv1.Deployment{} err := c.Get(ctx, types.NamespacedName{Name: kuberesources.KonnectorDeploymentName, Namespace: kuberesources.KonnectorNamespace}, existing) if err == nil { - return false, nil // already deployed + // Update the deployment if host aliases changed + existing.Spec.Template.Spec.HostAliases = hostAliases + existing.Spec.Template.Spec.Containers[0].Image = konnectorImage + if err := c.Update(ctx, existing); err != nil { + return false, fmt.Errorf("failed to update konnector deployment: %w", err) + } + return false, nil } if !errors.IsNotFound(err) { return false, fmt.Errorf("failed to check for existing konnector: %w", err) } - manifests := kuberesources.NewKonnectorManifests(konnectorImage, hostAliases) - if err := c.Create(ctx, manifests.ServiceAccount); err != nil && !errors.IsAlreadyExists(err) { return false, fmt.Errorf("failed to create konnector service account: %w", err) } @@ -697,3 +717,24 @@ func (m *Manager) SeedDefaultCluster(ctx context.Context) error { logger.Info("Default Cluster resource ensured") return nil } + +// GetKonnectorHostAliases returns the configured default host aliases for konnector pods. +func (m *Manager) GetKonnectorHostAliases() []corev1.HostAlias { + return m.konnectorHostAliases +} + +// mergeHostAliases merges additional host aliases into existing ones, +// skipping entries whose IP is already present. +func mergeHostAliases(existing, additional []corev1.HostAlias) []corev1.HostAlias { + seen := make(map[string]bool, len(existing)) + for _, ha := range existing { + seen[ha.IP] = true + } + for _, ha := range additional { + if !seen[ha.IP] { + existing = append(existing, ha) + seen[ha.IP] = true + } + } + return existing +} diff --git a/backend/options/options.go b/backend/options/options.go index a4e14565f..32149ede5 100644 --- a/backend/options/options.go +++ b/backend/options/options.go @@ -79,6 +79,10 @@ type ExtraOptions struct { // SchemaSyncInterval is how often the serviceexportrequest controller re-reconciles // to detect source schema changes when SchemaUpdatePolicy is Always. SchemaSyncInterval time.Duration + + // KonnectorHostAlias is a list of host alias entries for konnector pods + // deployed via the UI flow, in the format IP:hostname1,hostname2. + KonnectorHostAlias []string } type completedOptions struct { @@ -195,6 +199,7 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&options.TestingAutoSelect, "testing-auto-select", options.TestingAutoSelect, ". that is automatically selected on th bind screen for testing") fs.MarkHidden("testing-auto-select") //nolint:errcheck + fs.StringSliceVar(&options.KonnectorHostAlias, "konnector-host-alias", options.KonnectorHostAlias, "Add host aliases to konnector pods deployed via the UI flow, in the format IP:hostname1,hostname2. Can be specified multiple times.") } func (options *Options) Complete() (*CompletedOptions, error) { @@ -323,5 +328,12 @@ func (options *CompletedOptions) Validate() error { return fmt.Errorf("--schema-sync-interval must be at least 10s, got %v", options.SchemaSyncInterval) } + for _, entry := range options.KonnectorHostAlias { + parts := strings.SplitN(entry, ":", 2) + if len(parts) != 2 || parts[0] == "" || parts[1] == "" { + return fmt.Errorf("invalid --konnector-host-alias %q, expected format IP:hostname1,hostname2", entry) + } + } + return nil } diff --git a/backend/server.go b/backend/server.go index b58f0083e..4f8b75e4d 100644 --- a/backend/server.go +++ b/backend/server.go @@ -22,8 +22,10 @@ import ( "fmt" "net" nethttp "net/http" + "strings" "sync" + corev1 "k8s.io/api/core/v1" "k8s.io/klog/v2" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/controller" @@ -79,6 +81,18 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) { Config: c, } + // Parse konnector host aliases from flag + var konnectorHostAliases []corev1.HostAlias + for _, entry := range c.Options.KonnectorHostAlias { + parts := strings.SplitN(entry, ":", 2) + if len(parts) == 2 && parts[0] != "" && parts[1] != "" { + konnectorHostAliases = append(konnectorHostAliases, corev1.HostAlias{ + IP: parts[0], + Hostnames: strings.Split(parts[1], ","), + }) + } + } + var err error s.Kubernetes, err = kube.NewKubernetesManager( ctx, @@ -90,6 +104,7 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) { c.Options.TLSExternalServerName, s.Config.Manager, c.Options.OIDC.Type == string(kubebindv1alpha2.OIDCProviderTypeEmbedded), + konnectorHostAliases, ) if err != nil { return nil, fmt.Errorf("error setting up Kubernetes Manager: %w", err) diff --git a/web/dist/assets/index.-8-K3ENk.css b/web/dist/assets/index.7XpcMtlt.css similarity index 92% rename from web/dist/assets/index.-8-K3ENk.css rename to web/dist/assets/index.7XpcMtlt.css index 98f3f8ef6..85cd73b2b 100644 --- a/web/dist/assets/index.-8-K3ENk.css +++ b/web/dist/assets/index.7XpcMtlt.css @@ -174,7 +174,7 @@ line-height: 1.5; } -.binding-modal-overlay[data-v-21112df8] { +.binding-modal-overlay[data-v-6ba48543] { position: fixed; top: 0; left: 0; @@ -187,7 +187,7 @@ z-index: 1000; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif; } -.binding-modal[data-v-21112df8] { +.binding-modal[data-v-6ba48543] { background: white; border-radius: 12px; width: 90%; @@ -196,7 +196,7 @@ overflow: hidden; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); } -.binding-header[data-v-21112df8] { +.binding-header[data-v-6ba48543] { display: flex; justify-content: space-between; align-items: center; @@ -205,12 +205,12 @@ background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; } -.binding-header h3[data-v-21112df8] { +.binding-header h3[data-v-6ba48543] { margin: 0; font-size: 1.25rem; font-weight: 600; } -.close-btn[data-v-21112df8] { +.close-btn[data-v-6ba48543] { background: none; border: none; font-size: 1.5rem; @@ -224,39 +224,39 @@ border-radius: 50%; transition: all 0.2s; } -.close-btn[data-v-21112df8]:hover { +.close-btn[data-v-6ba48543]:hover { background: rgba(255, 255, 255, 0.1); color: white; } -.binding-content[data-v-21112df8] { +.binding-content[data-v-6ba48543] { padding: 2rem; max-height: 70vh; overflow-y: auto; } -.binding-info[data-v-21112df8] { +.binding-info[data-v-6ba48543] { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #e5e7eb; } -.binding-info h4[data-v-21112df8] { +.binding-info h4[data-v-6ba48543] { margin-bottom: 1rem; color: #111827; font-size: 1.125rem; font-weight: 600; } -.binding-info p[data-v-21112df8] { +.binding-info p[data-v-6ba48543] { margin: 0.5rem 0; color: #6b7280; font-size: 0.9rem; } -.method-tabs[data-v-21112df8] { +.method-tabs[data-v-6ba48543] { display: flex; gap: 0; margin-bottom: 1.5rem; border-bottom: 2px solid #e5e7eb; flex-wrap: wrap; } -.method-tab[data-v-21112df8] { +.method-tab[data-v-6ba48543] { padding: 0.75rem 1.25rem; background: none; border: none; @@ -269,47 +269,47 @@ transition: all 0.2s; white-space: nowrap; } -.method-tab[data-v-21112df8]:hover { +.method-tab[data-v-6ba48543]:hover { color: #374151; } -.method-tab.active[data-v-21112df8] { +.method-tab.active[data-v-6ba48543] { color: #3b82f6; border-bottom-color: #3b82f6; } -.instructions-section[data-v-21112df8] { +.instructions-section[data-v-6ba48543] { margin-bottom: 1rem; } -.instructions-text[data-v-21112df8] { +.instructions-text[data-v-6ba48543] { margin-bottom: 1.5rem; color: #6b7280; line-height: 1.6; } -.step-group[data-v-21112df8] { +.step-group[data-v-6ba48543] { margin-bottom: 2rem; } -.step-group h5[data-v-21112df8] { +.step-group h5[data-v-6ba48543] { margin-bottom: 0.5rem; color: #374151; font-size: 1rem; font-weight: 600; } -.step-description[data-v-21112df8] { +.step-description[data-v-6ba48543] { margin-bottom: 0.75rem; color: #6b7280; font-size: 0.875rem; } -.download-block[data-v-21112df8] { +.download-block[data-v-6ba48543] { background: #f0f9ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 1rem; margin-bottom: 0.75rem; } -.download-actions[data-v-21112df8] { +.download-actions[data-v-6ba48543] { display: flex; gap: 1rem; } -.download-btn[data-v-21112df8] { +.download-btn[data-v-6ba48543] { padding: 0.75rem 1.5rem; background: #6b7280; color: white; @@ -320,16 +320,16 @@ font-weight: 500; transition: background-color 0.2s; } -.download-btn[data-v-21112df8]:hover { +.download-btn[data-v-6ba48543]:hover { background: #4b5563; } -.download-btn.primary[data-v-21112df8] { +.download-btn.primary[data-v-6ba48543] { background: #3b82f6; } -.download-btn.primary[data-v-21112df8]:hover { +.download-btn.primary[data-v-6ba48543]:hover { background: #2563eb; } -.command-block[data-v-21112df8] { +.command-block[data-v-6ba48543] { display: flex; align-items: center; background: #f8fafc; @@ -338,7 +338,7 @@ padding: 1rem; gap: 1rem; } -.command-block code[data-v-21112df8] { +.command-block code[data-v-6ba48543] { flex: 1; font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace; font-size: 0.875rem; @@ -346,7 +346,7 @@ background: none; word-break: break-all; } -.copy-cmd-btn[data-v-21112df8] { +.copy-cmd-btn[data-v-6ba48543] { padding: 0.5rem 1rem; background: #3b82f6; color: white; @@ -358,12 +358,12 @@ transition: background-color 0.2s; flex-shrink: 0; } -.copy-cmd-btn[data-v-21112df8]:hover { +.copy-cmd-btn[data-v-6ba48543]:hover { background: #2563eb; } /* One-Click tab styles */ -.security-warning[data-v-21112df8] { +.security-warning[data-v-6ba48543] { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; @@ -373,23 +373,47 @@ font-size: 0.875rem; line-height: 1.5; } -.upload-block[data-v-21112df8] { +.upload-block[data-v-6ba48543] { background: #f9fafb; border: 2px dashed #d1d5db; border-radius: 8px; padding: 1.5rem; text-align: center; } -.file-input[data-v-21112df8] { +.file-input[data-v-6ba48543] { margin-bottom: 0.5rem; } -.file-info[data-v-21112df8] { +.file-info[data-v-6ba48543] { margin-top: 0.5rem; color: #059669; font-size: 0.875rem; font-weight: 500; } -.apply-btn[data-v-21112df8] { +.text-input[data-v-6ba48543] { + width: 100%; + padding: 0.5rem 0.75rem; + border: 1px solid #d1d5db; + border-radius: 6px; + font-size: 0.875rem; + font-family: 'SF Mono', Monaco, monospace; + box-sizing: border-box; +} +.text-input[data-v-6ba48543]:focus { + outline: none; + border-color: #3b82f6; + box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15); +} +.optional-label[data-v-6ba48543] { + font-weight: 400; + font-size: 0.8rem; + color: #9ca3af; +} +.step-hint[data-v-6ba48543] { + margin: 0.25rem 0 0; + font-size: 0.78rem; + color: #9ca3af; +} +.apply-btn[data-v-6ba48543] { padding: 0.875rem 2rem; background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; @@ -403,46 +427,46 @@ align-items: center; gap: 0.5rem; } -.apply-btn[data-v-21112df8]:hover:not(:disabled) { +.apply-btn[data-v-6ba48543]:hover:not(:disabled) { background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%); transform: translateY(-1px); } -.apply-btn[data-v-21112df8]:disabled { +.apply-btn[data-v-6ba48543]:disabled { opacity: 0.5; cursor: not-allowed; } -.spinner[data-v-21112df8] { +.spinner[data-v-6ba48543] { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: white; - animation: spin-21112df8 0.8s linear infinite; + animation: spin-6ba48543 0.8s linear infinite; } -@keyframes spin-21112df8 { +@keyframes spin-6ba48543 { to { transform: rotate(360deg); } } -.status-message[data-v-21112df8] { +.status-message[data-v-6ba48543] { padding: 1rem; border-radius: 8px; font-size: 0.9rem; margin-top: 1rem; } -.status-message.success[data-v-21112df8] { +.status-message.success[data-v-6ba48543] { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; } -.status-message.error[data-v-21112df8] { +.status-message.error[data-v-6ba48543] { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; } /* Already Connected tab styles */ -.status-check[data-v-21112df8] { +.status-check[data-v-6ba48543] { display: flex; align-items: center; gap: 0.75rem; @@ -450,11 +474,11 @@ to { transform: rotate(360deg); justify-content: center; color: #6b7280; } -.status-check .spinner[data-v-21112df8] { +.status-check .spinner[data-v-6ba48543] { border-color: rgba(59, 130, 246, 0.3); border-top-color: #3b82f6; } -.connected-badge[data-v-21112df8] { +.connected-badge[data-v-6ba48543] { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; @@ -464,7 +488,7 @@ to { transform: rotate(360deg); font-size: 1rem; margin-bottom: 1rem; } -.not-connected-badge[data-v-21112df8] { +.not-connected-badge[data-v-6ba48543] { background: #f0f9ff; border: 1px solid #bfdbfe; color: #1e40af; @@ -474,40 +498,40 @@ to { transform: rotate(360deg); font-size: 1rem; margin-bottom: 1rem; } -.exports-list[data-v-21112df8] { +.exports-list[data-v-6ba48543] { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; } -.exports-list h5[data-v-21112df8] { +.exports-list h5[data-v-6ba48543] { margin: 0 0 0.5rem 0; color: #374151; font-size: 0.9rem; } -.exports-list ul[data-v-21112df8] { +.exports-list ul[data-v-6ba48543] { margin: 0; padding-left: 1.5rem; } -.exports-list li[data-v-21112df8] { +.exports-list li[data-v-6ba48543] { color: #6b7280; font-size: 0.875rem; font-family: 'SF Mono', 'Monaco', monospace; padding: 0.25rem 0; } -.method-suggestions[data-v-21112df8] { +.method-suggestions[data-v-6ba48543] { padding-left: 1.5rem; color: #6b7280; line-height: 2; } -.binding-footer[data-v-21112df8] { +.binding-footer[data-v-6ba48543] { padding: 1.5rem 2rem; border-top: 1px solid #e5e7eb; background: #f9fafb; text-align: right; } -.ok-btn[data-v-21112df8] { +.ok-btn[data-v-6ba48543] { padding: 0.75rem 1.5rem; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; @@ -517,7 +541,7 @@ to { transform: rotate(360deg); font-weight: 600; transition: all 0.2s; } -.ok-btn[data-v-21112df8]:hover { +.ok-btn[data-v-6ba48543]:hover { background: linear-gradient(135deg, #059669 0%, #047857 100%); transform: translateY(-1px); } diff --git a/web/dist/assets/index.BBkPMOmG.js b/web/dist/assets/index.DE_Nx7OI.js similarity index 99% rename from web/dist/assets/index.BBkPMOmG.js rename to web/dist/assets/index.DE_Nx7OI.js index 8d39f3156..0223fd465 100644 --- a/web/dist/assets/index.BBkPMOmG.js +++ b/web/dist/assets/index.DE_Nx7OI.js @@ -9868,38 +9868,40 @@ var _hoisted_8$3 = { }; var _hoisted_9$3 = { class: "step-group" }; var _hoisted_10$3 = ["disabled"]; -var _hoisted_11$3 = { +var _hoisted_11$3 = { class: "step-group" }; +var _hoisted_12$3 = ["disabled"]; +var _hoisted_13$3 = { key: 0, class: "spinner" }; -var _hoisted_12$3 = { +var _hoisted_14$3 = { key: 0, class: "status-message success" }; -var _hoisted_13$3 = { +var _hoisted_15$3 = { key: 1, class: "status-message error" }; -var _hoisted_14$3 = { +var _hoisted_16$3 = { key: 1, class: "instructions-section" }; -var _hoisted_15$3 = { class: "step-group" }; -var _hoisted_16$3 = { class: "command-block" }; var _hoisted_17$3 = { class: "step-group" }; var _hoisted_18$2 = { class: "command-block" }; var _hoisted_19$2 = { class: "step-group" }; var _hoisted_20$2 = { class: "command-block" }; -var _hoisted_21$2 = { +var _hoisted_21$2 = { class: "step-group" }; +var _hoisted_22$2 = { class: "command-block" }; +var _hoisted_23$2 = { key: 2, class: "instructions-section" }; -var _hoisted_22$2 = { class: "step-group" }; -var _hoisted_23$2 = { class: "command-block" }; var _hoisted_24$2 = { class: "step-group" }; var _hoisted_25$2 = { class: "command-block" }; var _hoisted_26$2 = { class: "step-group" }; var _hoisted_27$2 = { class: "command-block" }; +var _hoisted_28$2 = { class: "step-group" }; +var _hoisted_29$2 = { class: "command-block" }; //#endregion //#region src/components/BindingResult.vue var BindingResult_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({ @@ -9919,6 +9921,7 @@ var BindingResult_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* const applyStatus = /* @__PURE__ */ ref("idle"); const applyMessage = /* @__PURE__ */ ref(""); const kubeconfigFileInput = /* @__PURE__ */ ref(null); + const hostAliasInput = /* @__PURE__ */ ref(""); const bindingName = computed(() => { return props.bindingResponse.bindingName || props.templateName; }); @@ -9957,7 +9960,8 @@ var BindingResult_default = /* @__PURE__ */ _plugin_vue_export_helper_default(/* headers: { "Content-Type": "application/json" }, body: JSON.stringify({ consumerKubeconfig: kubeconfigData.value, - bindingName: bindingName.value + bindingName: bindingName.value, + hostAliases: hostAliasInput.value.trim() ? [hostAliasInput.value.trim()] : void 0 }) }); if (!response.ok) { @@ -10082,7 +10086,7 @@ spec: onClick: closeModal }, [createBaseVNode("div", { class: "binding-modal", - onClick: _cache[9] || (_cache[9] = withModifiers(() => {}, ["stop"])) + onClick: _cache[10] || (_cache[10] = withModifiers(() => {}, ["stop"])) }, [ createBaseVNode("div", _hoisted_1$4, [createBaseVNode("h3", null, "Setup Binding: " + toDisplayString(__props.templateName), 1), createBaseVNode("button", { onClick: closeModal, @@ -10104,16 +10108,16 @@ spec: }, " Manual (CLI) ", 2) ]), activeMethod.value === "oneclick" ? (openBlock(), createElementBlock("div", _hoisted_4$4, [ - _cache[12] || (_cache[12] = createBaseVNode("p", { class: "instructions-text" }, " Upload your consumer cluster kubeconfig and we'll automatically deploy the konnector agent and configure the binding bundle for you. No CLI required. ", -1)), - _cache[13] || (_cache[13] = createBaseVNode("div", { class: "security-warning" }, [ + _cache[16] || (_cache[16] = createBaseVNode("p", { class: "instructions-text" }, " Upload your consumer cluster kubeconfig and we'll automatically deploy the konnector agent and configure the binding bundle for you. No CLI required. ", -1)), + _cache[17] || (_cache[17] = createBaseVNode("div", { class: "security-warning" }, [ createBaseVNode("strong", null, "⚠️ Security Note:"), createTextVNode(" Your kubeconfig will be used transiently to apply resources to your consumer cluster and will "), createBaseVNode("strong", null, "not"), createTextVNode(" be stored. The provider backend needs cluster-admin level access to deploy the konnector and create binding resources. ") ], -1)), createBaseVNode("div", _hoisted_5$4, [ - _cache[10] || (_cache[10] = createBaseVNode("h5", null, "Upload Consumer Kubeconfig", -1)), - _cache[11] || (_cache[11] = createBaseVNode("p", { class: "step-description" }, "Select the kubeconfig file for your consumer cluster.", -1)), + _cache[11] || (_cache[11] = createBaseVNode("h5", null, "Upload Consumer Kubeconfig", -1)), + _cache[12] || (_cache[12] = createBaseVNode("p", { class: "step-description" }, "Select the kubeconfig file for your consumer cluster.", -1)), createBaseVNode("div", _hoisted_6$4, [createBaseVNode("input", { type: "file", ref_key: "kubeconfigFileInput", @@ -10124,64 +10128,76 @@ spec: disabled: applyStatus.value === "loading" }, null, 40, _hoisted_7$4), kubeconfigFileName.value ? (openBlock(), createElementBlock("div", _hoisted_8$3, " 📄 " + toDisplayString(kubeconfigFileName.value), 1)) : createCommentVNode("", true)]) ]), - createBaseVNode("div", _hoisted_9$3, [createBaseVNode("button", { + createBaseVNode("div", _hoisted_9$3, [ + _cache[13] || (_cache[13] = createBaseVNode("h5", null, [createTextVNode("Host Aliases "), createBaseVNode("span", { class: "optional-label" }, "(optional)")], -1)), + _cache[14] || (_cache[14] = createBaseVNode("p", { class: "step-description" }, " Add host alias entries for the konnector pods if the provider hostname doesn't resolve correctly from the consumer cluster (e.g., in Kind/Docker environments). ", -1)), + withDirectives(createBaseVNode("input", { + "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => hostAliasInput.value = $event), + type: "text", + class: "text-input", + placeholder: "e.g. 172.19.0.2:kube-bind.dev.local", + disabled: applyStatus.value === "loading" + }, null, 8, _hoisted_10$3), [[vModelText, hostAliasInput.value]]), + _cache[15] || (_cache[15] = createBaseVNode("p", { class: "step-hint" }, "Format: IP:hostname1,hostname2", -1)) + ]), + createBaseVNode("div", _hoisted_11$3, [createBaseVNode("button", { onClick: applyToConsumer, class: "apply-btn", disabled: !kubeconfigData.value || applyStatus.value === "loading" - }, [applyStatus.value === "loading" ? (openBlock(), createElementBlock("span", _hoisted_11$3)) : createCommentVNode("", true), createTextVNode(" " + toDisplayString(applyStatus.value === "loading" ? "Applying..." : "Apply to Consumer Cluster"), 1)], 8, _hoisted_10$3)]), - applyStatus.value === "success" ? (openBlock(), createElementBlock("div", _hoisted_12$3, " ✅ " + toDisplayString(applyMessage.value), 1)) : createCommentVNode("", true), - applyStatus.value === "error" ? (openBlock(), createElementBlock("div", _hoisted_13$3, " ❌ " + toDisplayString(applyMessage.value), 1)) : createCommentVNode("", true) + }, [applyStatus.value === "loading" ? (openBlock(), createElementBlock("span", _hoisted_13$3)) : createCommentVNode("", true), createTextVNode(" " + toDisplayString(applyStatus.value === "loading" ? "Applying..." : "Apply to Consumer Cluster"), 1)], 8, _hoisted_12$3)]), + applyStatus.value === "success" ? (openBlock(), createElementBlock("div", _hoisted_14$3, " ✅ " + toDisplayString(applyMessage.value), 1)) : createCommentVNode("", true), + applyStatus.value === "error" ? (openBlock(), createElementBlock("div", _hoisted_15$3, " ❌ " + toDisplayString(applyMessage.value), 1)) : createCommentVNode("", true) ])) : createCommentVNode("", true), - activeMethod.value === "bundle" ? (openBlock(), createElementBlock("div", _hoisted_14$3, [ - _cache[22] || (_cache[22] = createBaseVNode("p", { class: "instructions-text" }, " Download and apply these files to your consumer cluster. The APIServiceBindingBundle will automatically discover and bind services from the provider. ", -1)), - createBaseVNode("div", _hoisted_15$3, [ - _cache[15] || (_cache[15] = createBaseVNode("h5", null, "1. Deploy the konnector agent (one-time)", -1)), - _cache[16] || (_cache[16] = createBaseVNode("p", { class: "step-description" }, "Skip this step if the konnector is already deployed on your consumer cluster.", -1)), + activeMethod.value === "bundle" ? (openBlock(), createElementBlock("div", _hoisted_16$3, [ + _cache[26] || (_cache[26] = createBaseVNode("p", { class: "instructions-text" }, " Download and apply these files to your consumer cluster. The APIServiceBindingBundle will automatically discover and bind services from the provider. ", -1)), + createBaseVNode("div", _hoisted_17$3, [ + _cache[19] || (_cache[19] = createBaseVNode("h5", null, "1. Deploy the konnector agent (one-time)", -1)), + _cache[20] || (_cache[20] = createBaseVNode("p", { class: "step-description" }, "Skip this step if the konnector is already deployed on your consumer cluster.", -1)), createBaseVNode("div", { class: "download-block" }, [createBaseVNode("div", { class: "download-actions" }, [createBaseVNode("button", { onClick: downloadKonnectorManifests, class: "download-btn primary" }, "Download konnector.yaml")])]), - createBaseVNode("div", _hoisted_16$3, [_cache[14] || (_cache[14] = createBaseVNode("code", null, "kubectl apply -f konnector.yaml", -1)), createBaseVNode("button", { - onClick: _cache[3] || (_cache[3] = ($event) => copyCommand("kubectl apply -f konnector.yaml")), + createBaseVNode("div", _hoisted_18$2, [_cache[18] || (_cache[18] = createBaseVNode("code", null, "kubectl apply -f konnector.yaml", -1)), createBaseVNode("button", { + onClick: _cache[4] || (_cache[4] = ($event) => copyCommand("kubectl apply -f konnector.yaml")), class: "copy-cmd-btn" }, "Copy")]) ]), - createBaseVNode("div", _hoisted_17$3, [ - _cache[18] || (_cache[18] = createBaseVNode("h5", null, "2. Apply the binding bundle", -1)), - _cache[19] || (_cache[19] = createBaseVNode("p", { class: "step-description" }, "Creates the kubeconfig secret and an APIServiceBindingBundle that auto-discovers and binds all services.", -1)), + createBaseVNode("div", _hoisted_19$2, [ + _cache[22] || (_cache[22] = createBaseVNode("h5", null, "2. Apply the binding bundle", -1)), + _cache[23] || (_cache[23] = createBaseVNode("p", { class: "step-description" }, "Creates the kubeconfig secret and an APIServiceBindingBundle that auto-discovers and binds all services.", -1)), createBaseVNode("div", { class: "download-block" }, [createBaseVNode("div", { class: "download-actions" }, [createBaseVNode("button", { onClick: downloadBindingBundle, class: "download-btn primary" }, "Download binding-bundle.yaml")])]), - createBaseVNode("div", _hoisted_18$2, [_cache[17] || (_cache[17] = createBaseVNode("code", null, "kubectl apply -f binding-bundle.yaml", -1)), createBaseVNode("button", { - onClick: _cache[4] || (_cache[4] = ($event) => copyCommand("kubectl apply -f binding-bundle.yaml")), + createBaseVNode("div", _hoisted_20$2, [_cache[21] || (_cache[21] = createBaseVNode("code", null, "kubectl apply -f binding-bundle.yaml", -1)), createBaseVNode("button", { + onClick: _cache[5] || (_cache[5] = ($event) => copyCommand("kubectl apply -f binding-bundle.yaml")), class: "copy-cmd-btn" }, "Copy")]) ]), - createBaseVNode("div", _hoisted_19$2, [_cache[21] || (_cache[21] = createBaseVNode("h5", null, "3. Verify", -1)), createBaseVNode("div", _hoisted_20$2, [_cache[20] || (_cache[20] = createBaseVNode("code", null, "kubectl get apiservicebindingbundles,apiservicebindings", -1)), createBaseVNode("button", { - onClick: _cache[5] || (_cache[5] = ($event) => copyCommand("kubectl get apiservicebindingbundles,apiservicebindings")), + createBaseVNode("div", _hoisted_21$2, [_cache[25] || (_cache[25] = createBaseVNode("h5", null, "3. Verify", -1)), createBaseVNode("div", _hoisted_22$2, [_cache[24] || (_cache[24] = createBaseVNode("code", null, "kubectl get apiservicebindingbundles,apiservicebindings", -1)), createBaseVNode("button", { + onClick: _cache[6] || (_cache[6] = ($event) => copyCommand("kubectl get apiservicebindingbundles,apiservicebindings")), class: "copy-cmd-btn" }, "Copy")])]) ])) : createCommentVNode("", true), - activeMethod.value === "manual" ? (openBlock(), createElementBlock("div", _hoisted_21$2, [ - _cache[28] || (_cache[28] = createBaseVNode("p", { class: "instructions-text" }, " Download the required files and run the following commands on your consumer cluster. ", -1)), - createBaseVNode("div", { class: "step-group" }, [_cache[23] || (_cache[23] = createBaseVNode("h5", null, "1. Download required files", -1)), createBaseVNode("div", { class: "download-block" }, [createBaseVNode("div", { class: "download-actions" }, [createBaseVNode("button", { + activeMethod.value === "manual" ? (openBlock(), createElementBlock("div", _hoisted_23$2, [ + _cache[32] || (_cache[32] = createBaseVNode("p", { class: "instructions-text" }, " Download the required files and run the following commands on your consumer cluster. ", -1)), + createBaseVNode("div", { class: "step-group" }, [_cache[27] || (_cache[27] = createBaseVNode("h5", null, "1. Download required files", -1)), createBaseVNode("div", { class: "download-block" }, [createBaseVNode("div", { class: "download-actions" }, [createBaseVNode("button", { onClick: downloadKubeconfig, class: "download-btn primary" }, "Download kubeconfig.yaml"), createBaseVNode("button", { onClick: downloadAPIRequests, class: "download-btn primary" }, "Download apiservice-export.yaml")])])]), - createBaseVNode("div", _hoisted_22$2, [_cache[25] || (_cache[25] = createBaseVNode("h5", null, "2. Create kube-bind namespace", -1)), createBaseVNode("div", _hoisted_23$2, [_cache[24] || (_cache[24] = createBaseVNode("code", null, "kubectl create namespace kube-bind --dry-run=client -o yaml | kubectl apply -f -", -1)), createBaseVNode("button", { - onClick: _cache[6] || (_cache[6] = ($event) => copyCommand("kubectl create namespace kube-bind --dry-run=client -o yaml | kubectl apply -f -")), + createBaseVNode("div", _hoisted_24$2, [_cache[29] || (_cache[29] = createBaseVNode("h5", null, "2. Create kube-bind namespace", -1)), createBaseVNode("div", _hoisted_25$2, [_cache[28] || (_cache[28] = createBaseVNode("code", null, "kubectl create namespace kube-bind --dry-run=client -o yaml | kubectl apply -f -", -1)), createBaseVNode("button", { + onClick: _cache[7] || (_cache[7] = ($event) => copyCommand("kubectl create namespace kube-bind --dry-run=client -o yaml | kubectl apply -f -")), class: "copy-cmd-btn" }, "Copy")])]), - createBaseVNode("div", _hoisted_24$2, [_cache[26] || (_cache[26] = createBaseVNode("h5", null, "3. Create kubeconfig secret", -1)), createBaseVNode("div", _hoisted_25$2, [createBaseVNode("code", null, toDisplayString(createSecretCommand.value), 1), createBaseVNode("button", { - onClick: _cache[7] || (_cache[7] = ($event) => copyCommand(createSecretCommand.value)), + createBaseVNode("div", _hoisted_26$2, [_cache[30] || (_cache[30] = createBaseVNode("h5", null, "3. Create kubeconfig secret", -1)), createBaseVNode("div", _hoisted_27$2, [createBaseVNode("code", null, toDisplayString(createSecretCommand.value), 1), createBaseVNode("button", { + onClick: _cache[8] || (_cache[8] = ($event) => copyCommand(createSecretCommand.value)), class: "copy-cmd-btn" }, "Copy")])]), - createBaseVNode("div", _hoisted_26$2, [_cache[27] || (_cache[27] = createBaseVNode("h5", null, "4. Bind the API service", -1)), createBaseVNode("div", _hoisted_27$2, [createBaseVNode("code", null, toDisplayString(bindCommand.value), 1), createBaseVNode("button", { - onClick: _cache[8] || (_cache[8] = ($event) => copyCommand(bindCommand.value)), + createBaseVNode("div", _hoisted_28$2, [_cache[31] || (_cache[31] = createBaseVNode("h5", null, "4. Bind the API service", -1)), createBaseVNode("div", _hoisted_29$2, [createBaseVNode("code", null, toDisplayString(bindCommand.value), 1), createBaseVNode("button", { + onClick: _cache[9] || (_cache[9] = ($event) => copyCommand(bindCommand.value)), class: "copy-cmd-btn" }, "Copy")])]) ])) : createCommentVNode("", true) @@ -10193,7 +10209,7 @@ spec: ])])) : createCommentVNode("", true); }; } -}), [["__scopeId", "data-v-21112df8"]]); +}), [["__scopeId", "data-v-6ba48543"]]); //#endregion //#region src/components/TemplateBindingModal.vue?vue&type=script&setup=true&lang.ts var _hoisted_1$3 = { class: "modal-header" }; diff --git a/web/dist/index.html b/web/dist/index.html index 41d246b70..05648f660 100644 --- a/web/dist/index.html +++ b/web/dist/index.html @@ -5,8 +5,8 @@ Kube Bind - - + +
diff --git a/web/src/components/BindingResult.vue b/web/src/components/BindingResult.vue index c325c69d4..94df5c8be 100644 --- a/web/src/components/BindingResult.vue +++ b/web/src/components/BindingResult.vue @@ -60,6 +60,22 @@ +
+
Host Aliases (optional)
+

+ Add host alias entries for the konnector pods if the provider hostname + doesn't resolve correctly from the consumer cluster (e.g., in Kind/Docker environments). +

+ +

Format: IP:hostname1,hostname2

+
+