-
Notifications
You must be signed in to change notification settings - Fork 394
/
bootstrap.go
120 lines (109 loc) · 6.22 KB
/
bootstrap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package main
import (
"flag"
"github.com/golang/glog"
"github.com/spf13/cobra"
"github.com/openshift/machine-config-operator/pkg/operator"
"github.com/openshift/machine-config-operator/pkg/version"
)
var (
bootstrapCmd = &cobra.Command{
Use: "bootstrap",
Short: "Machine Config Operator in bootstrap mode",
Long: "",
Run: runBootstrapCmd,
}
bootstrapOpts struct {
baremetalRuntimeCfgImage string
cloudConfigFile string
configFile string
cloudProviderCAFile string
corednsImage string
destinationDir string
haproxyImage string
imagesConfigMapFile string
infraConfigFile string
infraImage string
releaseImage string
keepalivedImage string
kubeCAFile string
mcoImage string
oauthProxyImage string
networkConfigFile string
oscontentImage string
pullSecretFile string
rootCAFile string
proxyConfigFile string
additionalTrustBundleFile string
dnsConfigFile string
}
)
func init() {
rootCmd.AddCommand(bootstrapCmd)
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.rootCAFile, "root-ca", "/etc/ssl/kubernetes/ca.crt", "path to root CA certificate")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.kubeCAFile, "kube-ca", "", "path to kube-apiserver serving-ca bundle")
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.MarkFlagRequired("dest-dir")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.mcoImage, "machine-config-operator-image", "", "Image for Machine Config Operator.")
bootstrapCmd.MarkFlagRequired("machine-config-operator-image")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.oscontentImage, "machine-config-oscontent-image", "", "Image for osImageURL")
bootstrapCmd.MarkFlagRequired("machine-config-oscontent-image")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.infraImage, "infra-image", "", "Image for Infra Containers.")
bootstrapCmd.MarkFlagRequired("infra-image")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.releaseImage, "release-image", "", "Release image used for cluster installation.")
bootstrapCmd.MarkFlagRequired("release-image")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.configFile, "config-file", "", "ClusterConfig ConfigMap file.")
bootstrapCmd.MarkFlagRequired("config-file")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.infraConfigFile, "infra-config-file", "/assets/manifests/cluster-infrastructure-02-config.yml", "File containing infrastructure.config.openshift.io manifest.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.networkConfigFile, "network-config-file", "/assets/manifests/cluster-network-02-config.yml", "File containing network.config.openshift.io manifest.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.cloudConfigFile, "cloud-config-file", "", "File containing the config map that contains the cloud config for cloudprovider.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.proxyConfigFile, "proxy-config-file", "/assets/manifests/cluster-proxy-01-config.yaml", "File containing proxy.config.openshift.io manifest.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.dnsConfigFile, "dns-config-file", "/assets/manifests/cluster-dns-02-config.yml", "File containing dns.config.openshift.io manifest.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.additionalTrustBundleFile, "additional-trust-bundle-config-file", "/assets/manifests/user-ca-bundle-config.yaml", "File containing the additional user provided CA bundle manifest.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.keepalivedImage, "keepalived-image", "", "Image for Keepalived.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.corednsImage, "coredns-image", "", "Image for CoreDNS.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.haproxyImage, "haproxy-image", "", "Image for haproxy.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.baremetalRuntimeCfgImage, "baremetal-runtimecfg-image", "", "Image for baremetal-runtimecfg.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.oauthProxyImage, "oauth-proxy-image", "", "Image for origin oauth proxy.")
bootstrapCmd.PersistentFlags().StringVar(&bootstrapOpts.cloudProviderCAFile, "cloud-provider-ca-file", "", "path to cloud provider CA certificate")
}
func runBootstrapCmd(cmd *cobra.Command, args []string) {
flag.Set("logtostderr", "true")
flag.Parse()
// To help debugging, immediately log version
glog.Infof("Version: %+v (%s)", version.Raw, version.Hash)
imgs := operator.Images{
RenderConfigImages: operator.RenderConfigImages{
MachineConfigOperator: bootstrapOpts.mcoImage,
MachineOSContent: bootstrapOpts.oscontentImage,
KeepalivedBootstrap: bootstrapOpts.keepalivedImage,
CorednsBootstrap: bootstrapOpts.corednsImage,
BaremetalRuntimeCfgBootstrap: bootstrapOpts.baremetalRuntimeCfgImage,
OauthProxy: bootstrapOpts.oauthProxyImage,
},
ControllerConfigImages: operator.ControllerConfigImages{
InfraImage: bootstrapOpts.infraImage,
Keepalived: bootstrapOpts.keepalivedImage,
Coredns: bootstrapOpts.corednsImage,
Haproxy: bootstrapOpts.haproxyImage,
BaremetalRuntimeCfg: bootstrapOpts.baremetalRuntimeCfgImage,
},
}
if err := operator.RenderBootstrap(
bootstrapOpts.additionalTrustBundleFile,
bootstrapOpts.proxyConfigFile,
bootstrapOpts.configFile,
bootstrapOpts.infraConfigFile,
bootstrapOpts.networkConfigFile,
bootstrapOpts.dnsConfigFile,
bootstrapOpts.cloudConfigFile,
bootstrapOpts.cloudProviderCAFile,
bootstrapOpts.rootCAFile, bootstrapOpts.kubeCAFile, bootstrapOpts.pullSecretFile,
&imgs,
bootstrapOpts.destinationDir,
bootstrapOpts.releaseImage,
); err != nil {
glog.Fatalf("error rendering bootstrap manifests: %v", err)
}
}