Skip to content
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

add kube-apiserver wiring #20578

Merged

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Aug 8, 2018

@sttts I've come around. This is where my head's at. Not pretty, but I think we can fit most everything into those two spots.

  • OAuth server (but not backing APIs)
  • /.well-known
  • Our authenticator (oauth tokens via loopback)
  • Our authorizer (scopes, browser-safe, deny?)
  • Our admission
    • initializers
      • clients/informers for openshift APIs
    • namespace filters
    • our ordered list
    • externalippluginname
    • restrictedendpointsplugin
  • SCC
  • Non-standard etcd storage paths (APIService, others?) UPSTREAM: <carry>: patch in a non-standard location for apiservices #20719

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 8, 2018
@deads2k
Copy link
Contributor Author

deads2k commented Aug 8, 2018

/retest

@sttts
Copy link
Contributor

sttts commented Aug 9, 2018

Commented on the follow-up PR.

@@ -164,6 +164,10 @@ func CreateServerChain(completedOptions completedServerRunOptions, stopCh <-chan
return nil, err
}

if err := PatchKubeAPIServerConfig(kubeAPIServerConfig, sharedInformers, versionedInformers, &pluginInitializer); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch from 35dcbe2 to f9b0ce8 Compare August 9, 2018 17:09
@deads2k
Copy link
Contributor Author

deads2k commented Aug 9, 2018

@liggitt I plan to kill the limitsecretreferences option. Any objection to just straight out removing it? I don't think anyone uses it.

@liggitt
Copy link
Contributor

liggitt commented Aug 9, 2018

@liggitt I plan to kill the limitsecretreferences option. Any objection to just straight out removing it? I don't think anyone uses it.

no objection

@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch 2 times, most recently from 470fdac to db4e9a2 Compare August 17, 2018 13:28
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 17, 2018
@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch from db4e9a2 to d9dde2e Compare August 17, 2018 19:57
func BuildHandlerChain(genericConfig *genericapiserver.Config, kubeInformers informers.SharedInformerFactory, kubeAPIServerConfig *configapi.MasterConfig, stopCh <-chan struct{}) (func(apiHandler http.Handler, kc *genericapiserver.Config) http.Handler, map[string]genericapiserver.PostStartHookFunc, error) {
webconsoleProxyHandler, err := newWebConsoleProxy(genericConfig, kubeInformers, kubeAPIServerConfig)
func BuildHandlerChain(genericConfig *genericapiserver.Config, kubeInformers informers.SharedInformerFactory, kubeAPIServerConfig *configapi.MasterConfig) (func(apiHandler http.Handler, kc *genericapiserver.Config) http.Handler, map[string]genericapiserver.PostStartHookFunc, error) {
extraPostStarkHooks := map[string]genericapiserver.PostStartHookFunc{}
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: start

@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch from d9dde2e to 107c2d1 Compare August 20, 2018 18:24
@openshift-ci-robot openshift-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 20, 2018
@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch 2 times, most recently from 2f21baf to 4480027 Compare August 21, 2018 17:40
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch from 28b9c41 to 28b885a Compare August 21, 2018 21:01
@deads2k deads2k changed the title [WIP] add kube-apiserver wiring add kube-apiserver wiring Aug 21, 2018
@deads2k
Copy link
Contributor Author

deads2k commented Aug 21, 2018

@sttts this is ready for a real review. We can bring in the old SCC as a later step for cluster up

@deads2k
Copy link
Contributor Author

deads2k commented Aug 21, 2018

@smarterclayton in 4.0 are we ready to drop SCC in /api/v1? If so (and I think we should), I'd like to drop it from cluster up in 3.11.

@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch from 28b885a to 1d2c1a7 Compare August 22, 2018 12:12
@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 22, 2018
return nil, err
}

// these flags are overridden by a patch
Copy link
Contributor

Choose a reason for hiding this comment

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

who maintains this list? not sure of the value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

who maintains this list? not sure of the value

We need this list so that we can create a struct to represent it in order to manage it. We'll need to write a test of some sort to make sure we don't lose them.

setIfUnset(args, "secure-port", portString)

var keys []string
for key := range args {
Copy link
Contributor

Choose a reason for hiding this comment

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

keys := append([]string(nil), args...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

keys := append([]string(nil), args...)

args is a map

return nil, err
}
// if the config isn't a DefaultAdmissionConfig, then assume we're enabled (we were called after all)
// if the config *is* a DefaultAdmissionConfig and it explicitly said
Copy link
Contributor

Choose a reason for hiding this comment

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

"it explicitly said" ?


} else if defaultConfig.Disable {
forceOff = append(forceOff, pluginName)
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for the continues if "else" is used.

tempFile.Close()

setIfUnset(args, "admission-control-config-file", tempFile.Name())
setIfUnset(args, "disable-admission-plugins", forceOff...)
Copy link
Contributor

Choose a reason for hiding this comment

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

these are additive to the default values. Maybe we should append?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are additive to the default values. Maybe we should append?

We've always stomped admission with our choices. I only want one way to set via config.

@@ -1,23 +1,27 @@
package openshiftkubeapiserver

import (
"github.com/openshift/origin/pkg/admission/namespaceconditions"
Copy link
Contributor

Choose a reason for hiding this comment

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

Goland still hasn't learned our import order.

if err != nil {
return nil, err
}
clusterQuotaMappingController := openshiftapiserver.NewClusterQuotaMappingController(kubeAPIServerInformers.InternalKubernetesInformers.Core().InternalVersion().Namespaces(), kubeAPIServerInformers.InternalOpenshiftQuotaInformers.Quota().InternalVersion().ClusterResourceQuotas())
kubeClient, err := kubernetes.NewForConfig(config.GenericConfig.LoopbackClientConfig)
patchContext.postStartHooks["quota.openshift.io-clusterquotamapping"] = func(context genericapiserver.PostStartHookContext) error {
go clusterQuotaMappingController.Run(5, context.StopCh)
Copy link
Contributor

Choose a reason for hiding this comment

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

any deeper reason why this is now a post start hook and not a plugin initializer?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any deeper reason why this is now a post start hook and not a plugin initializer?

There's a controller piece that neesd to run

@@ -137,15 +171,6 @@ func (c *KubeAPIServerServerPatchContext) PatchServer(server *master.Master) err
}
return nil
})
server.GenericAPIServer.AddPostStartHookOrDie("openshift.io-restmapperupdater", func(context genericapiserver.PostStartHookContext) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this gone? Why don't we need that anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where is this gone? Why don't we need that anymore?

we use the upstream restmapper now.


return func(apiHandler http.Handler, genericConfig *genericapiserver.Config) http.Handler {
// Machinery that let's use discover the Web Console Public URL
accessor := newWebConsolePublicURLAccessor(genericConfig.LoopbackClientConfig)
go accessor.Run(stopCh)
extraPostStartHooks["openshift.io-webconsolepublicurl"] = func(context genericapiserver.PostStartHookContext) error {
Copy link
Contributor

@sttts sttts Aug 22, 2018

Choose a reason for hiding this comment

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

this is (and was) dirty and deserves a big, bold explanation why we do this here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is (and was) dirty and deserves a big, bold explanation why we do this here.

No worse than before, but I can comment it.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 22, 2018

comments addressed in a separate commit.

bootstrappolicy.ClusterRoles = bootstrappolicy.OpenshiftClusterRoles
bootstrappolicy.ClusterRoleBindings = bootstrappolicy.OpenshiftClusterRoleBindings

options.AllOrderedPlugins = originadmission.CombinedAdmissionControlPlugins
Copy link
Contributor

Choose a reason for hiding this comment

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

ugly to override global slice vars meant as constants. But I guess we have no choice.

Copy link
Contributor

Choose a reason for hiding this comment

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

a carry patch might be more explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a carry patch might be more explicit.

doing so doesn't allow running in both modes and exposes us to greater conflicts

@@ -78,7 +79,8 @@ func createAggregatorConfig(
// copy the etcd options so we don't mutate originals.
etcdOptions := *commandOptions.Etcd
etcdOptions.StorageConfig.Codec = aggregatorscheme.Codecs.LegacyCodec(v1beta1.SchemeGroupVersion, v1.SchemeGroupVersion)
genericConfig.RESTOptionsGetter = &genericoptions.SimpleRestOptionsFactory{Options: etcdOptions}
aggregatorinstall.Install(legacyscheme.Scheme)
//genericConfig.RESTOptionsGetter = &genericoptions.SimpleRestOptionsFactory{Options: etcdOptions}
Copy link
Contributor

Choose a reason for hiding this comment

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

why? This needs a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why? This needs a comment

added

@@ -30,6 +30,10 @@ import (
"k8s.io/kubernetes/cmd/kube-apiserver/app/options"
)

func createAPIExtensionsServer(apiextensionsConfig *apiextensionsapiserver.Config, delegateAPIServer genericapiserver.DelegationTarget) (*apiextensionsapiserver.CustomResourceDefinitions, error) {
return apiextensionsConfig.Complete().New(delegateAPIServer)
Copy link
Contributor

Choose a reason for hiding this comment

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

If I trust my eyes, this is only an (unnecessary) move?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I trust my eyes, this is only an (unnecessary) move?

fixed

@@ -179,6 +179,9 @@ func CreateServerChain(completedOptions completedServerRunOptions, stopCh <-chan
return nil, err
}

if err := PatchKubeAPIServerServer(kubeAPIServer); err != nil {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

drop if or handle error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

drop if or handle error

fixed

@@ -634,6 +634,8 @@ func BuildStorageFactory(s *options.ServerRunOptions, apiResourceConfig *servers
return nil, fmt.Errorf("error in initializing storage factory: %s", err)
}

storageFactory.SetResourceEtcdPrefix(schema.GroupResource{Group: "apiregistration.k8s.io", Resource: "apiservices"}, "apiservices")
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the history of this? Did we ship an earlier version with a wrong etcd path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's the history of this? Did we ship an earlier version with a wrong etcd path?

Yes, in 3.6

@deads2k deads2k force-pushed the server-13-split-kubeapiserver branch from f10076b to 5e13f18 Compare August 22, 2018 13:58
@sttts
Copy link
Contributor

sttts commented Aug 22, 2018

Still quite some ugly hacks. But it's a good step into the right direction 👍

@deads2k deads2k added the lgtm Indicates that a PR is ready to be merged. label Aug 22, 2018
@deads2k
Copy link
Contributor Author

deads2k commented Aug 22, 2018

/retest

1 similar comment
@deads2k
Copy link
Contributor Author

deads2k commented Aug 22, 2018

/retest

@openshift-merge-robot openshift-merge-robot merged commit 7840b4d into openshift:master Aug 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants