From fc181fab4e10101d1d0776036dbbe0b8eea21231 Mon Sep 17 00:00:00 2001 From: jianli-97 Date: Tue, 4 Jun 2024 10:51:08 +0800 Subject: [PATCH] Modify template for kickstart --- cmd/deploy.go | 8 --- cmd/extend.go | 15 ++--- data/assets_vfsdata.go | 64 ++++++++++++++++--- .../controlplane}/kickstart.cfg.template | 2 +- .../kickstart/master/kickstart.cfg.template | 51 +++++++++++++++ .../kickstart/worker/kickstart.cfg.template | 57 +++++++++++++++++ .../bootconfig/kickstart/template.go | 9 ++- 7 files changed, 176 insertions(+), 30 deletions(-) rename data/data/{bootconfig => kickstart/controlplane}/kickstart.cfg.template (96%) create mode 100644 data/data/kickstart/master/kickstart.cfg.template create mode 100644 data/data/kickstart/worker/kickstart.cfg.template diff --git a/cmd/deploy.go b/cmd/deploy.go index 78e37fa..9233c6b 100755 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -122,14 +122,6 @@ func deployCluster(conf *asset.ClusterAsset) error { hs := httpserver.NewHTTPService(configmanager.GetBootstrapIgnPort()) defer hs.Stop() - if strings.ToLower(conf.Platform) == "pxe" || strings.ToLower(conf.Platform) == "ipxe" { - if err := createCluster(conf, hs); err != nil { - logrus.Errorf("Failed to create cluster: %v", err) - return err - } - return nil - } - if err := createCluster(conf, hs); err != nil { logrus.Errorf("Failed to create cluster: %v", err) return err diff --git a/cmd/extend.go b/cmd/extend.go index 2bf7938..cd58626 100755 --- a/cmd/extend.go +++ b/cmd/extend.go @@ -80,18 +80,13 @@ func runExtendCmd(cmd *cobra.Command, args []string) error { httpService := httpserver.NewHTTPService(configmanager.GetBootstrapIgnPort()) defer httpService.Stop() - if strings.ToLower(clusterConfig.Platform) == "pxe" || strings.ToLower(clusterConfig.Platform) == "ipxe" { - if err := extendCluster(clusterConfig, httpService); err != nil { - logrus.Errorf("Failed to extend %s cluster: %v", clusterID, err) - return err - } - return nil - } - num, err := cmd.Flags().GetUint("num") if err != nil { - logrus.Errorf("Failed to get the number of extended nodes: %v", err) - return err + platform := strings.ToLower(clusterConfig.Platform) + if platform != "pxe" && platform != "ipxe" { + logrus.Errorf("Failed to get the number of extended nodes: %v", err) + return err + } } newHostnames := extendArray(clusterConfig, int(num)) diff --git a/data/assets_vfsdata.go b/data/assets_vfsdata.go index 1c11c50..4f9f0fe 100644 --- a/data/assets_vfsdata.go +++ b/data/assets_vfsdata.go @@ -20,11 +20,11 @@ var Assets = func() http.FileSystem { fs := vfsgen۰FS{ "/": &vfsgen۰DirInfo{ name: "/", - modTime: time.Date(2024, 6, 4, 2, 2, 56, 452395590, time.UTC), + modTime: time.Date(2024, 6, 4, 2, 24, 1, 306008181, time.UTC), }, "/bootconfig": &vfsgen۰DirInfo{ name: "bootconfig", - modTime: time.Date(2024, 6, 4, 2, 3, 2, 321472207, time.UTC), + modTime: time.Date(2024, 6, 4, 2, 24, 15, 308193053, time.UTC), }, "/bootconfig/files": &vfsgen۰DirInfo{ name: "files", @@ -109,13 +109,6 @@ var Assets = func() http.FileSystem { compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x7c\x53\xd1\x4e\xdb\x50\x0c\x7d\xef\x57\x58\x01\x89\x87\x91\x54\xbc\x4e\xca\x43\xb7\x15\x34\xb1\x01\x2a\xa0\x4d\x9a\x26\xe4\x24\x4e\x6a\xb8\xbd\x2e\xbe\x4e\xa0\x42\xfc\xfb\x74\x13\x5a\x8a\x56\x78\x8a\xe3\xf8\x9e\x73\xae\xcf\xc9\x1e\x9c\x89\xd1\x67\xb8\x9a\x73\x80\x4a\x65\xc9\x1e\xc4\xbb\x15\x3c\x88\xde\x05\x78\x60\x9b\xc3\x5d\x5b\x10\x56\x0b\x40\x5f\xf5\xb5\x23\x83\xee\x28\x3b\x3a\xfa\x34\xfa\x73\x49\xda\x71\x49\x7f\x47\x53\xdf\xb1\x8a\x5f\x90\xb7\x3c\x39\xbd\xfe\x32\xfd\x31\xbd\xba\x89\xcf\xaf\xe7\x67\xc7\xdf\x4f\x6e\x26\xb3\x93\xcb\x3c\x4d\x0b\x11\x0b\xa6\xb8\x4c\x23\x52\x29\xbe\xe6\x26\x1f\x93\x95\xe3\xf8\xae\x9e\x8c\xc2\xf8\xed\x90\x23\xcb\xe2\x20\xa4\x1f\x9d\xd9\x9e\x4c\x76\xab\x79\xab\x64\x8d\xd3\xa1\x8e\x1d\x17\x6b\x80\xf1\xd0\xcf\x56\xb8\x70\xc9\xe8\xe9\x09\xb8\x06\xba\x87\x6c\xd6\x7a\xe3\x05\x41\x52\x2a\x4b\x02\xcf\xcf\xef\x70\x9c\xcc\xce\xaf\x2f\x7e\xfd\xdc\xb0\x34\x2a\xed\x32\xa4\x4b\xd2\xf4\x5e\x42\x5e\xa3\x0b\x04\x69\x4a\xbe\x16\x2d\x29\xf5\x52\x51\x8a\xce\x49\x89\x86\x85\xa3\xfc\xe0\xa0\x67\x25\x5f\x45\x8e\xbd\xc1\x18\x0e\x80\x50\xb3\x23\xb0\x39\x1a\x24\x6b\x47\xd8\xb3\x25\xbd\x2f\x9b\xd6\xad\xb0\x4f\xa0\x21\x4f\x8a\x46\x01\xd0\x40\x07\xe9\x87\xb0\x94\x65\xeb\xd0\xd8\x37\x60\x73\x82\x6d\x97\x26\xdf\x06\xc9\xd0\xa1\x72\x14\x02\xd5\xca\xe3\x82\x4b\x74\x6e\xb5\x7d\xd5\x63\x76\x94\xa7\xff\x6d\xed\x85\x3e\xad\x1d\x36\x21\x23\xdf\xbd\x23\x3d\xf2\xb6\x81\x14\x4a\xf4\xb1\x80\x5a\x14\xa4\x23\x55\xae\x28\x80\xd4\xfd\xc4\x3a\x65\xa8\x4d\x00\x8c\x08\x0e\x83\x81\x52\x10\xb5\x0c\x2e\x94\x6a\x52\x2c\xdc\xea\xf0\x15\x30\xcc\xa5\x75\x55\xac\x47\x7b\x7d\x37\x3b\x93\x8a\x66\xd4\x70\x8c\x92\xb1\xf8\xec\x74\x80\x9d\x3e\x9a\xe2\x24\x42\x4b\x71\x4b\xa5\x01\xfb\xfe\xc0\xe0\x7c\x3b\x0c\xf7\x9a\x03\xb0\x0f\x46\x58\x65\x9b\x65\x4d\x7f\x5f\xcd\x26\xc3\xaa\x5e\x18\x0b\x82\x20\xad\x96\x54\x41\xad\xb2\x00\x8b\xd7\x8e\xa7\xb3\x1d\x7b\x8b\xa9\x0d\xab\x30\x50\xad\xb7\x37\x9a\x3e\x52\x79\x69\xa8\x96\x6f\x95\xe3\x36\xe8\xb8\x60\xbf\x9e\x82\xfd\x77\x7e\xab\xd7\x0f\x3b\x9b\x6f\xec\xdd\xdf\x71\x8f\x0f\x42\xbe\xbf\x33\xd7\x9b\x7c\xfe\x0b\x00\x00\xff\xff\x21\x0d\x51\xd3\x3e\x04\x00\x00"), }, - "/bootconfig/kickstart.cfg.template": &vfsgen۰CompressedFileInfo{ - name: "kickstart.cfg.template", - modTime: time.Date(2024, 6, 4, 2, 3, 2, 321472207, time.UTC), - uncompressedSize: 918, - - compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x6c\x90\x4f\x6b\xdc\x30\x10\xc5\xef\xfa\x14\x43\x96\x90\x93\x76\x7b\x28\xa5\x17\x43\x43\xfe\x40\x68\x1b\x42\xd3\xb4\x3d\xb5\xcc\x4a\xb3\xb6\xb0\x3c\x23\x24\xd9\x1b\xc7\xec\x77\x2f\x72\x9c\x7f\xa5\xb7\xa7\x37\xf3\x1b\xcd\xbc\xd5\x40\x31\x39\xe1\xea\xfc\xe2\xc7\xc5\x17\xe5\x6a\x96\x48\xd6\xa5\x16\xb4\x16\xf6\xa3\xee\x13\x55\xc9\xa2\xc2\x3e\x4b\xc0\x98\x41\xeb\x3c\x06\xaa\xfc\xd0\xa9\x15\xdc\x60\xcc\x2e\x3b\x61\x30\x9e\x30\x3a\xae\xc1\xf1\x4e\x62\x87\xc5\x54\xb3\xb9\x50\x2c\x4c\xa0\xb5\x63\x97\x3d\x6e\xc9\xab\x15\xdc\x25\x82\x3a\x62\x68\x9c\x41\x0f\x8e\x53\x46\xef\xd5\xb3\xa3\x56\xf0\x99\xc6\xad\x60\xb4\xe0\x71\x94\x3e\x27\xd5\x3e\x19\x5a\x0f\xa6\xa5\xb1\xc3\x50\x19\x06\xad\xef\x97\x8e\xea\xc4\xf0\x89\x5a\xc1\xed\x98\x32\x75\xe0\x91\xeb\x1e\x6b\x52\x45\xc0\x43\xf3\xe7\xec\x7a\x7d\xf7\xfd\x52\x7f\x54\x6a\x05\xd7\x94\xf7\x12\xdb\x37\x2b\xf3\xe2\x81\xd6\x5b\x91\x1c\xa2\x64\xa9\x6c\x63\x02\x68\x6d\x69\x70\x86\x2a\xe2\xf0\x3e\xbd\x2b\xb7\x84\xe1\x43\x55\x82\x01\xad\xd1\x64\x37\x60\xa6\xd7\x03\x1a\x49\x99\xb1\xa3\x4a\x02\x31\xf5\x9e\xe2\xda\x48\x89\xed\x9b\x48\x86\x80\x29\xed\x25\x5a\x15\xcb\x3f\xfb\x32\x2f\x99\x38\x86\x4c\x16\xa6\x69\x7d\xb3\x94\x0f\x87\x02\xf4\x0c\xb9\x21\xb8\xa5\xdc\x07\x38\xad\x89\x33\x08\xc3\xce\xc5\x94\xa1\xec\xa9\x66\x59\x14\x68\x4d\x8c\x5b\x4f\x6a\x05\xe7\x02\x2c\x19\x8c\xf0\xce\xd5\x7d\xa4\x79\xc6\x2f\xf8\xe9\xd8\xca\x7e\x89\x48\xa5\xd6\x85\xfb\x97\xc4\x12\xc5\x72\x65\x52\x4f\xa2\x1c\xee\x52\x99\x68\xab\x23\xd3\x44\xe1\xd1\x1e\xbd\xf4\x67\xd7\xd1\x83\x30\xa9\x27\x01\xa7\xc9\xe1\xe6\xb6\x41\xae\x1b\x74\xa0\x75\x9f\x8d\x52\xc7\x01\x4d\x8b\x35\x25\xf5\xe9\x77\xe7\xd8\x75\xe8\x35\xf1\xe0\xa2\x70\x47\x9c\x95\x3a\x26\xb6\xa5\x4d\x52\x39\xc1\x4b\x5d\x6d\x06\x8c\x1b\x2f\xf5\xa6\x4d\xba\xd8\x6b\x2f\xb5\xea\x5a\xeb\x22\xe8\x00\x1b\xca\x66\xc3\xad\xdd\x39\x4f\x69\xd3\x88\xb4\x8f\x4a\xa9\x69\x72\x3b\x58\x5f\xa5\x73\x31\x2d\x45\xd0\x87\xc3\x3f\x94\x9d\x0b\x6a\x9a\x88\xed\x5c\x7e\x46\xae\x52\xef\xd1\xfe\x07\x71\x73\xe1\x2d\x12\x91\x6b\x82\xf5\x65\xf9\xf6\x70\x50\xd3\xb4\x3e\x13\xce\xc4\x79\x79\x94\x04\xe8\xab\xd8\xf9\x49\x6c\xdf\x50\x8f\xe9\xd9\x05\x7c\xd5\x52\x72\xf8\x1b\x00\x00\xff\xff\x87\x90\xf8\xb5\x96\x03\x00\x00"), - }, "/bootconfig/systemd": &vfsgen۰DirInfo{ name: "systemd", modTime: time.Date(2024, 5, 28, 1, 5, 55, 850365055, time.UTC), @@ -206,6 +199,43 @@ var Assets = func() http.FileSystem { compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xac\x93\x41\x6b\x1b\x31\x10\x85\xef\xfe\x15\x83\xef\xeb\x25\x57\xdd\x42\x93\x42\xa1\x71\x4d\x43\x7b\x2d\x93\xdd\x67\xaf\xd8\x91\x46\x48\xda\x4d\x4d\xc8\x7f\x2f\x8a\x5d\x7b\xd7\x14\xe2\x40\x75\x9c\x79\xf3\xcd\x3c\x31\xc3\xc1\xfe\x44\x4c\x56\xbd\x21\x0e\x21\xd5\xe3\xcd\xa2\xb7\xbe\x35\x74\xc7\x70\xea\x1f\x91\x17\x0e\x99\x5b\xce\x6c\x16\x44\x9e\x1d\x0c\x75\x3a\x24\xf4\x40\x40\xac\x1a\xf5\x39\xaa\x08\x62\xe5\xd8\xf3\x0e\xf1\x28\x4b\x81\x9b\x0b\x6d\xda\xa7\x0c\xb7\x20\x12\x7e\x82\xa4\x02\x24\x3a\x02\xaa\x20\xec\xdf\x67\xa7\x80\xa6\xd4\x25\x08\x9a\xac\xf1\xc0\x70\x9c\x9b\xee\xeb\x04\xfa\x51\x2c\x51\x86\x0b\xc2\x19\x47\xe0\xc4\x73\x79\x32\x63\x7f\x9c\x4e\xf4\x77\xf0\xf2\xb2\x0a\x22\x67\xab\x7e\x82\xac\xa8\xc7\xde\xd0\xd2\x6b\x8b\x2a\xaa\x60\xd5\x0f\x4f\x88\x1e\x19\x69\x65\xb5\x76\x9c\x32\xe2\xf2\xa4\x27\xd2\x50\x28\x1a\x0d\x2d\xef\x7f\xdb\x94\xd3\x34\x89\xed\x16\x4d\x36\xb4\x5c\xeb\x63\xd3\xa1\x1d\x04\xcb\xab\x7b\x3d\x6b\xec\xff\x4f\xaf\xf2\x1b\x6c\x3d\xe2\xd9\x69\x75\xed\x16\x9d\xfe\xda\x39\xf6\xad\x99\x34\xac\xa8\xbe\xb6\xda\x3a\xde\xc1\xd0\xcb\xcb\xea\xd3\x49\xf5\xa5\xc4\x7e\x44\x79\x7d\xbd\xd0\x6d\x06\x91\x8d\x8a\x6d\xf6\x86\x6e\xe5\x99\xf7\xe9\x2c\x18\x55\x06\x87\x07\x1d\x7c\x4e\xf3\x59\x0e\x76\x86\xb0\x8b\xdc\xa2\x6a\xdf\x0e\x67\x22\x20\x72\xa5\x68\xc3\xb9\x33\x54\x8f\x1c\x6b\xdf\xb7\xe7\x3c\xfc\xf8\x2f\xdc\xfa\xdb\xdd\xfd\xaf\xf5\xed\xc3\xfd\x8c\x34\xb2\x0c\xf8\x1c\xd5\x99\x59\x98\xb6\x16\xd2\x7e\xc7\xf6\x22\x4c\xd3\xfb\x1e\x6f\x2e\x92\x6f\x45\x87\xb1\xca\x76\xae\xca\x36\xac\xd9\x61\x31\x35\x3c\xdb\xd0\x77\x9c\x76\x9a\x0e\x36\x67\x8d\xc2\xcc\xf8\x9f\x00\x00\x00\xff\xff\x09\x7d\x30\x1a\x72\x04\x00\x00"), }, + "/kickstart": &vfsgen۰DirInfo{ + name: "kickstart", + modTime: time.Date(2024, 6, 4, 2, 2, 50, 861322610, time.UTC), + }, + "/kickstart/controlplane": &vfsgen۰DirInfo{ + name: "controlplane", + modTime: time.Date(2024, 6, 4, 2, 2, 50, 850322466, time.UTC), + }, + "/kickstart/controlplane/kickstart.cfg.template": &vfsgen۰CompressedFileInfo{ + name: "kickstart.cfg.template", + modTime: time.Date(2024, 6, 4, 2, 2, 50, 859322584, time.UTC), + uncompressedSize: 918, + + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x6c\x90\xcb\x6e\xdc\x3c\x0c\x85\xf7\x7c\x0a\x22\x46\x90\x95\x66\xfe\xc5\x8f\xa2\x1b\x03\x0d\x72\x41\x83\xb6\x41\xd0\x34\x6d\x57\x2d\x38\x16\xc7\x16\x2c\x93\x86\x24\x7b\xe2\x18\xf3\xee\x85\x26\xce\xad\xe8\xee\xe8\x90\x1f\x45\x9e\x62\xe4\x10\x9d\x4a\x79\x7e\xf1\xfd\xe2\x33\xb8\x5a\x34\xb0\x75\xb1\x45\x63\x54\xfc\x64\x86\xc8\x65\xb4\x04\x34\x24\xed\x29\x24\x34\x26\x4d\x3d\x97\x7e\xec\xa0\xc0\x1b\x0a\xc9\x25\xa7\x82\x95\x67\x0a\x4e\x6a\x74\xb2\xd5\xd0\x51\x36\xe1\x60\x2e\x94\xa8\x30\x1a\xe3\xc4\x25\x4f\x1b\xf6\x50\xe0\x5d\x64\xac\x03\xf5\x8d\xab\xc8\xa3\x93\x98\xc8\x7b\x78\x76\xa0\xc0\x4f\x3c\x6d\x94\x82\x45\x4f\x93\x0e\x29\x42\xfb\x64\x18\x33\x56\x2d\x4f\x1d\xf5\x65\x25\x68\xcc\xfd\xd2\x51\x9e\x54\x72\x02\x05\xde\x4e\x31\x71\x87\x9e\xa4\x1e\xa8\x66\xc8\x02\x1f\x9a\xdf\x67\xd7\xab\xbb\x6f\x97\xe6\x3d\x40\x81\xd7\x9c\x76\x1a\xda\x37\x2b\xcb\xe2\xa1\x31\x1b\xd5\xd4\x07\x4d\x5a\xda\xa6\xea\xd1\x18\xcb\xa3\xab\xb8\x64\xe9\xff\x8f\xff\xe5\x5b\xfa\xf1\x5d\x99\x83\x41\x63\xa8\x4a\x6e\xa4\xc4\xaf\x07\x34\x1a\x93\x50\xc7\xe5\x3c\xaf\x3e\x2e\x7a\xbf\x87\x02\xbf\xaa\x26\xec\x29\xc6\x9d\x06\x0b\x21\xff\xb3\xcb\xf3\x62\x15\xa6\x3e\xb1\xc5\x79\x5e\xdd\x2c\xe5\x47\x60\x10\x4c\x0d\xe3\x2d\xa7\xa1\xc7\xd3\x9a\x25\xa1\x0a\x6e\x5d\x88\x09\xf3\x9e\x70\x90\x59\xa1\x31\x2c\xb4\xf1\x0c\x05\x9e\x2b\x8a\x26\xac\x54\xb6\xae\x1e\x02\x1f\x66\xfc\xc4\x1f\x4e\xac\xee\x96\x88\x20\xb6\xae\xbf\x7f\x49\x2c\x72\xc8\x57\x46\x78\x12\xf9\x70\x17\xf3\x44\x5b\x1e\x55\x4d\x50\x99\xec\xd1\x4b\x7f\x72\x1d\x3f\xa8\x30\x3c\x09\x3c\x8d\x8e\xd6\xb7\x0d\x49\xdd\x90\x43\x63\x86\x54\x01\x1c\xf7\x54\xb5\x54\x73\x84\x0f\xbf\x3a\x27\xae\x23\x6f\x58\x46\x17\x54\x3a\x96\x04\x70\xcc\x62\x73\x9b\xc6\x7c\x82\xd7\xba\x5c\x8f\x14\xd6\x5e\xeb\x75\x1b\x4d\xb6\x57\x5e\x6b\xe8\x5a\xeb\x02\x9a\x1e\xd7\x9c\xaa\xb5\xb4\x76\xeb\x3c\xc7\x75\xa3\xda\x3e\x2a\x80\x79\x76\x5b\x5c\x5d\xc5\x73\xad\x5a\x0e\x68\xf6\xfb\xbf\x28\x7b\x28\xc0\x3c\xb3\xd8\x43\xf9\x19\xb9\x8a\x83\x27\xfb\x0f\xc4\x1d\x0a\x6f\x91\x40\x52\x33\xae\x2e\xf3\xb7\xfb\x3d\xcc\xf3\xea\x4c\x25\xb1\xa4\xe5\x91\x13\xe0\x2f\x6a\x0f\x4f\x16\xfb\x86\x7a\x4c\xcf\x2e\xe0\xab\x96\x9c\xc3\x9f\x00\x00\x00\xff\xff\x1d\xd5\xfd\xbd\x96\x03\x00\x00"), + }, + "/kickstart/master": &vfsgen۰DirInfo{ + name: "master", + modTime: time.Date(2024, 6, 4, 2, 2, 50, 860322597, time.UTC), + }, + "/kickstart/master/kickstart.cfg.template": &vfsgen۰CompressedFileInfo{ + name: "kickstart.cfg.template", + modTime: time.Date(2024, 6, 4, 2, 2, 50, 861322610, time.UTC), + uncompressedSize: 918, + + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x6c\x90\xcb\x6e\xdc\x3c\x0c\x85\xf7\x7c\x0a\x22\x46\x90\x95\x66\xfe\xc5\x8f\xa2\x1b\x03\x0d\x72\x41\x83\xb6\x41\xd0\x34\x6d\x57\x2d\x38\x16\xc7\x16\x2c\x93\x86\x24\x7b\xe2\x18\xf3\xee\x85\x26\xce\xad\xe8\xee\xe8\x90\x1f\x45\x9e\x62\xe4\x10\x9d\x4a\x79\x7e\xf1\xfd\xe2\x33\xb8\x5a\x34\xb0\x75\xb1\x45\x63\x54\xfc\x64\x86\xc8\x65\xb4\x04\x34\x24\xed\x29\x24\x34\x26\x4d\x3d\x97\x7e\xec\xa0\xc0\x1b\x0a\xc9\x25\xa7\x82\x95\x67\x0a\x4e\x6a\x74\xb2\xd5\xd0\x51\x36\xe1\x60\x2e\x94\xa8\x30\x1a\xe3\xc4\x25\x4f\x1b\xf6\x50\xe0\x5d\x64\xac\x03\xf5\x8d\xab\xc8\xa3\x93\x98\xc8\x7b\x78\x76\xa0\xc0\x4f\x3c\x6d\x94\x82\x45\x4f\x93\x0e\x29\x42\xfb\x64\x18\x33\x56\x2d\x4f\x1d\xf5\x65\x25\x68\xcc\xfd\xd2\x51\x9e\x54\x72\x02\x05\xde\x4e\x31\x71\x87\x9e\xa4\x1e\xa8\x66\xc8\x02\x1f\x9a\xdf\x67\xd7\xab\xbb\x6f\x97\xe6\x3d\x40\x81\xd7\x9c\x76\x1a\xda\x37\x2b\xcb\xe2\xa1\x31\x1b\xd5\xd4\x07\x4d\x5a\xda\xa6\xea\xd1\x18\xcb\xa3\xab\xb8\x64\xe9\xff\x8f\xff\xe5\x5b\xfa\xf1\x5d\x99\x83\x41\x63\xa8\x4a\x6e\xa4\xc4\xaf\x07\x34\x1a\x93\x50\xc7\xe5\x3c\xaf\x3e\x2e\x7a\xbf\x87\x02\xbf\xaa\x26\xec\x29\xc6\x9d\x06\x0b\x21\xff\xb3\xcb\xf3\x62\x15\xa6\x3e\xb1\xc5\x79\x5e\xdd\x2c\xe5\x47\x60\x10\x4c\x0d\xe3\x2d\xa7\xa1\xc7\xd3\x9a\x25\xa1\x0a\x6e\x5d\x88\x09\xf3\x9e\x70\x90\x59\xa1\x31\x2c\xb4\xf1\x0c\x05\x9e\x2b\x8a\x26\xac\x54\xb6\xae\x1e\x02\x1f\x66\xfc\xc4\x1f\x4e\xac\xee\x96\x88\x20\xb6\xae\xbf\x7f\x49\x2c\x72\xc8\x57\x46\x78\x12\xf9\x70\x17\xf3\x44\x5b\x1e\x55\x4d\x50\x99\xec\xd1\x4b\x7f\x72\x1d\x3f\xa8\x30\x3c\x09\x3c\x8d\x8e\xd6\xb7\x0d\x49\xdd\x90\x43\x63\x86\x54\x01\x1c\xf7\x54\xb5\x54\x73\x84\x0f\xbf\x3a\x27\xae\x23\x6f\x58\x46\x17\x54\x3a\x96\x04\x70\xcc\x62\x73\x9b\xc6\x7c\x82\xd7\xba\x5c\x8f\x14\xd6\x5e\xeb\x75\x1b\x4d\xb6\x57\x5e\x6b\xe8\x5a\xeb\x02\x9a\x1e\xd7\x9c\xaa\xb5\xb4\x76\xeb\x3c\xc7\x75\xa3\xda\x3e\x2a\x80\x79\x76\x5b\x5c\x5d\xc5\x73\xad\x5a\x0e\x68\xf6\xfb\xbf\x28\x7b\x28\xc0\x3c\xb3\xd8\x43\xf9\x19\xb9\x8a\x83\x27\xfb\x0f\xc4\x1d\x0a\x6f\x91\x40\x52\x33\xae\x2e\xf3\xb7\xfb\x3d\xcc\xf3\xea\x4c\x25\xb1\xa4\xe5\x91\x13\xe0\x2f\x6a\x0f\x4f\x16\xfb\x86\x7a\x4c\xcf\x2e\xe0\xab\x96\x9c\xc3\x9f\x00\x00\x00\xff\xff\x1d\xd5\xfd\xbd\x96\x03\x00\x00"), + }, + "/kickstart/worker": &vfsgen۰DirInfo{ + name: "worker", + modTime: time.Date(2024, 6, 4, 2, 2, 50, 862322623, time.UTC), + }, + "/kickstart/worker/kickstart.cfg.template": &vfsgen۰CompressedFileInfo{ + name: "kickstart.cfg.template", + modTime: time.Date(2024, 6, 4, 2, 31, 21, 304857538, time.UTC), + uncompressedSize: 1089, + + compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x6c\x52\xc1\x8e\x1b\x37\x0c\xbd\xf3\x2b\x08\xdb\xc1\xee\x1e\x68\xb7\x45\x51\xe4\x32\x45\x83\x6c\x02\x04\x6d\x83\xa0\xdb\xb4\x3d\x35\xd0\x4a\xf4\x8c\x30\x1a\x72\x20\x71\xbc\xeb\x4c\xfc\xef\x85\xbc\xb6\xd3\x2d\x7a\x7b\x7a\x7c\xef\x89\xa4\xb4\xdc\x71\x2e\x51\xa5\xb9\x7d\xf3\xc7\x9b\x5f\x20\xb6\xa2\x99\x43\x2c\x3d\x12\xa9\xa4\x3d\x4d\x85\x9b\x12\x1c\xb8\xc9\x74\x74\xd9\x90\xc8\xf6\x23\x37\x69\x37\xc0\x12\x3f\xb8\x6c\xd1\xa2\x0a\xfa\xc4\x2e\x47\x69\x31\xca\x56\xf3\xe0\x2a\x09\x47\xf2\xe4\x12\x15\x46\xa2\x28\xd1\x92\xbb\xe7\x04\x4b\xfc\x58\x18\xdb\xec\xc6\x2e\x7a\x97\x30\x4a\x31\x97\x12\x5c\x18\x58\xe2\xcf\xbc\xbf\x57\x97\x03\x26\xb7\xd7\xc9\x0a\xf4\x67\x82\x68\xe7\x7b\xde\x0f\x6e\x6c\xbc\x20\xd1\xe3\x49\xd1\x5c\x79\xb9\x82\x25\xde\xed\x8b\xf1\x80\xc9\x49\x3b\xb9\x96\xa1\x02\xfc\xdc\x7d\x7a\xfd\x7e\xfd\xf1\xf7\xb7\xf4\x12\x60\x89\xef\xd9\x1e\x34\xf7\xcf\x5a\x96\x13\x87\x44\xf7\xaa\x36\x66\x35\x6d\x42\xe7\x47\x24\x0a\xbc\x8b\x9e\x1b\x96\xf1\xfb\xf2\x4d\x9d\x65\xdc\xfd\xd0\xd4\xc5\x20\x91\xf3\x16\x77\xce\x18\x96\xf8\x9b\xaa\xe1\xe8\x4a\x79\xd0\x1c\x20\xd7\x94\x87\xaa\x2e\x3e\xef\x47\xe3\x80\xf3\xbc\xfe\x70\x2a\x1f\x0e\xd5\x30\x09\x5a\xc7\x78\xc7\x36\x8d\xf8\xaa\x65\x31\x54\xc1\x6d\xcc\xc5\xb0\x76\x01\x47\x58\x11\x12\xb1\xb8\xfb\x54\xef\xb9\x55\x14\x35\xf4\x2a\xdb\xd8\x4e\x99\x8f\x19\x7f\xe1\x9f\x51\x82\x3e\x9c\x16\x00\xa5\x8f\xe3\xe3\xd7\x7d\x14\xce\x75\x86\x02\x67\x50\xc7\x8a\xa5\x26\x86\x66\xe1\xbb\xac\xb2\x0f\x8b\xaf\x7a\x8b\x03\x7f\x56\x61\x38\x03\x7c\x55\xa2\xdb\xdc\x75\x4e\xda\xce\x45\x24\x9a\xcc\x03\xbc\x18\x9d\xef\x5d\xcb\x05\x7e\xfa\x7b\x88\x12\x07\x97\x88\x65\x17\xb3\xca\xc0\x62\x00\x2f\x58\x42\x95\x69\xa9\x23\x24\x6d\x9b\xcd\xce\xe5\x4d\xd2\x76\xd3\x17\xaa\xf4\x3a\x69\x5b\xef\x65\x3b\xce\xd1\x69\x31\x71\x03\xc3\x98\x79\x1b\x1f\x9b\x45\xff\xb2\xd0\x02\xb2\x93\xa0\xc3\xa7\x62\xf5\xaf\x35\xab\xeb\x69\x8a\xa1\x65\xc1\x2f\x68\x19\x29\xe0\x15\x5d\xe1\x17\xec\xd8\x05\x24\x8f\xab\xeb\xeb\x6f\xbf\x43\xc2\xd5\xbc\x7c\x8a\x39\xdc\xdc\xdc\xc0\x39\xba\x59\xac\xe6\x13\xbd\x9a\x9f\x05\x1f\x16\xc0\xbe\x53\x5c\x9d\xa5\xf8\x23\x6e\xd8\xfc\xe6\xd2\xd5\x19\x78\x4b\x58\xd8\xe8\x22\xbc\x58\x00\x86\x3e\xc4\x8c\x34\x3e\x59\xa5\x0f\xdb\x98\xb8\x6c\x3a\xd5\xfe\x09\x01\xcc\x73\xdc\xe2\xfa\x5d\xb9\x55\xdf\x73\x46\x3a\x1c\xfe\xe3\x0a\xc7\x02\xcc\x33\x4b\x38\x96\x2f\x96\x77\x65\x4a\x2e\xfc\x8f\x25\x1e\x0b\xcf\x2d\xd9\x49\xcb\xb8\x7e\x5b\xaf\x3d\x1c\x60\x9e\xd7\xaf\x55\x8c\xc5\x4e\x87\xfa\x9c\xfc\xab\x86\xe3\x91\x25\x3c\x73\x3d\x7d\x85\x70\x32\xfe\x4b\x52\x1f\xf5\x9f\x00\x00\x00\xff\xff\xdf\x6d\xa0\x7c\x41\x04\x00\x00"), + }, "/terraform": &vfsgen۰DirInfo{ name: "terraform", modTime: time.Date(2024, 5, 28, 1, 5, 55, 851365050, time.UTC), @@ -294,11 +324,11 @@ var Assets = func() http.FileSystem { fs["/"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ fs["/bootconfig"].(os.FileInfo), fs["/housekeeper"].(os.FileInfo), + fs["/kickstart"].(os.FileInfo), fs["/terraform"].(os.FileInfo), } fs["/bootconfig"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ fs["/bootconfig/files"].(os.FileInfo), - fs["/bootconfig/kickstart.cfg.template"].(os.FileInfo), fs["/bootconfig/systemd"].(os.FileInfo), } fs["/bootconfig/files"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ @@ -350,6 +380,20 @@ var Assets = func() http.FileSystem { fs["/housekeeper/5deployment.yaml.template"].(os.FileInfo), fs["/housekeeper/6daemonset.yaml.template"].(os.FileInfo), } + fs["/kickstart"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ + fs["/kickstart/controlplane"].(os.FileInfo), + fs["/kickstart/master"].(os.FileInfo), + fs["/kickstart/worker"].(os.FileInfo), + } + fs["/kickstart/controlplane"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ + fs["/kickstart/controlplane/kickstart.cfg.template"].(os.FileInfo), + } + fs["/kickstart/master"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ + fs["/kickstart/master/kickstart.cfg.template"].(os.FileInfo), + } + fs["/kickstart/worker"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ + fs["/kickstart/worker/kickstart.cfg.template"].(os.FileInfo), + } fs["/terraform"].(*vfsgen۰DirInfo).entries = []os.FileInfo{ fs["/terraform/generalos"].(os.FileInfo), fs["/terraform/nestos"].(os.FileInfo), diff --git a/data/data/bootconfig/kickstart.cfg.template b/data/data/kickstart/controlplane/kickstart.cfg.template similarity index 96% rename from data/data/bootconfig/kickstart.cfg.template rename to data/data/kickstart/controlplane/kickstart.cfg.template index 257b7dc..fe7dfc2 100644 --- a/data/data/bootconfig/kickstart.cfg.template +++ b/data/data/kickstart/controlplane/kickstart.cfg.template @@ -12,7 +12,7 @@ lang zh_CN.UTF-8 # Network information network --bootproto=dhcp --device=enp4s0 --ipv6=auto --activate -network --hostname=openeuler.com +network --hostname={{.Hostname}} # Root password rootpw --iscrypted {{.Password}} # Run the Setup Agent on first boot diff --git a/data/data/kickstart/master/kickstart.cfg.template b/data/data/kickstart/master/kickstart.cfg.template new file mode 100644 index 0000000..fe7dfc2 --- /dev/null +++ b/data/data/kickstart/master/kickstart.cfg.template @@ -0,0 +1,51 @@ +#version=DEVEL +ignoredisk --only-use=sda +autopart --type=lvm +# Partition clearing information +clearpart --none --initlabel +# Use graphical install +graphical +# Keyboard layouts +keyboard --vckeymap=cn --xlayouts='cn' +# System language +lang zh_CN.UTF-8 + +# Network information +network --bootproto=dhcp --device=enp4s0 --ipv6=auto --activate +network --hostname={{.Hostname}} +# Root password +rootpw --iscrypted {{.Password}} +# Run the Setup Agent on first boot +firstboot --enable +# Do not configure the X Window System +skipx +# System services +services --disabled="chronyd" +# System timezone +timezone Asia/Shanghai --utc + +%packages +@^minimal-environment + +%end + +%post --log=/var/log/ks-post.log +mkdir -p /etc/nkdfiles/hookfiles/ + +{{if .IsDocker -}} +mkdir -p /etc/docker +{{end -}} + +{{if .IsIsulad -}} +mkdir -p /etc/isulad +{{end -}} + +{{range .Files}} +{{.Content}} +{{.ChangeMod}} +{{end}} + +{{range .Systemds}} +{{.}} +{{end}} +%end \ No newline at end of file diff --git a/data/data/kickstart/worker/kickstart.cfg.template b/data/data/kickstart/worker/kickstart.cfg.template new file mode 100644 index 0000000..1b74cc9 --- /dev/null +++ b/data/data/kickstart/worker/kickstart.cfg.template @@ -0,0 +1,57 @@ +#version=DEVEL +ignoredisk --only-use=sda +autopart --type=lvm +# Partition clearing information +clearpart --none --initlabel +# Use graphical install +graphical +# Keyboard layouts +keyboard --vckeymap=cn --xlayouts='cn' +# System language +lang zh_CN.UTF-8 + +# Network information +network --bootproto=dhcp --device=enp4s0 --ipv6=auto --activate +# Root password +rootpw --iscrypted {{.Password}} +# Run the Setup Agent on first boot +firstboot --enable +# Do not configure the X Window System +skipx +# System services +services --disabled="chronyd" +# System timezone +timezone Asia/Shanghai --utc + +%packages +@^minimal-environment + +%end + +%post --log=/var/log/ks-post.log +# Set the hostname +prefix="k8s-" +random_string=$(uuidgen | tr -d '-' | head -c $((12 - ${#prefix}))) +hostname="${prefix}${random_string}" +echo $hostname > /etc/hostname +hostnamectl set-hostname $hostname + +mkdir -p /etc/nkdfiles/hookfiles/ + +{{if .IsDocker -}} +mkdir -p /etc/docker +{{end -}} + +{{if .IsIsulad -}} +mkdir -p /etc/isulad +{{end -}} + +{{range .Files}} +{{.Content}} +{{.ChangeMod}} +{{end}} + +{{range .Systemds}} +{{.}} +{{end}} +%end \ No newline at end of file diff --git a/pkg/osmanager/bootconfig/kickstart/template.go b/pkg/osmanager/bootconfig/kickstart/template.go index fa34bba..c85c05a 100644 --- a/pkg/osmanager/bootconfig/kickstart/template.go +++ b/pkg/osmanager/bootconfig/kickstart/template.go @@ -13,6 +13,7 @@ import ( ) type KsTempData struct { + Hostname string Password string Files []File Systemds []string @@ -53,6 +54,12 @@ func (t *template) GenerateBootConfig(url string, nodeType string) error { if nodeType == constants.Controlplane { tmplData.IsControlPlane = true tmplData.CertsUrl = utils.ConstructURL(url, constants.CertsFiles) + + ksData.Hostname = t.clusterAsset.Master[0].Hostname + } else if nodeType == constants.Master { + for i := 1; i < len(t.clusterAsset.Master); i++ { + ksData.Hostname = t.clusterAsset.Master[i].Hostname + } } engine, err := runtime.GetRuntime(t.clusterAsset.Runtime) @@ -106,7 +113,7 @@ func (t *template) GenerateBootConfig(url string, nodeType string) error { } ksData.Systemds = append(ksData.Systemds, fmt.Sprintf("systemctl enable %s", constants.KubeletService)) - file, err := data.Assets.Open("bootconfig/kickstart.cfg.template") + file, err := data.Assets.Open("kickstart/" + nodeType + "/kickstart.cfg.template") if err != nil { return fmt.Errorf("failed to open kickstart template file: %v", err) } -- Gitee