-
Notifications
You must be signed in to change notification settings - Fork 88
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
Configure routing subdomain #51
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ import ( | |
"reflect" | ||
"time" | ||
|
||
"github.com/ghodss/yaml" | ||
|
||
"github.com/golang/glog" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
|
@@ -30,8 +32,9 @@ import ( | |
) | ||
|
||
type Listers struct { | ||
imageConfigLister configlistersv1.ImageLister | ||
endpointLister corelistersv1.EndpointsLister | ||
imageConfigLister configlistersv1.ImageLister | ||
endpointLister corelistersv1.EndpointsLister | ||
clusterConfigLister corelistersv1.ConfigMapLister | ||
} | ||
|
||
type observeConfigFunc func(Listers, map[string]interface{}) (map[string]interface{}, error) | ||
|
@@ -46,6 +49,7 @@ type ConfigObserver struct { | |
|
||
operatorConfigSynced cache.InformerSynced | ||
endpointSynced cache.InformerSynced | ||
clusterConfigSynced cache.InformerSynced | ||
configImageSynced cache.InformerSynced | ||
|
||
rateLimiter flowcontrol.RateLimiter | ||
|
@@ -55,6 +59,7 @@ type ConfigObserver struct { | |
func NewConfigObserver( | ||
operatorConfigInformer operatorconfiginformerv1alpha1.OpenShiftAPIServerOperatorConfigInformer, | ||
kubeInformersForEtcdNamespace kubeinformers.SharedInformerFactory, | ||
kubeInformersForClusterConfigNamespace kubeinformers.SharedInformerFactory, | ||
imageConfigInformer imageconfiginformers.SharedInformerFactory, | ||
operatorConfigClient operatorconfigclientv1alpha1.OpenshiftapiserverV1alpha1Interface, | ||
) *ConfigObserver { | ||
|
@@ -67,19 +72,23 @@ func NewConfigObserver( | |
observers: []observeConfigFunc{ | ||
observeEtcdEndpoints, | ||
observeInternalRegistryHostname, | ||
observeRoutingSubdomain, | ||
}, | ||
listers: Listers{ | ||
imageConfigLister: imageConfigInformer.Config().V1().Images().Lister(), | ||
endpointLister: kubeInformersForEtcdNamespace.Core().V1().Endpoints().Lister(), | ||
imageConfigLister: imageConfigInformer.Config().V1().Images().Lister(), | ||
endpointLister: kubeInformersForClusterConfigNamespace.Core().V1().Endpoints().Lister(), | ||
clusterConfigLister: kubeInformersForClusterConfigNamespace.Core().V1().ConfigMaps().Lister(), | ||
}, | ||
} | ||
|
||
c.operatorConfigSynced = operatorConfigInformer.Informer().HasSynced | ||
c.endpointSynced = kubeInformersForEtcdNamespace.Core().V1().Endpoints().Informer().HasSynced | ||
c.clusterConfigSynced = kubeInformersForClusterConfigNamespace.Core().V1().Endpoints().Informer().HasSynced | ||
c.configImageSynced = imageConfigInformer.Config().V1().Images().Informer().HasSynced | ||
|
||
operatorConfigInformer.Informer().AddEventHandler(c.eventHandler()) | ||
kubeInformersForEtcdNamespace.Core().V1().ConfigMaps().Informer().AddEventHandler(c.eventHandler()) | ||
kubeInformersForClusterConfigNamespace.Core().V1().ConfigMaps().Informer().AddEventHandler(c.eventHandler()) | ||
imageConfigInformer.Config().V1().Images().Informer().AddEventHandler(c.eventHandler()) | ||
|
||
return c | ||
|
@@ -157,6 +166,42 @@ func observeInternalRegistryHostname(listers Listers, observedConfig map[string] | |
return observedConfig, nil | ||
} | ||
|
||
func observeRoutingSubdomain(listers Listers, observedConfig map[string]interface{}) (map[string]interface{}, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sanchezl figure out what state this config observation is in to finish this review |
||
// TODO: Get the value for routingConfig.subdomain from global config or | ||
// from a ClusterIngress resource instead of from the install config. | ||
clusterConfig, err := listers.clusterConfigLister.ConfigMaps(clusterConfigNamespaceName).Get(clusterConfigName) | ||
if errors.IsNotFound(err) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. glog a warning |
||
return observedConfig, nil | ||
} | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
if clusterConfig != nil { | ||
if installConfig, ok := clusterConfig.Data["install-config"]; ok { | ||
type InstallConfigMetadata struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, don't defined a schema here. use the unstructured helpers like the rest |
||
Name string `json:"name"` | ||
} | ||
|
||
type InstallConfig struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no. Use the usntructured helpers |
||
Metadata InstallConfigMetadata `json:"metadata"` | ||
BaseDomain string `json:"baseDomain"` | ||
} | ||
|
||
var config InstallConfig | ||
if err := yaml.Unmarshal([]byte(installConfig), &config); err != nil { | ||
return nil, fmt.Errorf("invalid InstallConfig: %v\njson:\n%s", err, installConfig) | ||
} | ||
|
||
subdomain := fmt.Sprintf("apps.%s.%s", config.Metadata.Name, config.BaseDomain) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? 😁 We have outstanding work to pull this out to cluster config one way or another. |
||
|
||
unstructured.SetNestedField(observedConfig, subdomain, "routingConfig", "subdomain") | ||
} | ||
} | ||
|
||
return observedConfig, nil | ||
} | ||
|
||
func (c *ConfigObserver) Run(workers int, stopCh <-chan struct{}) { | ||
defer utilruntime.HandleCrash() | ||
defer c.queue.ShutDown() | ||
|
@@ -167,6 +212,7 @@ func (c *ConfigObserver) Run(workers int, stopCh <-chan struct{}) { | |
cache.WaitForCacheSync(stopCh, | ||
c.operatorConfigSynced, | ||
c.endpointSynced, | ||
c.clusterConfigSynced, | ||
c.configImageSynced, | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ForKubeSystem if you would