Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ignored = [

[[constraint]]
name = "github.com/openshift/api"
revision = "8241b16bb46fe9bd7aebbbce92d7af84fb71be7f"
revision = "aab033bae2a129607f4fb277c3777b2eabb08601"

[[constraint]]
name = "github.com/openshift/client-go"
Expand Down
16 changes: 16 additions & 0 deletions data/data/manifests/openshift/cluster-infrastructure-crd.yaml
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
109 changes: 109 additions & 0 deletions pkg/asset/manifests/infrastructure.go
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This asset should not be loadable. Its files will be loaded by the Common Manifests asset. For more context, see #877.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we may need to update the recent DNS config implementation for this too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll refactor DNS once this PR merges

return false, nil
}
5 changes: 4 additions & 1 deletion pkg/asset/manifests/operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (m *Manifests) Dependencies() []asset.Asset {
&installconfig.InstallConfig{},
&Ingress{},
&DNS{},
&Infrastructure{},
&Networking{},
&tls.RootCA{},
&tls.EtcdCA{},
Expand Down Expand Up @@ -88,8 +89,9 @@ func (m *Manifests) Generate(dependencies asset.Parents) error {
ingress := &Ingress{}
dns := &DNS{}
network := &Networking{}
infra := &Infrastructure{}
installConfig := &installconfig.InstallConfig{}
dependencies.Get(installConfig, ingress, dns, network)
dependencies.Get(installConfig, ingress, dns, network, infra)

// mao go to kube-system config map
m.KubeSysConfig = configMap("kube-system", "cluster-config-v1", genericData{
Expand All @@ -111,6 +113,7 @@ func (m *Manifests) Generate(dependencies asset.Parents) error {
m.FileList = append(m.FileList, ingress.Files()...)
m.FileList = append(m.FileList, dns.Files()...)
m.FileList = append(m.FileList, network.Files()...)
m.FileList = append(m.FileList, infra.Files()...)

return nil
}
Expand Down
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
}
6 changes: 5 additions & 1 deletion pkg/asset/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (m *Templates) Dependencies() []asset.Asset {
&openshift.CloudCredsSecret{},
&openshift.KubeadminPasswordSecret{},
&openshift.RoleCloudCredsSecretReader{},
&openshift.InfrastructureCRD{},
}
}

Expand All @@ -65,6 +66,7 @@ func (m *Templates) Generate(dependencies asset.Parents) error {
cloudCredsSecret := &openshift.CloudCredsSecret{}
kubeadminPasswordSecret := &openshift.KubeadminPasswordSecret{}
roleCloudCredsSecretReader := &openshift.RoleCloudCredsSecretReader{}
infrastructure := &openshift.InfrastructureCRD{}

dependencies.Get(
kubeCloudConfig,
Expand All @@ -84,7 +86,8 @@ func (m *Templates) Generate(dependencies asset.Parents) error {
bindingDiscovery,
cloudCredsSecret,
kubeadminPasswordSecret,
roleCloudCredsSecretReader)
roleCloudCredsSecretReader,
infrastructure)

m.FileList = []*asset.File{}
m.FileList = append(m.FileList, kubeCloudConfig.Files()...)
Expand All @@ -106,6 +109,7 @@ func (m *Templates) Generate(dependencies asset.Parents) error {
m.FileList = append(m.FileList, cloudCredsSecret.Files()...)
m.FileList = append(m.FileList, kubeadminPasswordSecret.Files()...)
m.FileList = append(m.FileList, roleCloudCredsSecretReader.Files()...)
m.FileList = append(m.FileList, infrastructure.Files()...)

return nil
}
Expand Down

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.

Loading