1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 06:46:36 +01:00

Merge pull request #934 from ironcladlou/basedomain

Add asset for DNS config
This commit is contained in:
OpenShift Merge Robot
2018-12-18 22:35:54 -08:00
committed by GitHub
8 changed files with 153 additions and 9 deletions

5
Gopkg.lock generated
View File

@@ -364,15 +364,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"

View File

@@ -81,8 +81,8 @@ ignored = [
revision = "34f5991525d116b3832e0d9409492274f1c06bda"
[[constraint]]
branch = "master"
name = "github.com/openshift/api"
revision = "8241b16bb46fe9bd7aebbbce92d7af84fb71be7f"
[[constraint]]
name = "github.com/openshift/client-go"

View File

@@ -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

121
pkg/asset/manifests/dns.go Normal file
View File

@@ -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
}

View File

@@ -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

View File

@@ -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"`
}

View File

@@ -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 {

View File

@@ -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.",
}