Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Merge branch 'pr/1322'
Browse files Browse the repository at this point in the history
LGTM from:
duglin
staebler
MHBauer
  • Loading branch information
MHBauer committed Oct 4, 2017
2 parents d337ec4 + 6fb9fe8 commit f6eac6e
Show file tree
Hide file tree
Showing 45 changed files with 35 additions and 4,135 deletions.
3 changes: 1 addition & 2 deletions charts/catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ chart and their default values.
| `apiserver.tls.requestHeaderCA` | Base64-encoded CA used to validate request-header authentication, when receiving delegated authentication from an aggregator | *none (will disable requestheader authentication)* |
| `apiserver.service.type` | Type of service; valid values are `LoadBalancer` and `NodePort` | `NodePort` |
| `apiserver.service.nodePort.securePort` | If service type is `NodePort`, specifies a port in allowable range (e.g. 30000 - 32767 on minikube); The TLS-enabled endpoint will be exposed here | `30443` |
| `apiserver.storage.type` | The storage backend to use; valid values are `etcd` and `tpr` | `etcd` |
| `apiserver.storage.type` | The storage backend to use; the only valid value is `etcd`, left for other storages support in future, e.g. `crd` | `etcd` |
| `apiserver.storage.etcd.useEmbedded` | If storage type is `etcd`: Whether to embed an etcd container in the apiserver pod; THIS IS INADEQUATE FOR PRODUCTION USE! | `true` |
| `apiserver.storage.etcd.servers` | If storage type is `etcd`: etcd URL(s); override this if NOT using embedded etcd | `http://localhost:2379` |
| `apiserver.storage.tpr.globalNamespace` | If storage type is `tpr`: Some service catalog resources are not namespaced, but third party resources must be; setting this designates a namespace that will be treated as a container for such resources | `servicecatalog` |
| `apiserver.verbosity` | Log level; valid values are in the range 0 - 10 | `10` |
| `apiserver.auth.enabled` | Enable authentication and authorization | `false` |
| `controllerManager.image` | controller-manager image to use | `quay.io/kubernetes-service-catalog/controller-manager:v0.0.22` |
Expand Down
3 changes: 0 additions & 3 deletions charts/catalog/templates/apiserver-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ spec:
{{- if eq .Values.apiserver.storage.type "etcd" }}
- --etcd-servers
- {{ .Values.apiserver.storage.etcd.servers }}
{{- else if eq .Values.apiserver.storage.type "tpr" }}
- --global-namespace
- {{ .Values.apiserver.storage.tpr.globalNamespace }}
{{- end }}
- -v
- "{{ .Values.apiserver.verbosity }}"
Expand Down
8 changes: 2 additions & 6 deletions charts/catalog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ apiserver:
# The TLS-enabled endpoint will be exposed here
securePort: 30443
storage:
# The storage backend to use; valid values are "etcd" and "tpr"
# The storage backend to use; the only valid value is "etcd"
# (left for "crd" support in future)
type: etcd
# Further configuration for the etcd-based backend
etcd:
Expand All @@ -52,11 +53,6 @@ apiserver:
useEmbedded: true
# etcd URL(s); override this if NOT using embedded etcd
servers: http://localhost:2379
tpr:
# Some service catalog resources are not namespaced, but third party
# resources must be; setting this designates a namespace that will be
# treated as a container for such resources
globalNamespace: servicecatalog
# Log level; valid values are in the range 0 - 10
verbosity: 10
auth:
Expand Down
6 changes: 1 addition & 5 deletions cmd/apiserver/app/server/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ type ServiceCatalogServerOptions struct {
AuditOptions *genericserveroptions.AuditOptions
// EtcdOptions are options for serving with etcd as the backing store
EtcdOptions *EtcdOptions
// TPROptions are options for serving with TPR as the backing store
TPROptions *TPROptions
// DisableAuth disables delegating authentication and authorization for testing scenarios
DisableAuth bool
StopCh <-chan struct{}
Expand All @@ -65,7 +63,6 @@ func NewServiceCatalogServerOptions() *ServiceCatalogServerOptions {
AuthorizationOptions: genericserveroptions.NewDelegatingAuthorizationOptions(),
AuditOptions: genericserveroptions.NewAuditOptions(),
EtcdOptions: NewEtcdOptions(),
TPROptions: NewTPROptions(),
}
}

Expand All @@ -90,7 +87,6 @@ func (s *ServiceCatalogServerOptions) addFlags(flags *pflag.FlagSet) {
s.AuthenticationOptions.AddFlags(flags)
s.AuthorizationOptions.AddFlags(flags)
s.EtcdOptions.addFlags(flags)
s.TPROptions.addFlags(flags)
s.AuditOptions.AddFlags(flags)
}

Expand Down Expand Up @@ -119,7 +115,7 @@ func (s *ServiceCatalogServerOptions) Validate() error {
errors = append(errors, etcdErrs...)
}
// TODO add alternative storage validation
// errors = append(errors, s.TPROptions.Validate()...)
// errors = append(errors, s.CRDOptions.Validate()...)
// TODO uncomment after 1.8 rebase expecting
// https://github.com/kubernetes/kubernetes/pull/47043
// errors = append(errors, s.AuditOptions.Validate()...)
Expand Down
54 changes: 4 additions & 50 deletions cmd/apiserver/app/server/run_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@ import (

"github.com/kubernetes-incubator/service-catalog/pkg/api"
genericapiserverstorage "k8s.io/apiserver/pkg/server/storage"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/cmd/kube-apiserver/app/preflight"

"github.com/golang/glog"
"github.com/kubernetes-incubator/service-catalog/pkg/apiserver"
"github.com/kubernetes-incubator/service-catalog/pkg/apiserver/options"
"github.com/kubernetes-incubator/service-catalog/pkg/registry/servicecatalog/server"
"github.com/kubernetes-incubator/service-catalog/pkg/storage/tpr"
)

// RunServer runs an API server with configuration according to opts
Expand All @@ -49,55 +47,11 @@ func RunServer(opts *ServiceCatalogServerOptions) error {
return err
}

if storageType == server.StorageTypeTPR {
return runTPRServer(opts)
if storageType == server.StorageTypeEtcd {
return runEtcdServer(opts)
}
return runEtcdServer(opts)
}

func installTPRsToCore(cl clientset.Interface) func() error {
return func() error {
if err := tpr.InstallTypes(cl.Extensions().ThirdPartyResources()); err != nil {
glog.Errorf("Failed to install TPR types (%s)", err)
return err
}
return nil
}
}

func runTPRServer(opts *ServiceCatalogServerOptions) error {
tprOpts := opts.TPROptions
glog.Infoln("Installing TPR types to the cluster")
if err := tprOpts.InstallTPRsFunc(); err != nil {
glog.V(4).Infof("Installing TPR types failed, continuing anyway (%s)", err)
return err
}

glog.V(4).Infoln("Preparing to run API server")
genericConfig, scConfig, err := buildGenericConfig(opts)
if err != nil {
return err
}

config := apiserver.NewTPRConfig(
tprOpts.RESTClient,
genericConfig,
tprOpts.GlobalNamespace,
tprOpts.storageFactory(),
)
completed := config.Complete()
// make the server
glog.V(4).Infoln("Completing API server configuration")
server, err := completed.NewServer()
if err != nil {
return fmt.Errorf("error completing API server configuration: %v", err)
}
addPostStartHooks(server.GenericAPIServer, scConfig, opts.StopCh)

glog.Infoln("Running the API server")
server.GenericAPIServer.PrepareRun().Run(opts.StopCh)

return nil
// This should never happen, catch for potential bugs
panic("Unexpected storage type: " + storageType)
}

func runEtcdServer(opts *ServiceCatalogServerOptions) error {
Expand Down
81 changes: 0 additions & 81 deletions cmd/apiserver/app/server/run_server_test.go

This file was deleted.

26 changes: 3 additions & 23 deletions cmd/apiserver/app/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ import (
"github.com/kubernetes-incubator/service-catalog/plugin/pkg/admission/serviceplan/changevalidator"
"github.com/kubernetes-incubator/service-catalog/plugin/pkg/admission/serviceplan/defaultserviceplan"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apiserver/pkg/admission"
genericserveroptions "k8s.io/apiserver/pkg/server/options"
clientset "k8s.io/client-go/kubernetes"
restclient "k8s.io/client-go/rest"
"k8s.io/kubernetes/pkg/util/interrupt"
)

Expand All @@ -51,8 +48,7 @@ const (
// GroupName I made this up. Maybe we'll need it.
GroupName = "service-catalog.k8s.io"

storageTypeFlagName = "storageType"
tprGlobalNamespaceName = "tprGlobalNamespace"
storageTypeFlagName = "storageType"
)

// NewCommandServer creates a new cobra command to run our server.
Expand All @@ -78,7 +74,6 @@ func NewCommandServer(
AuthorizationOptions: genericserveroptions.NewDelegatingAuthorizationOptions(),
AuditOptions: genericserveroptions.NewAuditOptions(),
EtcdOptions: NewEtcdOptions(),
TPROptions: NewTPROptions(),
StopCh: stopCh,
StandaloneMode: standaloneMode(),
}
Expand All @@ -104,23 +99,8 @@ func NewCommandServer(
// Store resources in etcd under our special prefix
opts.EtcdOptions.StorageConfig.Prefix = etcdPathPrefix
} else {
cfg, err := restclient.InClusterConfig()
if err != nil {
glog.Errorf("Failed to get kube client config (%s)", err)
return nil, err
}
cfg.GroupVersion = &schema.GroupVersion{}

clIface, err := clientset.NewForConfig(cfg)
if err != nil {
glog.Errorf("Failed to create clientset Interface (%s)", err)
return nil, err
}

glog.Infof("using third party resources for storage")
opts.TPROptions.DefaultGlobalNamespace = "servicecatalog"
opts.TPROptions.RESTClient = clIface.Core().RESTClient()
opts.TPROptions.InstallTPRsFunc = installTPRsToCore(clIface)
// This should never happen, catch for potential bugs
panic("Unexpected storage type: " + storageType)
}

cmd.Run = func(c *cobra.Command, args []string) {
Expand Down
57 changes: 0 additions & 57 deletions cmd/apiserver/app/server/tpr_options.go

This file was deleted.

6 changes: 0 additions & 6 deletions contrib/jenkins/install_catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ while [[ $# -gt 0 ]]; do
case "${1}" in
--registry) REGISTRY="${2:-}"; shift ;;
--version) VERSION="${2:-}"; shift ;;
--with-tpr) WITH_TPR=true ;;
--fix-auth) FIX_CONFIGMAP=true ;;
*) error_exit "Unrecognized command line parameter: $1" ;;
esac
Expand All @@ -33,7 +32,6 @@ done

REGISTRY="${REGISTRY:-}"
VERSION="${VERSION:-"canary"}"
WITH_TPR="${WITH_TPR:-false}"
FIX_CONFIGMAP="${FIX_CONFIGMAP:-false}"

CONTROLLER_MANAGER_IMAGE="${REGISTRY}controller-manager:${VERSION}"
Expand Down Expand Up @@ -66,10 +64,6 @@ VALUES+="controllerManager.image=${CONTROLLER_MANAGER_IMAGE}"
VALUES+=",apiserver.image=${APISERVER_IMAGE}"
VALUES+=",apiserver.service.type=NodePort"
VALUES+=",apiserver.service.nodePort.securePort=30443"
if [[ "${WITH_TPR}" == true ]]; then
VALUES+=',apiserver.storage.type=tpr'
VALUES+=',apiserver.storage.tpr.globalNamespace=test-ns'
fi

retry \
helm install "${ROOT}/charts/catalog" \
Expand Down
Loading

0 comments on commit f6eac6e

Please sign in to comment.