-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add a config.openshift.io/Infrastructure instance to the cluster
#943
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| apiVersion: apiextensions.k8s.io/v1beta1 | ||
| kind: CustomResourceDefinition | ||
| metadata: | ||
| name: infrastructures.config.openshift.io | ||
| spec: | ||
| group: config.openshift.io | ||
| names: | ||
| kind: Infrastructure | ||
| listKind: InfrastructureList | ||
| plural: infrastructures | ||
| singular: infrastructure | ||
| scope: Cluster | ||
| versions: | ||
| - name: v1 | ||
| served: true | ||
| storage: true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| package manifests | ||
|
|
||
| import ( | ||
| "path/filepath" | ||
|
|
||
| "github.com/ghodss/yaml" | ||
| "github.com/pkg/errors" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/installconfig" | ||
| "github.com/openshift/installer/pkg/asset/templates/content/openshift" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| "github.com/openshift/installer/pkg/types/aws" | ||
| "github.com/openshift/installer/pkg/types/libvirt" | ||
| "github.com/openshift/installer/pkg/types/none" | ||
| "github.com/openshift/installer/pkg/types/openstack" | ||
| ) | ||
|
|
||
| var ( | ||
| infraCrdFilename = filepath.Join(manifestDir, "cluster-infrastructure-01-crd.yaml") | ||
| infraCfgFilename = filepath.Join(manifestDir, "cluster-infrastructure-02-config.yml") | ||
| ) | ||
|
|
||
| // Infrastructure generates the cluster-infrastructure-*.yml files. | ||
| type Infrastructure struct { | ||
| FileList []*asset.File | ||
| } | ||
|
|
||
| var _ asset.WritableAsset = (*Infrastructure)(nil) | ||
|
|
||
| // Name returns a human friendly name for the asset. | ||
| func (*Infrastructure) Name() string { | ||
| return "Infrastructure Config" | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed to generate | ||
| // the asset. | ||
| func (*Infrastructure) Dependencies() []asset.Asset { | ||
| return []asset.Asset{ | ||
| &installconfig.InstallConfig{}, | ||
| &openshift.InfrastructureCRD{}, | ||
| } | ||
| } | ||
|
|
||
| // Generate generates the Infrastructure config and its CRD. | ||
| func (i *Infrastructure) Generate(dependencies asset.Parents) error { | ||
| installConfig := &installconfig.InstallConfig{} | ||
| infra := &openshift.InfrastructureCRD{} | ||
| dependencies.Get(installConfig, infra) | ||
|
|
||
| var platform configv1.PlatformType | ||
| switch installConfig.Config.Platform.Name() { | ||
| case aws.Name: | ||
| platform = configv1.AWSPlatform | ||
| case none.Name: | ||
| platform = configv1.NonePlatform | ||
| case libvirt.Name: | ||
| platform = configv1.LibvirtPlatform | ||
| case openstack.Name: | ||
| platform = configv1.OpenStackPlatform | ||
| default: | ||
| platform = configv1.NonePlatform | ||
| } | ||
|
|
||
| config := &configv1.Infrastructure{ | ||
| TypeMeta: metav1.TypeMeta{ | ||
| APIVersion: configv1.SchemeGroupVersion.String(), | ||
| Kind: "Infrastructure", | ||
| }, | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "cluster", | ||
| // not namespaced | ||
| }, | ||
| Status: configv1.InfrastructureStatus{ | ||
| Platform: platform, | ||
| }, | ||
| } | ||
|
|
||
| configData, err := yaml.Marshal(config) | ||
| if err != nil { | ||
| return errors.Wrapf(err, "failed to marshal config: %#v", config) | ||
| } | ||
|
|
||
| i.FileList = []*asset.File{ | ||
| { | ||
| Filename: infraCrdFilename, | ||
| Data: []byte(infra.Files()[0].Data), | ||
| }, | ||
| { | ||
| Filename: infraCfgFilename, | ||
| Data: configData, | ||
| }, | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (i *Infrastructure) Files() []*asset.File { | ||
| return i.FileList | ||
| } | ||
|
|
||
| // Load returns false since this asset is not written to disk by the installer. | ||
| func (i *Infrastructure) Load(f asset.FileFetcher) (bool, error) { | ||
|
||
| return false, nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package openshift | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/openshift/installer/pkg/asset" | ||
| "github.com/openshift/installer/pkg/asset/templates/content" | ||
| ) | ||
|
|
||
| const ( | ||
| infraCRDfilename = "cluster-infrastructure-crd.yaml" | ||
| ) | ||
|
|
||
| var _ asset.WritableAsset = (*InfrastructureCRD)(nil) | ||
|
|
||
| // InfrastructureCRD is the custom resource definition for the openshift/api | ||
| // Infrastructure type. | ||
| type InfrastructureCRD struct { | ||
| fileName string | ||
| FileList []*asset.File | ||
| } | ||
|
|
||
| // Dependencies returns all of the dependencies directly needed by the asset | ||
| func (t *InfrastructureCRD) Dependencies() []asset.Asset { | ||
| return []asset.Asset{} | ||
| } | ||
|
|
||
| // Name returns the human-friendly name of the asset. | ||
| func (t *InfrastructureCRD) Name() string { | ||
| return "Infrastructure" | ||
| } | ||
|
|
||
| // Generate generates the actual files by this asset | ||
| func (t *InfrastructureCRD) Generate(parents asset.Parents) error { | ||
| t.fileName = infraCRDfilename | ||
| data, err := content.GetOpenshiftTemplate(t.fileName) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| t.FileList = []*asset.File{ | ||
| { | ||
| Filename: filepath.Join(content.TemplateDir, t.fileName), | ||
| Data: []byte(data), | ||
| }, | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // Files returns the files generated by the asset. | ||
| func (t *InfrastructureCRD) Files() []*asset.File { | ||
| return t.FileList | ||
| } | ||
|
|
||
| // Load returns the asset from disk. | ||
| func (t *InfrastructureCRD) Load(f asset.FileFetcher) (bool, error) { | ||
| file, err := f.FetchByName(filepath.Join(content.TemplateDir, infraCRDfilename)) | ||
| if err != nil { | ||
| if os.IsNotExist(err) { | ||
| return false, nil | ||
| } | ||
| return false, err | ||
| } | ||
| t.FileList = []*asset.File{file} | ||
| return true, nil | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.