@@ -110,7 +110,11 @@ func (client *client) updateVMConfig(startConfig types.StartConfig, vm *virtualM
110
110
return nil
111
111
}
112
112
113
- func growRootFileSystem (sshRunner * crcssh.Runner ) error {
113
+ func growRootFileSystem (sshRunner * crcssh.Runner , preset crcPreset.Preset ) error {
114
+ if preset == crcPreset .Microshift {
115
+ logging .Debugf ("growRootFileSystem does not support LVM which is used by %s images" , preset )
116
+ return nil
117
+ }
114
118
// With 4.7, this is quite a manual process until https://github.com/openshift/installer/pull/4746 gets fixed
115
119
// See https://github.com/crc-org/crc/issues/2104 for details
116
120
rootPart , _ , err := sshRunner .Run ("realpath" , "/dev/disk/by-label/root" )
@@ -370,7 +374,7 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
370
374
}
371
375
372
376
// Trigger disk resize, this will be a no-op if no disk size change is needed
373
- if err := growRootFileSystem (sshRunner ); err != nil {
377
+ if err := growRootFileSystem (sshRunner , startConfig . Preset ); err != nil {
374
378
return nil , errors .Wrap (err , "Error updating filesystem size" )
375
379
}
376
380
@@ -408,7 +412,7 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
408
412
return nil , errors .Wrap (err , "Error getting proxy configuration" )
409
413
}
410
414
411
- if ! vm .bundle .IsOpenShift () {
415
+ if vm .bundle .IsPodman () {
412
416
// **************************
413
417
// END OF PODMAN START CODE
414
418
// **************************
@@ -476,6 +480,31 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
476
480
logging .Warn (fmt .Sprintf ("Failed to query DNS from host: %v" , err ))
477
481
}
478
482
483
+ if vm .bundle .IsMicroshift () {
484
+ // **************************
485
+ // END OF MICROSHIFT START CODE
486
+ // **************************
487
+ // Start the microshift and copy the generated kubeconfig file
488
+ ocConfig := oc .UseOCWithSSH (sshRunner )
489
+ ocConfig .Context = "microshift"
490
+ ocConfig .Cluster = "microshift"
491
+
492
+ if err := startMicroshift (ctx , sshRunner , ocConfig , startConfig .PullSecret ); err != nil {
493
+ return nil , err
494
+ }
495
+
496
+ if client .useVSock () {
497
+ if err := ensureRoutesControllerIsRunning (sshRunner , ocConfig , startConfig .Preset , vm .bundle ); err != nil {
498
+ return nil , err
499
+ }
500
+ }
501
+
502
+ return & types.StartResult {
503
+ ClusterConfig : types.ClusterConfig {ClusterType : startConfig .Preset },
504
+ Status : vmState ,
505
+ }, nil
506
+ }
507
+
479
508
// Check the certs validity inside the vm
480
509
logging .Info ("Verifying validity of the kubelet certificates..." )
481
510
certsExpired , err := cluster .CheckCertsValidity (sshRunner )
@@ -882,11 +911,8 @@ func updateKubeconfig(ctx context.Context, ocConfig oc.Config, sshRunner *crcssh
882
911
}
883
912
884
913
func bundleMismatchWithPreset (preset crcPreset.Preset , bundleMetadata * bundle.CrcBundleInfo ) error {
885
- if preset == crcPreset .Podman && bundleMetadata .IsOpenShift () {
886
- return errors .Errorf ("Preset %s is used but bundle is provided for %s preset" , crcPreset .Podman , crcPreset .OpenShift )
887
- }
888
- if preset != crcPreset .Podman && ! bundleMetadata .IsOpenShift () {
889
- return errors .Errorf ("Preset %s is used but bundle is provided for %s preset" , crcPreset .OpenShift , crcPreset .Podman )
914
+ if preset != bundleMetadata .GetBundleType () {
915
+ return errors .Errorf ("Preset %s is used but bundle is provided for %s preset" , preset , bundleMetadata .GetBundleType ())
890
916
}
891
917
return nil
892
918
}
@@ -922,3 +948,32 @@ func addPodmanSystemConnections(c *types.ConnectionDetails) error {
922
948
}
923
949
return nil
924
950
}
951
+
952
+ func startMicroshift (ctx context.Context , sshRunner * crcssh.Runner , ocConfig oc.Config , pullSec cluster.PullSecretLoader ) error {
953
+ logging .Infof ("Starting Microshift service... [takes around 1min]" )
954
+ content , err := pullSec .Value ()
955
+ if err != nil {
956
+ return err
957
+ }
958
+ if err := sshRunner .CopyDataPrivileged ([]byte (content ), "/etc/crio/openshift-pull-secret" , 0600 ); err != nil {
959
+ return err
960
+ }
961
+ if _ , _ , err := sshRunner .RunPrivileged ("Starting microshift service" , "systemctl" , "start" , "microshift" ); err != nil {
962
+ return err
963
+ }
964
+ if err := sshRunner .CopyFileFromVM ("/var/lib/microshift/resources/kubeadmin/kubeconfig" , constants .KubeconfigFilePath , 0600 ); err != nil {
965
+ return err
966
+ }
967
+ if err := sshRunner .CopyFile (constants .KubeconfigFilePath , "/opt/kubeconfig" , 0644 ); err != nil {
968
+ return err
969
+ }
970
+ if err := updateServerDetailsToKubeConfig (constants .KubeconfigFilePath , constants .KubeconfigFilePath ); err != nil {
971
+ return err
972
+ }
973
+
974
+ if err := cluster .WaitForAPIServer (ctx , ocConfig ); err != nil {
975
+ return err
976
+ }
977
+
978
+ return nil
979
+ }
0 commit comments