Created
April 3, 2020 19:53
-
-
Save Prashanth684/c52737c522b379edb5cf154d859315e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/data/data/libvirt/bootstrap/main.tf b/data/data/libvirt/bootstrap/main.tf | |
index 2b70f448b..70e52aa04 100644 | |
--- a/data/data/libvirt/bootstrap/main.tf | |
+++ b/data/data/libvirt/bootstrap/main.tf | |
@@ -13,7 +13,7 @@ resource "libvirt_ignition" "bootstrap" { | |
resource "libvirt_domain" "bootstrap" { | |
name = "${var.cluster_id}-bootstrap" | |
- memory = "2048" | |
+ memory = "${var.bootstrap_memory}" | |
vcpu = "2" | |
diff --git a/data/data/libvirt/bootstrap/variables.tf b/data/data/libvirt/bootstrap/variables.tf | |
index 84852a402..28b01d3f1 100644 | |
--- a/data/data/libvirt/bootstrap/variables.tf | |
+++ b/data/data/libvirt/bootstrap/variables.tf | |
@@ -33,3 +33,9 @@ variable "pool" { | |
type = string | |
description = "The name of the storage pool." | |
} | |
+ | |
+variable "bootstrap_memory" { | |
+ type = string | |
+ description = "RAM of bootstrap in MiB" | |
+ default = 2048 | |
+} | |
diff --git a/pkg/asset/cluster/cluster.go b/pkg/asset/cluster/cluster.go | |
index d3e04580f..0345e6278 100644 | |
--- a/pkg/asset/cluster/cluster.go | |
+++ b/pkg/asset/cluster/cluster.go | |
@@ -43,6 +43,7 @@ func (c *Cluster) Dependencies() []asset.Asset { | |
&installconfig.PlatformCredsCheck{}, | |
&installconfig.PlatformPermsCheck{}, | |
&TerraformVariables{}, | |
+ &TerraformOverrides{}, | |
&password.KubeadminPassword{}, | |
} | |
} | |
@@ -52,7 +53,8 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) { | |
clusterID := &installconfig.ClusterID{} | |
installConfig := &installconfig.InstallConfig{} | |
terraformVariables := &TerraformVariables{} | |
- parents.Get(clusterID, installConfig, terraformVariables) | |
+ terraformOverrides := &TerraformOverrides{} | |
+ parents.Get(clusterID, installConfig, terraformVariables, terraformOverrides) | |
if installConfig.Config.Platform.None != nil { | |
return errors.New("cluster cannot be created with platform set to 'none'") | |
@@ -73,6 +75,12 @@ func (c *Cluster) Generate(parents asset.Parents) (err error) { | |
extraArgs = append(extraArgs, fmt.Sprintf("-var-file=%s", filepath.Join(tmpDir, file.Filename))) | |
} | |
+ for _, file := range terraformOverrides.Files() { | |
+ if err := ioutil.WriteFile(filepath.Join(tmpDir, filepath.Base(file.Filename)), file.Data, 0600); err != nil { | |
+ return err | |
+ } | |
+ } | |
+ | |
logrus.Infof("Creating infrastructure resources...") | |
if installConfig.Config.Platform.AWS != nil { | |
if err := aws.PreTerraform(context.TODO(), clusterID.InfraID, installConfig); err != nil { | |
diff --git a/pkg/asset/cluster/tfoverrides.go b/pkg/asset/cluster/tfoverrides.go | |
new file mode 100644 | |
index 000000000..f6a6f2116 | |
--- /dev/null | |
+++ b/pkg/asset/cluster/tfoverrides.go | |
@@ -0,0 +1,53 @@ | |
+package cluster | |
+ | |
+import ( | |
+ "fmt" | |
+ | |
+ "github.com/openshift/installer/pkg/asset" | |
+ "github.com/sirupsen/logrus" | |
+) | |
+ | |
+const ( | |
+ // TfOverridesFileName is the filename for Terraform overrides. | |
+ TfOverridesFileName = "tf/%soverride.tf" | |
+) | |
+ | |
+// TerraformOverrides - list of override files | |
+type TerraformOverrides struct { | |
+ FileList []*asset.File | |
+} | |
+ | |
+var _ asset.WritableAsset = (*TerraformOverrides)(nil) | |
+ | |
+// Name returns the human-friendly name of the asset. | |
+func (t *TerraformOverrides) Name() string { | |
+ return "Terraform Overrides" | |
+} | |
+ | |
+// Dependencies returns the dependency of the TerraformOverrides | |
+func (t *TerraformOverrides) Dependencies() []asset.Asset { | |
+ return []asset.Asset{} | |
+} | |
+ | |
+// Generate is a noop here. | |
+func (t *TerraformOverrides) Generate(parents asset.Parents) error { | |
+ return nil | |
+} | |
+ | |
+// Files returns the files generated by the asset. | |
+func (t *TerraformOverrides) Files() []*asset.File { | |
+ return t.FileList | |
+} | |
+ | |
+// Load reads the tf/*override.tf from disk. The idea is to just copy this to the openshift-install folder | |
+// so Terraform can process the overrides | |
+func (t *TerraformOverrides) Load(f asset.FileFetcher) (found bool, err error) { | |
+ fileList, err := f.FetchByPattern(fmt.Sprintf(TfOverridesFileName, "*")) | |
+ if err != nil { | |
+ logrus.Debug("No terraform overrides found") | |
+ return true, nil | |
+ } | |
+ t.FileList = append(t.FileList, fileList...) | |
+ | |
+ return true, nil | |
+} | |
diff --git a/pkg/asset/targets/targets.go b/pkg/asset/targets/targets.go | |
index 6e0fdd73e..d691e3154 100644 | |
--- a/pkg/asset/targets/targets.go | |
+++ b/pkg/asset/targets/targets.go | |
@@ -64,6 +64,7 @@ var ( | |
// Cluster are the cluster targeted assets. | |
Cluster = []asset.WritableAsset{ | |
&cluster.TerraformVariables{}, | |
+ &cluster.TerraformOverrides{}, | |
&kubeconfig.AdminClient{}, | |
&password.KubeadminPassword{}, | |
&tls.JournalCertKey{}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment