Skip to content

Commit 8702550

Browse files
committed
Support service port other than 443 for kube-aggregator
1 parent 11f37d7 commit 8702550

File tree

13 files changed

+101
-9
lines changed

13 files changed

+101
-9
lines changed

hack/.golint_failures

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ staging/src/k8s.io/code-generator/cmd/lister-gen/generators
607607
staging/src/k8s.io/component-base/cli/flag
608608
staging/src/k8s.io/component-base/config/v1alpha1
609609
staging/src/k8s.io/cri-api/pkg/apis/testing
610+
staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1
611+
staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1
610612
staging/src/k8s.io/kube-aggregator/pkg/controllers/autoregister
611613
staging/src/k8s.io/kube-proxy/config/v1alpha1
612614
staging/src/k8s.io/kubelet/config/v1beta1

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ type ServiceReference struct {
3434
Namespace string
3535
// Name is the name of the service
3636
Name string
37+
// If specified, the port on the service that hosting the service.
38+
// Default to 443 for backward compatibility.
39+
// `Port` should be a valid port number (1-65535, inclusive).
40+
// +optional
41+
Port int32
3742
}
3843

3944
// APIServiceSpec contains information for locating and communicating with a server.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/runtime"
21+
utilpointer "k8s.io/utils/pointer"
22+
)
23+
24+
func addDefaultingFuncs(scheme *runtime.Scheme) error {
25+
return RegisterDefaults(scheme)
26+
}
27+
28+
// SetDefaults_ServiceReference sets defaults for AuditSync Webhook's ServiceReference
29+
func SetDefaults_ServiceReference(obj *ServiceReference) {
30+
if obj.Port == nil {
31+
obj.Port = utilpointer.Int32Ptr(443)
32+
}
33+
}

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
// +k8s:conversion-gen=k8s.io/kube-aggregator/pkg/apis/apiregistration
2020
// +k8s:openapi-gen=true
2121
// +groupName=apiregistration.k8s.io
22+
// +k8s:defaulter-gen=TypeMeta
2223

2324
// Package v1 contains the API Registration API, which is responsible for
2425
// registering an API `Group`/`Version` with another kubernetes like API server.

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func init() {
4747
// We only register manually written functions here. The registration of the
4848
// generated functions takes place in the generated files. The separation
4949
// makes the code compile even when the generated files are missing.
50-
localSchemeBuilder.Register(addKnownTypes)
50+
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs)
5151
}
5252

5353
// Adds the list of known types to the given scheme.

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ type ServiceReference struct {
3434
Namespace string `json:"namespace,omitempty" protobuf:"bytes,1,opt,name=namespace"`
3535
// Name is the name of the service
3636
Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
37+
// If specified, the port on the service that hosting webhook.
38+
// Default to 443 for backward compatibility.
39+
// `Port` should be a valid port number (1-65535, inclusive).
40+
// +optional
41+
Port *int32 `json:"port,omitempty" protobuf:"varint,3,opt,name=port"`
3742
}
3843

3944
// APIServiceSpec contains information for locating and communicating with a server.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
"k8s.io/apimachinery/pkg/runtime"
21+
utilpointer "k8s.io/utils/pointer"
22+
)
23+
24+
func addDefaultingFuncs(scheme *runtime.Scheme) error {
25+
return RegisterDefaults(scheme)
26+
}
27+
28+
// SetDefaults_ServiceReference sets defaults for AuditSync Webhook's ServiceReference
29+
func SetDefaults_ServiceReference(obj *ServiceReference) {
30+
if obj.Port == nil {
31+
obj.Port = utilpointer.Int32Ptr(443)
32+
}
33+
}

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
// +k8s:conversion-gen=k8s.io/kube-aggregator/pkg/apis/apiregistration
2020
// +k8s:openapi-gen=true
2121
// +groupName=apiregistration.k8s.io
22+
// +k8s:defaulter-gen=TypeMeta
2223

2324
// Package v1beta1 contains the API Registration API, which is responsible for
2425
// registering an API `Group`/`Version` with another kubernetes like API server.

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func init() {
4747
// We only register manually written functions here. The registration of the
4848
// generated functions takes place in the generated files. The separation
4949
// makes the code compile even when the generated files are missing.
50-
localSchemeBuilder.Register(addKnownTypes)
50+
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs)
5151
}
5252

5353
// Adds the list of known types to the given scheme.

staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ type ServiceReference struct {
3434
Namespace string `json:"namespace,omitempty" protobuf:"bytes,1,opt,name=namespace"`
3535
// Name is the name of the service
3636
Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
37+
// If specified, the port on the service that hosting webhook.
38+
// Default to 443 for backward compatibility.
39+
// `Port` should be a valid port number (1-65535, inclusive).
40+
// +optional
41+
Port *int32 `json:"port,omitempty" protobuf:"varint,3,opt,name=port"`
3742
}
3843

3944
// APIServiceSpec contains information for locating and communicating with a server.

0 commit comments

Comments
 (0)