Skip to content

Commit

Permalink
cmd: allow image flags to override image from images-configmap
Browse files Browse the repository at this point in the history
Currently you can either specify `images-configmap` or you need to set all images using the corresponding image flag. This makes it difficult
to add new images like `etcd, setupEtcdEnv` as these are not set in installer [1] yet. This allows MCO to add new images with deafults and then update installer to override them
from the release image during bootstrapping.

[1]: https://github.com/openshift/installer/blob/d3ff3afe836d9880610a14be2f00d86ed34f3a13/data/data/bootstrap/files/usr/local/bin/bootkube.sh.template#L129-L131
  • Loading branch information
abhinavdahiya committed Jan 30, 2019
1 parent 1479180 commit 6f0f3ff
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions cmd/machine-config-operator/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func init() {
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.pullSecretFile, "pull-secret", "/assets/manifests/pull.json", "path to secret manifest that contains pull secret.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.destinationDir, "dest-dir", "", "The destination directory where MCO writes the manifests.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.imagesConfigMapFile, "images-json-configmap", "", "ConfigMap that contains images.json for MCO.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mccImage, "machine-config-controller-image", "", "Image for Machine Config Controller. (this cannot be set if --images-json-configmap is set)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mcsImage, "machine-config-server-image", "", "Image for Machine Config Server. (this cannot be set if --images-json-configmap is set)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mcdImage, "machine-config-daemon-image", "", "Image for Machine Config Daemon. (this cannot be set if --images-json-configmap is set)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.etcdImage, "etcd-image", "", "Image for Etcd. (this cannot be set if --images-json-configmap is set)")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.setupEtcdEnvImage, "setup-etcd-env-image", "", "Image for Setup Etcd Environment. (this cannot be set if --images-json-configmap is set)")
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.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 All @@ -69,15 +69,6 @@ func runBootstrapCmd(cmd *cobra.Command, args []string) {
glog.Fatal("--config-file cannot be empty")
}

if bootstrapOpts.imagesConfigMapFile != "" &&
(bootstrapOpts.mccImage != "" ||
bootstrapOpts.mcsImage != "" ||
bootstrapOpts.mcdImage != "" ||
bootstrapOpts.etcdImage != "" ||
bootstrapOpts.setupEtcdEnvImage != "") {
glog.Fatal("both --images-json-configmap and [--machine-config-{controller,server,daemon}-image, etcd-image, setup-etcd-env-image] flags cannot be set")
}

imgs := operator.DefaultImages()
if bootstrapOpts.imagesConfigMapFile != "" {
imgsRaw, err := rawImagesFromConfigMapOnDisk(bootstrapOpts.imagesConfigMapFile)
Expand All @@ -87,11 +78,20 @@ func runBootstrapCmd(cmd *cobra.Command, args []string) {
if err := json.Unmarshal([]byte(imgsRaw), &imgs); err != nil {
glog.Fatal(err)
}
} else {
}
if bootstrapOpts.mccImage != "" {
imgs.MachineConfigController = bootstrapOpts.mccImage
}
if bootstrapOpts.mcsImage != "" {
imgs.MachineConfigServer = bootstrapOpts.mcsImage
}
if bootstrapOpts.mcdImage != "" {
imgs.MachineConfigDaemon = bootstrapOpts.mcdImage
}
if bootstrapOpts.etcdImage != "" {
imgs.Etcd = bootstrapOpts.etcdImage
}
if bootstrapOpts.setupEtcdEnvImage != "" {
imgs.SetupEtcdEnv = bootstrapOpts.setupEtcdEnvImage
}
if err := operator.RenderBootstrap(
Expand Down

0 comments on commit 6f0f3ff

Please sign in to comment.