diff --git a/Documentation/design/installconfig.md b/Documentation/design/installconfig.md index 8fe8ff165f0..aaeef5f41d0 100644 --- a/Documentation/design/installconfig.md +++ b/Documentation/design/installconfig.md @@ -173,8 +173,6 @@ type AWSClusterSpec struct { SSHUser string SSLSecret corev1.LocalObjectReference - KeyPairName string - Region string VPCName string VPCSubnet string @@ -245,11 +243,11 @@ type InstallConfig struct { // ClusterID is the ID of the cluster. ClusterID string `json:"clusterID"` - // Admin is the configuration for the admin user. - Admin Admin `json:"admin"` + // Admin is the configuration for the admin user. + Admin Admin `json:"admin"` - // BaseDomain is the base domain to which the cluster should belong. - BaseDomain string `json:"baseDomain"` + // BaseDomain is the base domain to which the cluster should belong. + BaseDomain string `json:"baseDomain"` // Networking defines the pod network provider in the cluster. Networking `json:"networking"` @@ -260,16 +258,17 @@ type InstallConfig struct { // only one of the platform configuration should be set Platform `json:"platform"` - // License is an OpenShift license needed to install a cluster. - License string `json:"license"` + // License is an OpenShift license needed to install a cluster. + License string `json:"license"` - // PullSecret is the secret to use when pulling images. - PullSecret string `json:"pullSecret"` + // PullSecret is the secret to use when pulling images. + PullSecret string `json:"pullSecret"` } type Admin struct { - Email string `json:"email"` - Password string `json:"password"` + Email string `json:"email"` + Password string `json:"password"` + SSHKey string `json:"sshKey"` } type Platform struct { @@ -299,10 +298,6 @@ type AWS struct { // Region specifies the AWS region where the cluster will be created. Region string `json:"region"` - // KeyPairName is the name of the AWS key pair to use for SSH access to EC2 - // instances in this cluster. - KeyPairName string `json:"keyPairName"` - // VPCID specifies the vpc to associate with the cluster. // If empty, new vpc will be created. // +optional @@ -319,9 +314,6 @@ type Libvirt struct { // URI URI string `json:"URI"` - // SSHKey - SSHKey string `json:"sshKey"` - // Network Network `json:"network"` diff --git a/Documentation/design/resource_dep.dot b/Documentation/design/resource_dep.dot index ba009f5acc0..2936a8b1f81 100644 --- a/Documentation/design/resource_dep.dot +++ b/Documentation/design/resource_dep.dot @@ -23,6 +23,7 @@ strict digraph resource { platform [label="platform"]; email_address [label="email address"]; password [label="password"]; + sshkey [label="SSH key"]; } // Install config. @@ -88,6 +89,7 @@ strict digraph resource { // Dependencies password -> install_config; + sshkey -> install_config; platform -> install_config; email_address -> install_config; pull_secret -> install_config; diff --git a/Documentation/design/resource_dep.svg b/Documentation/design/resource_dep.svg index 9f9ddf6bf7f..839d9882a25 100644 --- a/Documentation/design/resource_dep.svg +++ b/Documentation/design/resource_dep.svg @@ -31,581 +31,591 @@ base_domain - -base domain + +base domain -install_config +install_config install-config.yaml -base_domain->install_config - - +base_domain->install_config + + cluster_name - -cluster name + +cluster name -cluster_name->install_config - - +cluster_name->install_config + + license - -license + +license -license->install_config - - +license->install_config + + pull_secret - -pull secret + +pull secret -pull_secret->install_config - - +pull_secret->install_config + + platform - -platform + +platform -platform->install_config - - +platform->install_config + + email_address - -email address + +email address -email_address->install_config - - +email_address->install_config + + password - -password + +password password->install_config - - + + + + +sshkey + +SSH key + + +sshkey->install_config + + -install_config->install_cfg +install_config->install_cfg -apiserver_bundle +apiserver_bundle apiserver crt/key -install_config->apiserver_bundle - - +install_config->apiserver_bundle + + -ingress_bundle +ingress_bundle ingress crt/key -install_config->ingress_bundle +install_config->ingress_bundle -openshift_apiserver_bundle +openshift_apiserver_bundle openshift apiserver crt/key -install_config->openshift_apiserver_bundle +install_config->openshift_apiserver_bundle -mcc_bundle +mcc_bundle machine config controller crt/key -install_config->mcc_bundle +install_config->mcc_bundle -operator_manifests +operator_manifests operator manifests and their configs -install_config->operator_manifests +install_config->operator_manifests -kubelet_kubeconfig +kubelet_kubeconfig kubeconfig-kubelet -install_config->kubelet_kubeconfig - - +install_config->kubelet_kubeconfig + + -kubeconfig +kubeconfig kubeconfig -install_config->kubeconfig +install_config->kubeconfig -terraform_state +terraform_state *.tfstate -install_config->terraform_state +install_config->terraform_state -admin_bundle +admin_bundle admin crt/key -admin_bundle->manifests - +admin_bundle->manifests + -admin_bundle->kubeconfig +admin_bundle->kubeconfig -aggregator_ca_bundle +aggregator_ca_bundle aggregator ca crt/key -aggregator_ca_bundle->manifests - - +aggregator_ca_bundle->manifests + + -apiserver_proxy_bundle +apiserver_proxy_bundle apiserver proxy crt/key -aggregator_ca_bundle->apiserver_proxy_bundle +aggregator_ca_bundle->apiserver_proxy_bundle -clusterapi_apiserver_bundle - -clusterapi apiserver crt/key +clusterapi_apiserver_bundle + +clusterapi apiserver crt/key -aggregator_ca_bundle->clusterapi_apiserver_bundle - - +aggregator_ca_bundle->clusterapi_apiserver_bundle + + -aggregator_ca_bundle->openshift_apiserver_bundle +aggregator_ca_bundle->openshift_apiserver_bundle -bootstrap_ignition +bootstrap_ignition bootstrap.ign -aggregator_ca_bundle->bootstrap_ignition +aggregator_ca_bundle->bootstrap_ignition -apiserver_bundle->manifests +apiserver_bundle->manifests -bootstrap_control_plane +bootstrap_control_plane bootstrap control plane manifests -apiserver_bundle->bootstrap_control_plane +apiserver_bundle->bootstrap_control_plane -apiserver_proxy_bundle->manifests +apiserver_proxy_bundle->manifests -apiserver_proxy_bundle->bootstrap_ignition +apiserver_proxy_bundle->bootstrap_ignition -clusterapi_apiserver_bundle->manifests - - +clusterapi_apiserver_bundle->manifests + + -clusterapi_apiserver_bundle->bootstrap_ignition - - +clusterapi_apiserver_bundle->bootstrap_ignition + + -etcd_ca_bundle +etcd_ca_bundle etcd ca crt/key -etcd_ca_bundle->manifests - - +etcd_ca_bundle->manifests + + -etcd_client_bundle +etcd_client_bundle etcd client crt/key -etcd_ca_bundle->etcd_client_bundle +etcd_ca_bundle->etcd_client_bundle -etcd_ca_bundle->bootstrap_control_plane +etcd_ca_bundle->bootstrap_control_plane -master_ignition +master_ignition master.ign -etcd_ca_bundle->master_ignition +etcd_ca_bundle->master_ignition -etcd_client_bundle->manifests +etcd_client_bundle->manifests -etcd_client_bundle->bootstrap_control_plane +etcd_client_bundle->bootstrap_control_plane -ingress_bundle->manifests - - +ingress_bundle->manifests + + -ingress_bundle->bootstrap_ignition +ingress_bundle->bootstrap_ignition -kube_ca_bundle - -kube ca crt/key +kube_ca_bundle + +kube ca crt/key -kube_ca_bundle->manifests - +kube_ca_bundle->manifests + -kube_ca_bundle->admin_bundle - - +kube_ca_bundle->admin_bundle + + -kube_ca_bundle->apiserver_bundle - - +kube_ca_bundle->apiserver_bundle + + -kube_ca_bundle->ingress_bundle - - +kube_ca_bundle->ingress_bundle + + -kubelet_bundle - -kubelet crt/key +kubelet_bundle + +kubelet crt/key -kube_ca_bundle->kubelet_bundle - - +kube_ca_bundle->kubelet_bundle + + -kube_ca_bundle->bootstrap_control_plane - +kube_ca_bundle->bootstrap_control_plane + -kubelet_bundle->manifests - +kubelet_bundle->manifests + -kubelet_bundle->kubelet_kubeconfig - - +kubelet_bundle->kubelet_kubeconfig + + -openshift_apiserver_bundle->manifests +openshift_apiserver_bundle->manifests -openshift_apiserver_bundle->bootstrap_ignition +openshift_apiserver_bundle->bootstrap_ignition -root_ca_bundle - -root ca crt/key +root_ca_bundle + +root ca crt/key -root_ca_bundle->manifests - +root_ca_bundle->manifests + -root_ca_bundle->aggregator_ca_bundle - - +root_ca_bundle->aggregator_ca_bundle + + -root_ca_bundle->etcd_ca_bundle - - +root_ca_bundle->etcd_ca_bundle + + -root_ca_bundle->kube_ca_bundle - - +root_ca_bundle->kube_ca_bundle + + -service_serving_ca_bundle +service_serving_ca_bundle service serving ca crt/key -root_ca_bundle->service_serving_ca_bundle - +root_ca_bundle->service_serving_ca_bundle + -root_ca_bundle->mcc_bundle - - +root_ca_bundle->mcc_bundle + + -root_ca_bundle->bootstrap_control_plane - - +root_ca_bundle->bootstrap_control_plane + + -root_ca_bundle->master_ignition - +root_ca_bundle->master_ignition + -worker_ignition +worker_ignition worker.ign -root_ca_bundle->worker_ignition - +root_ca_bundle->worker_ignition + -root_ca_bundle->kubelet_kubeconfig - - +root_ca_bundle->kubelet_kubeconfig + + -root_ca_bundle->kubeconfig - +root_ca_bundle->kubeconfig + -service_account_bundle +service_account_bundle service account pub/key -service_account_bundle->manifests +service_account_bundle->manifests -service_account_bundle->bootstrap_ignition +service_account_bundle->bootstrap_ignition -service_serving_ca_bundle->manifests +service_serving_ca_bundle->manifests -service_serving_ca_bundle->bootstrap_ignition +service_serving_ca_bundle->bootstrap_ignition -mcc_bundle->manifests +mcc_bundle->manifests -mcc_bundle->bootstrap_ignition +mcc_bundle->bootstrap_ignition -operator_manifests->manifests +operator_manifests->manifests -operator_manifests->bootstrap_control_plane +operator_manifests->bootstrap_control_plane -misc_manifests +misc_manifests misc manifests (rbac, namespace, CRD, pod security policy, etc) -operator_manifests->misc_manifests - - +operator_manifests->misc_manifests + + -operator_manifests->bootstrap_ignition +operator_manifests->bootstrap_ignition -bootstrap_control_plane->manifests +bootstrap_control_plane->manifests -bootstrap_control_plane->bootstrap_ignition +bootstrap_control_plane->bootstrap_ignition -misc_manifests->manifests +misc_manifests->manifests -misc_manifests->bootstrap_ignition - - +misc_manifests->bootstrap_ignition + + -bootstrap_ignition->ignition_configs +bootstrap_ignition->ignition_configs -bootstrap_ignition->terraform_state +bootstrap_ignition->terraform_state -master_ignition->ignition_configs +master_ignition->ignition_configs -master_ignition->terraform_state +master_ignition->terraform_state -worker_ignition->ignition_configs +worker_ignition->ignition_configs -worker_ignition->terraform_state +worker_ignition->terraform_state -kubelet_kubeconfig->manifests +kubelet_kubeconfig->manifests -kubelet_kubeconfig->bootstrap_ignition - - +kubelet_kubeconfig->bootstrap_ignition + + -kubelet_kubeconfig->master_ignition +kubelet_kubeconfig->master_ignition -kubeconfig->manifests +kubeconfig->manifests -kubeconfig->cluster +kubeconfig->cluster -terraform_state->cluster +terraform_state->cluster diff --git a/pkg/asset/doc.go b/pkg/asset/doc.go new file mode 100644 index 00000000000..8c199afb6e5 --- /dev/null +++ b/pkg/asset/doc.go @@ -0,0 +1,2 @@ +// Package asset defines the asset dependencies and implements the graph engine. +package asset diff --git a/pkg/asset/installconfig/clusterid.go b/pkg/asset/installconfig/clusterid.go index 8771441d28a..1fbbebde41e 100644 --- a/pkg/asset/installconfig/clusterid.go +++ b/pkg/asset/installconfig/clusterid.go @@ -19,7 +19,7 @@ func (a *clusterID) Dependencies() []asset.Asset { func (a *clusterID) Generate(map[asset.Asset]*asset.State) (*asset.State, error) { return &asset.State{ Contents: []asset.Content{ - {Data: []byte(uuid.NewUUID().String())}, + {Data: []byte(uuid.New())}, }, }, nil } diff --git a/pkg/asset/installconfig/doc.go b/pkg/asset/installconfig/doc.go new file mode 100644 index 00000000000..fc5482f6203 --- /dev/null +++ b/pkg/asset/installconfig/doc.go @@ -0,0 +1,3 @@ +// Package installconfig generates the install config assets based on its dependencies. +// The type itself is defined in ../pkg/types. +package installconfig diff --git a/pkg/asset/installconfig/installconfig.go b/pkg/asset/installconfig/installconfig.go index 5552d269b0f..475c7bd0d95 100644 --- a/pkg/asset/installconfig/installconfig.go +++ b/pkg/asset/installconfig/installconfig.go @@ -27,6 +27,7 @@ func (a *installConfig) Dependencies() []asset.Asset { a.assetStock.ClusterID(), a.assetStock.EmailAddress(), a.assetStock.Password(), + a.assetStock.SSHKey(), a.assetStock.BaseDomain(), a.assetStock.ClusterName(), a.assetStock.License(), @@ -40,6 +41,7 @@ func (a *installConfig) Generate(dependencies map[asset.Asset]*asset.State) (*as clusterID := string(dependencies[a.assetStock.ClusterID()].Contents[0].Data) emailAddress := string(dependencies[a.assetStock.EmailAddress()].Contents[0].Data) password := string(dependencies[a.assetStock.Password()].Contents[0].Data) + sshKey := string(dependencies[a.assetStock.SSHKey()].Contents[0].Data) baseDomain := string(dependencies[a.assetStock.BaseDomain()].Contents[0].Data) clusterName := string(dependencies[a.assetStock.ClusterName()].Contents[0].Data) license := string(dependencies[a.assetStock.License()].Contents[0].Data) @@ -53,6 +55,7 @@ func (a *installConfig) Generate(dependencies map[asset.Asset]*asset.State) (*as Admin: types.Admin{ Email: emailAddress, Password: password, + SSHKey: sshKey, }, BaseDomain: baseDomain, License: license, @@ -64,17 +67,13 @@ func (a *installConfig) Generate(dependencies map[asset.Asset]*asset.State) (*as switch platform { case AWSPlatformType: region := string(platformState.Contents[1].Data) - keyPairName := string(platformState.Contents[2].Data) installConfig.AWS = &types.AWSPlatform{ - Region: region, - KeyPairName: keyPairName, + Region: region, } case LibvirtPlatformType: uri := string(platformState.Contents[1].Data) - sshKey := string(platformState.Contents[2].Data) installConfig.Libvirt = &types.LibvirtPlatform{ - URI: uri, - SSHKey: sshKey, + URI: uri, } default: return nil, fmt.Errorf("unknown platform type %q", platform) diff --git a/pkg/asset/installconfig/installconfig_test.go b/pkg/asset/installconfig/installconfig_test.go index 035571734b9..9a879417b3d 100644 --- a/pkg/asset/installconfig/installconfig_test.go +++ b/pkg/asset/installconfig/installconfig_test.go @@ -29,6 +29,7 @@ func TestInstallConfigDependencies(t *testing.T) { clusterID: &testAsset{name: "test-cluster-id"}, emailAddress: &testAsset{name: "test-email"}, password: &testAsset{name: "test-password"}, + sshKey: &testAsset{name: "test-sshkey"}, baseDomain: &testAsset{name: "test-domain"}, clusterName: &testAsset{name: "test-cluster"}, license: &testAsset{name: "test-license"}, @@ -42,6 +43,7 @@ func TestInstallConfigDependencies(t *testing.T) { "test-cluster-id", "test-email", "test-password", + "test-sshkey", "test-domain", "test-cluster", "test-license", @@ -69,10 +71,8 @@ func TestInstallConfigGenerate(t *testing.T) { platformContents: []string{ "aws", "test-region", - "test-keypairname", }, expectedPlatformYaml: ` aws: - keyPairName: test-keypairname region: test-region vpcCIDRBlock: "" vpcID: ""`, @@ -82,7 +82,6 @@ func TestInstallConfigGenerate(t *testing.T) { platformContents: []string{ "libvirt", "test-uri", - "test-sshkey", }, expectedPlatformYaml: ` libvirt: URI: test-uri @@ -91,8 +90,7 @@ func TestInstallConfigGenerate(t *testing.T) { if: "" ipRange: "" name: "" - resolver: "" - sshKey: test-sshkey`, + resolver: ""`, }, } for _, tc := range cases { @@ -101,6 +99,7 @@ func TestInstallConfigGenerate(t *testing.T) { clusterID: &testAsset{}, emailAddress: &testAsset{}, password: &testAsset{}, + sshKey: &testAsset{}, baseDomain: &testAsset{}, clusterName: &testAsset{}, license: &testAsset{}, @@ -129,6 +128,9 @@ func TestInstallConfigGenerate(t *testing.T) { stock.password: { Contents: []asset.Content{{Data: []byte("test-password")}}, }, + stock.sshKey: { + Contents: []asset.Content{{Data: []byte("test-sshkey")}}, + }, stock.baseDomain: { Contents: []asset.Content{{Data: []byte("test-domain")}}, }, @@ -162,6 +164,7 @@ func TestInstallConfigGenerate(t *testing.T) { exp := fmt.Sprintf(`admin: email: test-email password: test-password + sshKey: test-sshkey baseDomain: test-domain clusterID: test-cluster-id license: test-license diff --git a/pkg/asset/installconfig/platform.go b/pkg/asset/installconfig/platform.go index 73be3c472c2..053149cf4ce 100644 --- a/pkg/asset/installconfig/platform.go +++ b/pkg/asset/installconfig/platform.go @@ -27,11 +27,9 @@ var ( // // * AWS // Contents[1] is the region. -// Contents[2] is the key pair name. // // * Libvirt // Contents[1] is the URI. -// Contents[2] is the SSH key. type Platform struct { InputReader *bufio.Reader } @@ -73,15 +71,14 @@ func (a *Platform) awsPlatform() (*asset.State, error) { return assetStateForStringContents( AWSPlatformType, asset.QueryUser(a.InputReader, "Region:"), - asset.QueryUser(a.InputReader, "Key Pair Name:"), ), nil } func (a *Platform) libvirtPlatform() (*asset.State, error) { return assetStateForStringContents( LibvirtPlatformType, + // TODO(yifan): Set the default URI. asset.QueryUser(a.InputReader, "URI:"), - asset.QueryUser(a.InputReader, "SSH Key:"), ), nil } diff --git a/pkg/asset/installconfig/platform_test.go b/pkg/asset/installconfig/platform_test.go index 84d5a643c09..f9335963f7a 100644 --- a/pkg/asset/installconfig/platform_test.go +++ b/pkg/asset/installconfig/platform_test.go @@ -25,46 +25,38 @@ func TestPlatformGenerate(t *testing.T) { { name: "aws", input: `aws -test_region -test_keypairname`, +test_region`, expectedContents: []string{ "aws", "test_region", - "test_keypairname", }, }, { name: "libvirt", input: `libvirt -test_uri -test_sshkey`, +test_uri`, expectedContents: []string{ "libvirt", "test_uri", - "test_sshkey", }, }, { name: "case insensitive platform", input: `AWS -test_region -test_keypairname`, +test_region`, expectedContents: []string{ "aws", "test_region", - "test_keypairname", }, }, { name: "invalid platform", input: `bad-platform aws -test_region -test_keypairname`, +test_region`, expectedContents: []string{ "aws", "test_region", - "test_keypairname", }, }, } diff --git a/pkg/asset/installconfig/stock.go b/pkg/asset/installconfig/stock.go index a6151ddaa9d..4e97310780f 100644 --- a/pkg/asset/installconfig/stock.go +++ b/pkg/asset/installconfig/stock.go @@ -16,6 +16,8 @@ type Stock interface { EmailAddress() asset.Asset // Password is the asset that queries the user for the admin password. Password() asset.Asset + // SSHKey is the asset that queries the user for the ssh public key in a string format. + SSHKey() asset.Asset // BaseDomain is the asset that queries the user for the base domain to use // for the cluster. BaseDomain() asset.Asset @@ -36,6 +38,7 @@ type StockImpl struct { clusterID asset.Asset emailAddress asset.Asset password asset.Asset + sshKey asset.Asset baseDomain asset.Asset clusterName asset.Asset license asset.Asset @@ -58,6 +61,10 @@ func (s *StockImpl) EstablishStock(directory string, inputReader *bufio.Reader) Prompt: "Password:", InputReader: inputReader, } + s.sshKey = &asset.UserProvided{ + Prompt: "SSH Key:", + InputReader: inputReader, + } s.baseDomain = &asset.UserProvided{ Prompt: "Base Domain:", InputReader: inputReader, @@ -97,6 +104,11 @@ func (s *StockImpl) Password() asset.Asset { return s.password } +// SSHKey is the asset that queries the user for the ssh public key in a string format. +func (s *StockImpl) SSHKey() asset.Asset { + return s.sshKey +} + // BaseDomain is the asset that queries the user for the base domain to use // for the cluster. func (s *StockImpl) BaseDomain() asset.Asset { diff --git a/pkg/asset/stock/doc.go b/pkg/asset/stock/doc.go new file mode 100644 index 00000000000..38923c414df --- /dev/null +++ b/pkg/asset/stock/doc.go @@ -0,0 +1,2 @@ +// Package stock defines a stock type that holds that holds the instantiated assets. +package stock diff --git a/pkg/types/doc.go b/pkg/types/doc.go new file mode 100644 index 00000000000..a4f12b3ceaa --- /dev/null +++ b/pkg/types/doc.go @@ -0,0 +1,2 @@ +// Package types defines structures for user-supplied installer configuration. +package types diff --git a/pkg/types/installconfig.go b/pkg/types/installconfig.go index 9a1cdc4ca9d..fb936a38b27 100644 --- a/pkg/types/installconfig.go +++ b/pkg/types/installconfig.go @@ -45,6 +45,8 @@ type Admin struct { Email string `json:"email"` // Password is the password of the admin user. Password string `json:"password"` + // SSHKey to use for the access to compute instances. + SSHKey string `json:"sshKey,omitempty"` } // Platform is the configuration for the specific platform upon which to perform @@ -79,10 +81,6 @@ type AWSPlatform struct { // Region specifies the AWS region where the cluster will be created. Region string `json:"region"` - // KeyPairName is the name of the AWS key pair to use for SSH access to EC2 - // instances in this cluster. - KeyPairName string `json:"keyPairName"` - // VPCID specifies the vpc to associate with the cluster. // If empty, new vpc will be created. // +optional @@ -99,9 +97,6 @@ type LibvirtPlatform struct { // URI URI string `json:"URI"` - // SSHKey - SSHKey string `json:"sshKey"` - // Network Network LibvirtNetwork `json:"network"`