diff --git a/Gopkg.lock b/Gopkg.lock index b7d93f58a59..275b65d506c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -363,15 +363,14 @@ version = "1.0.1" [[projects]] - branch = "master" - digest = "1:8d0349ca7980bc787c8c595434618a5abc98076d07a50ca38c9a80685e70f80e" + digest = "1:68214731af5ff5a3bfab4d28571578e5522bc4f667ad1232745d7b4189ccb442" name = "github.com/openshift/api" packages = [ "config/v1", "route/v1", ] pruneopts = "NUT" - revision = "6a375c5bd37e0a30bf3da96935273fa41f957a0d" + revision = "8241b16bb46fe9bd7aebbbce92d7af84fb71be7f" [[projects]] digest = "1:6b1540f37963c713da08d8463791201d8469e8c755ed66a0b54ee424b15ea401" diff --git a/Gopkg.toml b/Gopkg.toml index 8c2604c9987..aeabc27297d 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -85,8 +85,8 @@ ignored = [ revision = "34f5991525d116b3832e0d9409492274f1c06bda" [[constraint]] - branch = "master" name = "github.com/openshift/api" + revision = "8241b16bb46fe9bd7aebbbce92d7af84fb71be7f" [[constraint]] name = "github.com/openshift/client-go" diff --git a/data/data/manifests/bootkube/cluster-dns-01-crd.yaml b/data/data/manifests/bootkube/cluster-dns-01-crd.yaml new file mode 100644 index 00000000000..b103f9f9b2c --- /dev/null +++ b/data/data/manifests/bootkube/cluster-dns-01-crd.yaml @@ -0,0 +1,16 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: dnses.config.openshift.io +spec: + group: config.openshift.io + names: + kind: DNS + listKind: DNSList + plural: dnses + singular: dns + scope: Cluster + versions: + - name: v1 + served: true + storage: true diff --git a/pkg/asset/manifests/dns.go b/pkg/asset/manifests/dns.go new file mode 100644 index 00000000000..ccfce56766b --- /dev/null +++ b/pkg/asset/manifests/dns.go @@ -0,0 +1,121 @@ +package manifests + +import ( + "os" + "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" + + configv1 "github.com/openshift/api/config/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var ( + dnsCrdFilename = "cluster-dns-01-crd.yaml" + dnsCfgFilename = filepath.Join(manifestDir, "cluster-dns-02-config.yml") +) + +// DNS generates the cluster-dns-*.yml files. +type DNS struct { + config *configv1.DNS + FileList []*asset.File +} + +var _ asset.WritableAsset = (*DNS)(nil) + +// Name returns a human friendly name for the asset. +func (*DNS) Name() string { + return "DNS Config" +} + +// Dependencies returns all of the dependencies directly needed to generate +// the asset. +func (*DNS) Dependencies() []asset.Asset { + return []asset.Asset{ + &installconfig.InstallConfig{}, + } +} + +// Generate generates the DNS config and its CRD. +func (d *DNS) Generate(dependencies asset.Parents) error { + installConfig := &installconfig.InstallConfig{} + dependencies.Get(installConfig) + + d.config = &configv1.DNS{ + TypeMeta: metav1.TypeMeta{ + APIVersion: configv1.SchemeGroupVersion.String(), + Kind: "DNS", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "cluster", + // not namespaced + }, + Spec: configv1.DNSSpec{ + BaseDomain: installConfig.Config.BaseDomain, + }, + } + + configData, err := yaml.Marshal(d.config) + if err != nil { + return errors.Wrapf(err, "failed to create %s manifests from InstallConfig", d.Name()) + } + + crdData, err := content.GetBootkubeTemplate(dnsCrdFilename) + if err != nil { + return err + } + + d.FileList = []*asset.File{ + { + Filename: filepath.Join(manifestDir, dnsCrdFilename), + Data: []byte(crdData), + }, + { + Filename: dnsCfgFilename, + Data: configData, + }, + } + + return nil +} + +// Files returns the files generated by the asset. +func (d *DNS) Files() []*asset.File { + return d.FileList +} + +// Load loads the already-rendered files back from disk. +func (d *DNS) Load(f asset.FileFetcher) (bool, error) { + crdFile, err := f.FetchByName(filepath.Join(manifestDir, dnsCrdFilename)) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + return false, err + } + + cfgFile, err := f.FetchByName(dnsCfgFilename) + if err != nil { + if os.IsNotExist(err) { + return false, nil + } + + return false, err + } + + dnsConfig := &configv1.DNS{} + if err := yaml.Unmarshal(cfgFile.Data, dnsConfig); err != nil { + return false, errors.Wrapf(err, "failed to unmarshal %s", dnsCfgFilename) + } + + fileList := []*asset.File{crdFile, cfgFile} + + d.FileList, d.config = fileList, dnsConfig + + return true, nil +} diff --git a/pkg/asset/manifests/operators.go b/pkg/asset/manifests/operators.go index 3d6e4cd060b..5444a1855ef 100644 --- a/pkg/asset/manifests/operators.go +++ b/pkg/asset/manifests/operators.go @@ -54,6 +54,7 @@ func (m *Manifests) Dependencies() []asset.Asset { return []asset.Asset{ &installconfig.InstallConfig{}, &Ingress{}, + &DNS{}, &Networking{}, &tls.RootCA{}, &tls.EtcdCA{}, @@ -85,9 +86,10 @@ func (m *Manifests) Dependencies() []asset.Asset { // Generate generates the respective operator config.yml files func (m *Manifests) Generate(dependencies asset.Parents) error { ingress := &Ingress{} + dns := &DNS{} network := &Networking{} installConfig := &installconfig.InstallConfig{} - dependencies.Get(installConfig, ingress, network) + dependencies.Get(installConfig, ingress, dns, network) // mao go to kube-system config map m.KubeSysConfig = configMap("kube-system", "cluster-config-v1", genericData{ @@ -107,6 +109,7 @@ func (m *Manifests) Generate(dependencies asset.Parents) error { m.FileList = append(m.FileList, m.generateBootKubeManifests(dependencies)...) m.FileList = append(m.FileList, ingress.Files()...) + m.FileList = append(m.FileList, dns.Files()...) m.FileList = append(m.FileList, network.Files()...) return nil diff --git a/vendor/github.com/openshift/api/config/v1/types.go b/vendor/github.com/openshift/api/config/v1/types.go index 370c265c08f..bfefb67d2f1 100644 --- a/vendor/github.com/openshift/api/config/v1/types.go +++ b/vendor/github.com/openshift/api/config/v1/types.go @@ -5,10 +5,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" ) -// ConfigMapReference references the location of a configmap. +// ConfigMapReference references a configmap in the openshift-config namespace. type ConfigMapReference struct { - Namespace string `json:"namespace"` - Name string `json:"name"` + Name string `json:"name"` // Key allows pointing to a specific key/value inside of the configmap. This is useful for logical file references. Key string `json:"filename,omitempty"` } diff --git a/vendor/github.com/openshift/api/config/v1/types_dns.go b/vendor/github.com/openshift/api/config/v1/types_dns.go index 44fa6e4d27d..c371895471b 100644 --- a/vendor/github.com/openshift/api/config/v1/types_dns.go +++ b/vendor/github.com/openshift/api/config/v1/types_dns.go @@ -20,6 +20,12 @@ type DNS struct { } type DNSSpec struct { + // baseDomain is the base domain of the cluster. All managed DNS records will + // be sub-domains of this base. + // + // For example, given the base domain `openshift.example.com`, an API server + // DNS record may be created for `cluster-api.openshift.example.com`. + BaseDomain string `json:"baseDomain"` } type DNSStatus struct { diff --git a/vendor/github.com/openshift/api/config/v1/types_swagger_doc_generated.go b/vendor/github.com/openshift/api/config/v1/types_swagger_doc_generated.go index 1fd8c16e8ac..8f433b01558 100644 --- a/vendor/github.com/openshift/api/config/v1/types_swagger_doc_generated.go +++ b/vendor/github.com/openshift/api/config/v1/types_swagger_doc_generated.go @@ -61,7 +61,7 @@ func (ClientConnectionOverrides) SwaggerDoc() map[string]string { } var map_ConfigMapReference = map[string]string{ - "": "ConfigMapReference references the location of a configmap.", + "": "ConfigMapReference references a configmap in the openshift-config namespace.", "filename": "Key allows pointing to a specific key/value inside of the configmap. This is useful for logical file references.", }