@@ -61,12 +61,13 @@ type DevOptions struct {
6161 AgentClusterName string
6262 WaitForReadyTimeout time.Duration
6363 ChartPath string
64+ AgentChartPath string
6465 ChartVersion string
6566 KindNetwork string
6667}
6768
6869// fallbackAssetVersion is used when unable to fetch the latest version
69- const fallbackAssetVersion = "0.1.0 "
70+ const fallbackAssetVersion = "0.0.1 "
7071
7172// gitHubRelease represents a GitHub release response
7273type gitHubRelease struct {
@@ -80,6 +81,7 @@ func NewDevOptions(streams genericclioptions.IOStreams) *DevOptions {
8081 HubClusterName : "kedge-hub" ,
8182 AgentClusterName : "kedge-agent" ,
8283 ChartPath : "deploy/charts/kedge-hub" ,
84+ AgentChartPath : "oci://ghcr.io/faroshq/charts/kedge-agent" ,
8385 ChartVersion : fallbackAssetVersion ,
8486 }
8587}
@@ -89,7 +91,8 @@ func (o *DevOptions) AddCmdFlags(cmd *cobra.Command) {
8991 cmd .Flags ().StringVar (& o .HubClusterName , "hub-cluster-name" , "kedge-hub" , "Name of the hub cluster in dev mode" )
9092 cmd .Flags ().StringVar (& o .AgentClusterName , "agent-cluster-name" , "kedge-agent" , "Name of the agent cluster in dev mode" )
9193 cmd .Flags ().DurationVar (& o .WaitForReadyTimeout , "wait-for-ready-timeout" , 2 * time .Minute , "Timeout for waiting for the cluster to be ready" )
92- cmd .Flags ().StringVar (& o .ChartPath , "chart-path" , o .ChartPath , "Helm chart path or OCI registry URL" )
94+ cmd .Flags ().StringVar (& o .ChartPath , "chart-path" , o .ChartPath , "Helm chart path or OCI registry URL for hub" )
95+ cmd .Flags ().StringVar (& o .AgentChartPath , "agent-chart-path" , o .AgentChartPath , "Helm chart path or OCI registry URL for agent" )
9396 cmd .Flags ().StringVar (& o .ChartVersion , "chart-version" , o .ChartVersion , "Helm chart version" )
9497 cmd .Flags ().StringVar (& o .Image , "image" , "ghcr.io/faroshq/kedge-hub" , "kedge hub image to use in dev mode" )
9598 cmd .Flags ().StringVar (& o .Tag , "tag" , "" , "kedge hub image tag to use in dev mode" )
@@ -127,7 +130,7 @@ func fetchLatestRelease() (string, error) {
127130 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
128131 defer cancel ()
129132
130- req , err := http .NewRequestWithContext (ctx , http .MethodGet , "https://api.github.com/repos/faroshq/faros- kedge/releases/latest" , nil )
133+ req , err := http .NewRequestWithContext (ctx , http .MethodGet , "https://api.github.com/repos/faroshq/kedge/releases/latest" , nil )
131134 if err != nil {
132135 return "" , fmt .Errorf ("failed to create request: %w" , err )
133136 }
@@ -185,9 +188,6 @@ nodes:
185188
186189var agentClusterConfig = `apiVersion: kind.x-k8s.io/v1alpha4
187190kind: Cluster
188- networking:
189- apiServerAddress: "0.0.0.0"
190- apiServerPort: 6443
191191nodes:
192192- role: control-plane
193193`
@@ -279,13 +279,20 @@ func (o *DevOptions) runWithColors(ctx context.Context) error {
279279 o .AgentClusterName , o .AgentClusterName )))
280280
281281 _ , _ = fmt .Fprint (o .Streams .ErrOut , " Then install the agent Helm chart:\n " )
282- _ , _ = fmt .Fprintf (o .Streams .ErrOut , "%s\n \n " , blueCommand (fmt .Sprintf (
283- "helm install kedge-agent deploy/charts/kedge-agent \\ \n --kubeconfig %s.kubeconfig \\ \n -n kedge-system \\ \n --set agent.siteName=my-site \\ \n --set agent.hub.existingSecret=site-kubeconfig" ,
284- o .AgentClusterName )))
285-
286282 if hubIP != "" {
287- _ , _ = fmt .Fprint (o .Streams .ErrOut , " Note: The agent connects to the hub via the Docker network.\n " )
288- _ , _ = fmt .Fprintf (o .Streams .ErrOut , " Hub is reachable at: https://%s:8443 from within the kind network.\n \n " , hubIP )
283+ // Use hub.url to override the kubeconfig server URL with the correct NodePort address
284+ // The kubeconfig has kedge.localhost:8443 which works from host, but from within
285+ // the Docker network we need to use the hub's IP and NodePort 31443
286+ _ , _ = fmt .Fprintf (o .Streams .ErrOut , "%s\n \n " , blueCommand (fmt .Sprintf (
287+ "helm install kedge-agent %s --version %s \\ \n --kubeconfig %s.kubeconfig \\ \n -n kedge-system \\ \n --set agent.siteName=my-site \\ \n --set agent.hub.existingSecret=site-kubeconfig \\ \n --set agent.hub.url=https://%s:31443" ,
288+ o .AgentChartPath , o .ChartVersion , o .AgentClusterName , hubIP )))
289+ } else {
290+ _ , _ = fmt .Fprintf (o .Streams .ErrOut , "%s\n \n " , blueCommand (fmt .Sprintf (
291+ "helm install kedge-agent %s --version %s \\ \n --kubeconfig %s.kubeconfig \\ \n -n kedge-system \\ \n --set agent.siteName=my-site \\ \n --set agent.hub.existingSecret=site-kubeconfig" ,
292+ o .AgentChartPath , o .ChartVersion , o .AgentClusterName )))
293+ _ , _ = fmt .Fprint (o .Streams .ErrOut , " Note: You may need to set agent.hub.url to the hub's Docker network IP and NodePort.\n " )
294+ _ , _ = fmt .Fprint (o .Streams .ErrOut , " Get hub IP: docker inspect kedge-hub-control-plane | jq -r '.[0].NetworkSettings.Networks[\" kedge-dev\" ].IPAddress'\n " )
295+ _ , _ = fmt .Fprint (o .Streams .ErrOut , " Then add: --set agent.hub.url=https://<HUB_IP>:31443\n \n " )
289296 }
290297
291298 _ , _ = fmt .Fprint (o .Streams .ErrOut , "Useful commands:\n " )
0 commit comments