Skip to content

Commit

Permalink
include the airgap registry cluster IP in the node join response
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Apr 17, 2024
1 parent ea2056e commit 33a17b1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/handlers/embedded_cluster_node_join_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/replicatedhq/kots/pkg/logger"
"github.com/replicatedhq/kots/pkg/store"
"github.com/replicatedhq/kots/pkg/util"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type GenerateEmbeddedClusterNodeJoinCommandResponse struct {
Expand All @@ -24,6 +25,8 @@ type GetEmbeddedClusterNodeJoinCommandResponse struct {
EndUserK0sConfigOverrides string `json:"endUserK0sConfigOverrides"`
MetricsBaseURL string `json:"metricsBaseURL"`
EmbeddedClusterVersion string `json:"embeddedClusterVersion"`
AirgapRegistryAddress string `json:"airgapRegistryAddress"`
IsAirgap bool `json:"isAirgap"`
}

type GenerateEmbeddedClusterNodeJoinCommandRequest struct {
Expand Down Expand Up @@ -163,6 +166,17 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
ecVersion = install.Spec.Config.Version
}

airgapRegistryAddress := ""
if install.Spec.AirGap {
airgapRegistrySvc, err := client.CoreV1().Services("registry").Get(r.Context(), "registry", metav1.GetOptions{})
if err != nil {
logger.Error(fmt.Errorf("failed to get airgap registry service: %w", err))
w.WriteHeader(http.StatusInternalServerError)
return
}
airgapRegistryAddress = fmt.Sprintf("%s:5000", airgapRegistrySvc.Spec.ClusterIP)
}

JSON(w, http.StatusOK, GetEmbeddedClusterNodeJoinCommandResponse{
ClusterID: clusterID,
K0sJoinCommand: k0sJoinCommand,
Expand All @@ -171,5 +185,7 @@ func (h *Handler) GetEmbeddedClusterNodeJoinCommand(w http.ResponseWriter, r *ht
EndUserK0sConfigOverrides: endUserK0sConfigOverrides,
MetricsBaseURL: install.Spec.MetricsBaseURL,
EmbeddedClusterVersion: ecVersion,
AirgapRegistryAddress: airgapRegistryAddress,
IsAirgap: install.Spec.AirGap,
})
}

0 comments on commit 33a17b1

Please sign in to comment.