@@ -171,11 +171,14 @@ echo "ssh -i <your-private-key> ubuntu@${INSTANCE_ENDPOINT_HOST}"
171171
172172const microk8sTemplate = `
173173: ${INSTANCE_ENDPOINT_HOST:={{.K8sEndpointHost}}}
174+ : ${K8S_VERSION:={{.Version}}}
175+
176+ # Remove leading 'v' from version if present for microk8s snap channel
177+ MICROK8S_VERSION="${K8S_VERSION#v}"
174178
175179# Install microk8s
176180sudo apt-get update
177-
178- sudo snap install microk8s --classic --channel={{.Version}}
181+ sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}
179182sudo microk8s enable gpu dashboard dns registry
180183sudo usermod -a -G microk8s ubuntu
181184mkdir -p ~/.kube
@@ -184,7 +187,7 @@ sudo microk8s config > ~/.kube/config
184187sudo chown -f -R ubuntu ~/.kube
185188sudo snap alias microk8s.kubectl kubectl
186189
187- echo "Microk8s {{.Version} } installed successfully"
190+ echo "Microk8s ${MICROK8S_VERSION } installed successfully"
188191echo "you can now access the cluster with:"
189192echo "ssh -i <your-private-key> ubuntu@${INSTANCE_ENDPOINT_HOST}"
190193`
@@ -274,11 +277,11 @@ type KubeadmConfig struct {
274277func NewKubernetes (env v1alpha1.Environment ) (* Kubernetes , error ) {
275278 kubernetes := & Kubernetes {}
276279
277- // Normalize Kubernetes version using a switch statement
280+ // Normalize Kubernetes version: always ensure it starts with 'v'
278281 switch {
279282 case env .Spec .Kubernetes .KubernetesVersion == "" :
280283 kubernetes .Version = defaultKubernetesVersion
281- case ! strings .HasPrefix (env .Spec .Kubernetes .KubernetesVersion , "v" ) && env . Spec . Kubernetes . KubernetesInstaller != "microk8s" :
284+ case ! strings .HasPrefix (env .Spec .Kubernetes .KubernetesVersion , "v" ):
282285 kubernetes .Version = "v" + env .Spec .Kubernetes .KubernetesVersion
283286 default :
284287 kubernetes .Version = env .Spec .Kubernetes .KubernetesVersion
0 commit comments