Skip to content

Commit

Permalink
operator: Add bootstrap arg --machine-config-oscontent-image
Browse files Browse the repository at this point in the history
This will allow the installer to render the payload's osImageURL
ConfigMap in the initial MachineConfig as well.

Closes: #334
  • Loading branch information
cgwalters committed Jan 31, 2019
1 parent 71ace53 commit 77ed063
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions cmd/machine-config-operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
rootCAFile string
pullSecretFile string
configFile string
oscontentImage string
imagesConfigMapFile string
mccImage string
mcsImage string
Expand All @@ -49,6 +50,7 @@ func init() {
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mccImage, "machine-config-controller-image", "", "Image for Machine Config Controller. (this overrides the image from --images-json-configmap)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mcsImage, "machine-config-server-image", "", "Image for Machine Config Server. (this overrides the image from --images-json-configmap)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mcdImage, "machine-config-daemon-image", "", "Image for Machine Config Daemon. (this overrides the image from --images-json-configmap)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.oscontentImage, "machine-config-oscontent-image", "", "Image for osImageURL")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.etcdImage, "etcd-image", "", "Image for Etcd. (this overrides the image from --images-json-configmap)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.setupEtcdEnvImage, "setup-etcd-env-image", "", "Image for Setup Etcd Environment. (this overrides the image from --images-json-configmap)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.configFile, "config-file", "", "ClusterConfig ConfigMap file.")
Expand Down Expand Up @@ -94,6 +96,10 @@ func runBootstrapCmd(cmd *cobra.Command, args []string) {
if bootstrapOpts.setupEtcdEnvImage != "" {
imgs.SetupEtcdEnv = bootstrapOpts.setupEtcdEnvImage
}
if bootstrapOpts.oscontentImage != "" {
imgs.MachineOSContent = bootstrapOpts.oscontentImage
}

if err := operator.RenderBootstrap(
bootstrapOpts.configFile,
bootstrapOpts.etcdCAFile, bootstrapOpts.rootCAFile, bootstrapOpts.pullSecretFile,
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RenderBootstrap(
return fmt.Errorf("error discovering MCOConfig from %q: %v", clusterConfigConfigMapFile, err)
}

config := getRenderConfig(mcoconfig, filesData[etcdCAFile], filesData[rootCAFile], nil, imgs, "")
config := getRenderConfig(mcoconfig, filesData[etcdCAFile], filesData[rootCAFile], nil, imgs)

manifests := []struct {
name string
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Images struct {
MachineConfigController string `json:"machineConfigController"`
MachineConfigDaemon string `json:"machineConfigDaemon"`
MachineConfigServer string `json:"machineConfigServer"`
MachineOSContent string `json:"machineOSContent"`
Etcd string `json:"etcd"`
SetupEtcdEnv string `json:"setupEtcdEnv"`
}
Expand All @@ -15,6 +16,7 @@ func DefaultImages() Images {
MachineConfigController: "docker.io/openshift/origin-machine-config-controller:v4.0.0",
MachineConfigDaemon: "docker.io/openshift/origin-machine-config-daemon:v4.0.0",
MachineConfigServer: "docker.io/openshift/origin-machine-config-server:v4.0.0",
MachineOSContent: "",
Etcd: "quay.io/coreos/etcd:v3.3.10",
SetupEtcdEnv: "registry.svc.ci.openshift.org/openshift/origin-v4.0:setup-etcd-environment",
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ func (optr *Operator) sync(key string) error {
if err != nil {
return err
}
imgs.MachineOSContent = osimageurl

rc := getRenderConfig(mcoconfig, etcdCA, rootCA, &v1.ObjectReference{Namespace: "kube-system", Name: "coreos-pull-secret"}, imgs, osimageurl)
rc := getRenderConfig(mcoconfig, etcdCA, rootCA, &v1.ObjectReference{Namespace: "kube-system", Name: "coreos-pull-secret"}, imgs)
return optr.syncAll(rc)
}

Expand Down Expand Up @@ -335,7 +336,7 @@ func icFromClusterConfig(cm *v1.ConfigMap) (installertypes.InstallConfig, error)
return ic, nil
}

func getRenderConfig(mc *mcfgv1.MCOConfig, etcdCAData, rootCAData []byte, ps *v1.ObjectReference, imgs Images, osimageurl string) renderConfig {
func getRenderConfig(mc *mcfgv1.MCOConfig, etcdCAData, rootCAData []byte, ps *v1.ObjectReference, imgs Images) renderConfig {
controllerconfig := mcfgv1.ControllerConfigSpec{
ClusterDNSIP: mc.Spec.ClusterDNSIP,
CloudProviderConfig: mc.Spec.CloudProviderConfig,
Expand All @@ -346,7 +347,7 @@ func getRenderConfig(mc *mcfgv1.MCOConfig, etcdCAData, rootCAData []byte, ps *v1
RootCAData: rootCAData,
PullSecret: ps,
SSHKey: mc.Spec.SSHKey,
OSImageURL: osimageurl,
OSImageURL: imgs.MachineOSContent,
Images: map[string]string{
templatectrl.EtcdImageKey: imgs.Etcd,
templatectrl.SetupEtcdEnvKey: imgs.SetupEtcdEnv,
Expand Down

0 comments on commit 77ed063

Please sign in to comment.