Skip to content

Commit ce28252

Browse files
staeblerpmorie
authored andcommitted
Combine apiserver and controller-manager into a single service-catalog image (#1343)
* Combine apiserver and controller-manager into a single service-catalog image. * Remove extraneous <<<< HEAD from pkg/kubernetes/README.md * Remove unused constants related to etcd storage
1 parent 7bbc8ee commit ce28252

30 files changed

+1098
-333
lines changed

Makefile

+19-41
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ BASE_PATH = $(ROOT:/src/github.com/kubernetes-incubator/service-catalog/=)
8080
export GOPATH = $(BASE_PATH):$(ROOT)/vendor
8181

8282
MUTABLE_TAG ?= canary
83-
APISERVER_IMAGE = $(REGISTRY)apiserver-$(ARCH):$(VERSION)
84-
APISERVER_MUTABLE_IMAGE = $(REGISTRY)apiserver-$(ARCH):$(MUTABLE_TAG)
85-
CONTROLLER_MANAGER_IMAGE = $(REGISTRY)controller-manager-$(ARCH):$(VERSION)
86-
CONTROLLER_MANAGER_MUTABLE_IMAGE = $(REGISTRY)controller-manager-$(ARCH):$(MUTABLE_TAG)
83+
SERVICE_CATALOG_IMAGE = $(REGISTRY)service-catalog-$(ARCH):$(VERSION)
84+
SERVICE_CATALOG_MUTABLE_IMAGE = $(REGISTRY)service-catalog-$(ARCH):$(MUTABLE_TAG)
8785
USER_BROKER_IMAGE = $(REGISTRY)user-broker-$(ARCH):$(VERSION)
8886
USER_BROKER_MUTABLE_IMAGE = $(REGISTRY)user-broker-$(ARCH):$(MUTABLE_TAG)
8987

@@ -111,11 +109,10 @@ NON_VENDOR_DIRS = $(shell $(DOCKER_CMD) glide nv)
111109

112110
# This section builds the output binaries.
113111
# Some will have dedicated targets to make it easier to type, for example
114-
# "apiserver" instead of "bin/apiserver".
112+
# "service-catalog" instead of "bin/service-catalog".
115113
#########################################################################
116114
build: .init .generate_files \
117-
$(BINDIR)/apiserver \
118-
$(BINDIR)/controller-manager \
115+
$(BINDIR)/service-catalog \
119116
$(BINDIR)/user-broker
120117

121118
user-broker: $(BINDIR)/user-broker
@@ -124,14 +121,10 @@ $(BINDIR)/user-broker: .init contrib/cmd/user-broker \
124121
$(shell find contrib/pkg/broker -type f)
125122
$(DOCKER_CMD) $(GO_BUILD) -o $@ $(SC_PKG)/contrib/cmd/user-broker
126123

127-
# We'll rebuild apiserver if any go file has changed (ie. NEWEST_GO_FILE)
128-
apiserver: $(BINDIR)/apiserver
129-
$(BINDIR)/apiserver: .init .generate_files cmd/apiserver $(NEWEST_GO_FILE)
130-
$(DOCKER_CMD) $(GO_BUILD) -o $@ $(SC_PKG)/cmd/apiserver
131-
132-
controller-manager: $(BINDIR)/controller-manager
133-
$(BINDIR)/controller-manager: .init .generate_files cmd/controller-manager $(NEWEST_GO_FILE)
134-
$(DOCKER_CMD) $(GO_BUILD) -o $@ $(SC_PKG)/cmd/controller-manager
124+
# We'll rebuild service-catalog if any go file has changed (ie. NEWEST_GO_FILE)
125+
service-catalog: $(BINDIR)/service-catalog
126+
$(BINDIR)/service-catalog: .init .generate_files cmd/service-catalog $(NEWEST_GO_FILE)
127+
$(DOCKER_CMD) $(GO_BUILD) -o $@ $(SC_PKG)/cmd/service-catalog
135128

136129
# This section contains the code generation stuff
137130
#################################################
@@ -331,7 +324,7 @@ clean-coverage:
331324

332325
# Building Docker Images for our executables
333326
############################################
334-
images: user-broker-image controller-manager-image apiserver-image
327+
images: user-broker-image service-catalog-image
335328

336329
images-all: $(addprefix arch-image-,$(ALL_ARCH))
337330
arch-image-%:
@@ -360,24 +353,17 @@ ifeq ($(ARCH),amd64)
360353
docker tag $(USER_BROKER_MUTABLE_IMAGE) $(REGISTRY)user-broker:$(MUTABLE_TAG)
361354
endif
362355

363-
apiserver-image: build/apiserver/Dockerfile $(BINDIR)/apiserver
364-
$(call build-and-tag,"apiserver",$(APISERVER_IMAGE),$(APISERVER_MUTABLE_IMAGE))
365-
ifeq ($(ARCH),amd64)
366-
docker tag $(APISERVER_IMAGE) $(REGISTRY)apiserver:$(VERSION)
367-
docker tag $(APISERVER_MUTABLE_IMAGE) $(REGISTRY)apiserver:$(MUTABLE_TAG)
368-
endif
369-
370-
controller-manager-image: build/controller-manager/Dockerfile $(BINDIR)/controller-manager
371-
$(call build-and-tag,"controller-manager",$(CONTROLLER_MANAGER_IMAGE),$(CONTROLLER_MANAGER_MUTABLE_IMAGE))
356+
service-catalog-image: build/service-catalog/Dockerfile $(BINDIR)/service-catalog
357+
$(call build-and-tag,"service-catalog",$(SERVICE_CATALOG_IMAGE),$(SERVICE_CATALOG_MUTABLE_IMAGE))
372358
ifeq ($(ARCH),amd64)
373-
docker tag $(CONTROLLER_MANAGER_IMAGE) $(REGISTRY)controller-manager:$(VERSION)
374-
docker tag $(CONTROLLER_MANAGER_MUTABLE_IMAGE) $(REGISTRY)controller-manager:$(MUTABLE_TAG)
359+
docker tag $(SERVICE_CATALOG_IMAGE) $(REGISTRY)service-catalog:$(VERSION)
360+
docker tag $(SERVICE_CATALOG_MUTABLE_IMAGE) $(REGISTRY)service-catalog:$(MUTABLE_TAG)
375361
endif
376362

377363

378364
# Push our Docker Images to a registry
379365
######################################
380-
push: user-broker-push controller-manager-push apiserver-push
366+
push: user-broker-push service-catalog-push
381367

382368
user-broker-push: user-broker-image
383369
docker push $(USER_BROKER_IMAGE)
@@ -387,20 +373,12 @@ ifeq ($(ARCH),amd64)
387373
docker push $(REGISTRY)user-broker:$(MUTABLE_TAG)
388374
endif
389375

390-
controller-manager-push: controller-manager-image
391-
docker push $(CONTROLLER_MANAGER_IMAGE)
392-
docker push $(CONTROLLER_MANAGER_MUTABLE_IMAGE)
393-
ifeq ($(ARCH),amd64)
394-
docker push $(REGISTRY)controller-manager:$(VERSION)
395-
docker push $(REGISTRY)controller-manager:$(MUTABLE_TAG)
396-
endif
397-
398-
apiserver-push: apiserver-image
399-
docker push $(APISERVER_IMAGE)
400-
docker push $(APISERVER_MUTABLE_IMAGE)
376+
service-catalog-push: service-catalog-image
377+
docker push $(SERVICE_CATALOG_IMAGE)
378+
docker push $(SERVICE_CATALOG_MUTABLE_IMAGE)
401379
ifeq ($(ARCH),amd64)
402-
docker push $(REGISTRY)apiserver:$(VERSION)
403-
docker push $(REGISTRY)apiserver:$(MUTABLE_TAG)
380+
docker push $(REGISTRY)service-catalog:$(VERSION)
381+
docker push $(REGISTRY)service-catalog:$(MUTABLE_TAG)
404382
endif
405383

406384

build/apiserver/Dockerfile

-25
This file was deleted.

build/controller-manager/Dockerfile renamed to build/service-catalog/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ RUN export DEBIAN_FRONTEND=noninteractive && \
1919
apt-get install ca-certificates -y && \
2020
rm -rf /var/lib/apt/lists/*
2121

22-
ADD controller-manager /opt/services/
22+
ADD service-catalog opt/services/
2323

24-
ENTRYPOINT ["/opt/services/controller-manager" ]
24+
ENTRYPOINT ["/opt/services/service-catalog"]

charts/catalog/README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ chart and their default values.
4040

4141
| Parameter | Description | Default |
4242
|-----------|-------------|---------|
43-
| `apiserver.image` | apiserver image to use | `quay.io/kubernetes-service-catalog/apiserver:v0.1.0-rc2` |
44-
| `apiserver.imagePullPolicy` | `imagePullPolicy` for the apiserver | `Always` |
43+
| `image` | apiserver image to use | `quay.io/kubernetes-service-catalog/service-catalog:v0.1.0-rc2` |
44+
| `imagePullPolicy` | `imagePullPolicy` for the service catalog | `Always` |
4545
| `apiserver.tls.cert` | Base64-encoded x509 certificate | A self-signed certificate |
4646
| `apiserver.tls.key` | Base64-encoded private key | The private key for the certificate above |
4747
| `apiserver.tls.ca` | Base64-encoded CA certificate used to sign the above certificate | |
@@ -53,8 +53,6 @@ chart and their default values.
5353
| `apiserver.storage.etcd.servers` | If storage type is `etcd`: etcd URL(s); override this if NOT using embedded etcd | `http://localhost:2379` |
5454
| `apiserver.verbosity` | Log level; valid values are in the range 0 - 10 | `10` |
5555
| `apiserver.auth.enabled` | Enable authentication and authorization | `false` |
56-
| `controllerManager.image` | controller-manager image to use | `quay.io/kubernetes-service-catalog/controller-manager:v0.1.0-rc2` |
57-
| `controllerManager.imagePullPolicy` | `imagePullPolicy` for the controller-manager | `Always` |
5856
| `controllerManager.verbosity` | Log level; valid values are in the range 0 - 10 | `10` |
5957
| `controllerManager.resyncInterval` | How often the controller should resync informers; duration format (`20m`, `1h`, etc) | `5m` |
6058
| `controllerManager.brokerRelistInterval` | How often the controller should relist the catalogs of ready brokers; duration format (`20m`, `1h`, etc) | `24h` |

charts/catalog/templates/apiserver-deployment.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ spec:
2323
serviceAccountName: "{{ .Values.apiserver.serviceAccount }}"
2424
containers:
2525
- name: apiserver
26-
image: {{ .Values.apiserver.image }}
27-
imagePullPolicy: {{ .Values.apiserver.imagePullPolicy }}
26+
image: {{ .Values.image }}
27+
imagePullPolicy: {{ .Values.imagePullPolicy }}
2828
resources:
2929
requests:
3030
cpu: 100m
@@ -33,6 +33,7 @@ spec:
3333
cpu: 100m
3434
memory: 30Mi
3535
args:
36+
- apiserver
3637
{{ if .Values.apiserver.audit.activated -}}
3738
- --audit-log-path
3839
- {{ .Values.apiserver.audit.logPath }}

charts/catalog/templates/controller-manager-deployment.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ spec:
2323
serviceAccountName: "{{ .Values.controllerManager.serviceAccount }}"
2424
containers:
2525
- name: controller-manager
26-
image: {{ .Values.controllerManager.image }}
27-
imagePullPolicy: {{ .Values.controllerManager.imagePullPolicy }}
26+
image: {{ .Values.image }}
27+
imagePullPolicy: {{ .Values.imagePullPolicy }}
2828
resources:
2929
requests:
3030
cpu: 100m
@@ -38,6 +38,7 @@ spec:
3838
fieldRef:
3939
fieldPath: metadata.namespace
4040
args:
41+
- controller-manager
4142
- --port
4243
- "8080"
4344
{{ if .Values.controllerManager.leaderElection.activated -}}

charts/catalog/values.yaml

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Default values for Service Catalog
2+
# service-catalog image to use
3+
image: quay.io/kubernetes-service-catalog/service-catalog:v0.1.0-rc2
4+
# imagePullPolicy for the service-catalog; valid values are "IfNotPresent",
5+
# "Never", and "Always"
6+
imagePullPolicy: Always
27
# determines whether the API server should be registered with the kube-aggregator
38
useAggregator: false
49
## If true, create & use RBAC resources
510
##
611
rbacEnable: true
712
apiserver:
8-
# apiserver image to use
9-
image: quay.io/kubernetes-service-catalog/apiserver:v0.1.0-rc2
10-
# imagePullPolicy for the apiserver; valid values are "IfNotPresent",
11-
# "Never", and "Always"
12-
imagePullPolicy: Always
1313
aggregator:
1414
# priority is the priority of the APIService. Please see
1515
# https://github.com/kubernetes/kubernetes/blob/v1.7.0/staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1/types.go#L56-L61
@@ -70,11 +70,6 @@ apiserver:
7070
logPath: "/tmp/service-catalog-apiserver-audit.log"
7171
serviceAccount: service-catalog-apiserver
7272
controllerManager:
73-
# controller-manager image to use
74-
image: quay.io/kubernetes-service-catalog/controller-manager:v0.1.0-rc2
75-
# imagePullPolicy for the controller-manager; valid values are
76-
# "IfNotPresent", "Never", and "Always"
77-
imagePullPolicy: Always
7873
# Log level; valid values are in the range 0 - 10
7974
verbosity: 10
8075
# Resync interval; format is a duration (`20m`, `1h`, etc)

cmd/apiserver/apiserver.go

-54
This file was deleted.

cmd/apiserver/app/plugins.go

-29
This file was deleted.

cmd/apiserver/app/server/options.go

+17-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ import (
2626
genericserveroptions "k8s.io/apiserver/pkg/server/options"
2727
)
2828

29+
const (
30+
// Store generated SSL certificates in a place that won't collide with the
31+
// k8s core API server.
32+
certDirectory = "/var/run/kubernetes-service-catalog"
33+
34+
storageTypeFlagName = "storageType"
35+
)
36+
2937
// ServiceCatalogServerOptions contains the aggregation of configuration structs for
3038
// the service-catalog server. It contains everything needed to configure a basic API server.
3139
// It is public so that integration tests can access it.
@@ -47,26 +55,32 @@ type ServiceCatalogServerOptions struct {
4755
EtcdOptions *EtcdOptions
4856
// DisableAuth disables delegating authentication and authorization for testing scenarios
4957
DisableAuth bool
50-
StopCh <-chan struct{}
5158
// StandaloneMode if true asserts that we will not depend on a kube-apiserver
5259
StandaloneMode bool
5360
}
5461

5562
// NewServiceCatalogServerOptions creates a new instances of
5663
// ServiceCatalogServerOptions with all sub-options filled in.
5764
func NewServiceCatalogServerOptions() *ServiceCatalogServerOptions {
58-
return &ServiceCatalogServerOptions{
65+
opts := &ServiceCatalogServerOptions{
5966
GenericServerRunOptions: genericserveroptions.NewServerRunOptions(),
6067
AdmissionOptions: genericserveroptions.NewAdmissionOptions(),
6168
SecureServingOptions: genericserveroptions.NewSecureServingOptions(),
6269
AuthenticationOptions: genericserveroptions.NewDelegatingAuthenticationOptions(),
6370
AuthorizationOptions: genericserveroptions.NewDelegatingAuthorizationOptions(),
6471
AuditOptions: genericserveroptions.NewAuditOptions(),
6572
EtcdOptions: NewEtcdOptions(),
73+
StandaloneMode: standaloneMode(),
6674
}
75+
// register all admission plugins
76+
registerAllAdmissionPlugins(opts.AdmissionOptions.Plugins)
77+
// Set generated SSL cert path correctly
78+
opts.SecureServingOptions.ServerCert.CertDirectory = certDirectory
79+
return opts
6780
}
6881

69-
func (s *ServiceCatalogServerOptions) addFlags(flags *pflag.FlagSet) {
82+
// AddFlags adds to the flag set the flags to configure the API Server.
83+
func (s *ServiceCatalogServerOptions) AddFlags(flags *pflag.FlagSet) {
7084
flags.StringVar(
7185
&s.StorageTypeString,
7286
"storage-type",

0 commit comments

Comments
 (0)